2012-03-11 10:11:29 -05:00
|
|
|
/*
|
|
|
|
* Copyright 2012, Casalinuovo Dario. All rights reserved.
|
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Casalinuovo Dario
|
|
|
|
*/
|
|
|
|
|
2021-05-23 15:10:14 -05:00
|
|
|
#include "UserInfoWindow.h"
|
2021-05-19 16:12:19 -05:00
|
|
|
|
2012-03-11 10:11:29 -05:00
|
|
|
#include <Alert.h>
|
|
|
|
#include <Application.h>
|
|
|
|
#include <Box.h>
|
|
|
|
#include <GridLayout.h>
|
|
|
|
#include <GridLayoutBuilder.h>
|
|
|
|
#include <GroupLayout.h>
|
|
|
|
#include <GroupLayoutBuilder.h>
|
|
|
|
#include <Layout.h>
|
|
|
|
#include <Message.h>
|
|
|
|
#include <SpaceLayoutItem.h>
|
|
|
|
#include <String.h>
|
|
|
|
|
2021-05-19 16:12:19 -05:00
|
|
|
#include <libinterface/BitmapView.h>
|
|
|
|
|
2021-06-20 12:44:20 -05:00
|
|
|
#include "AppMessages.h"
|
|
|
|
#include "ChatProtocolMessages.h"
|
|
|
|
#include "AppConstants.h"
|
|
|
|
#include "RenderView.h"
|
|
|
|
#include "Utils.h"
|
2012-03-11 10:11:29 -05:00
|
|
|
#include "NotifyMessage.h"
|
2021-05-23 15:10:14 -05:00
|
|
|
#include "User.h"
|
2012-03-11 10:11:29 -05:00
|
|
|
|
|
|
|
|
2021-05-23 15:10:14 -05:00
|
|
|
UserInfoWindow::UserInfoWindow(User* user)
|
2012-03-11 10:11:29 -05:00
|
|
|
:
|
|
|
|
BWindow(BRect(200, 200, 500, 400),
|
2021-05-23 15:10:14 -05:00
|
|
|
"User information", B_FLOATING_WINDOW,
|
2012-03-11 19:40:37 -05:00
|
|
|
B_NOT_ZOOMABLE | B_NOT_RESIZABLE),
|
2021-05-23 15:10:14 -05:00
|
|
|
fUser(user)
|
2012-03-11 10:11:29 -05:00
|
|
|
{
|
|
|
|
fPersonalMessage = new BTextView("personalMessage", B_WILL_DRAW);
|
2012-03-11 19:40:37 -05:00
|
|
|
fPersonalMessage->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT,
|
|
|
|
B_ALIGN_MIDDLE));
|
|
|
|
|
2021-05-23 15:10:14 -05:00
|
|
|
fPersonalMessage->SetText(fUser->GetNotifyPersonalStatus());
|
2012-03-11 10:11:29 -05:00
|
|
|
fPersonalMessage->SetExplicitMaxSize(BSize(200, 200));
|
|
|
|
fPersonalMessage->MakeEditable(false);
|
|
|
|
fPersonalMessage->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
|
|
|
|
2021-05-23 15:10:14 -05:00
|
|
|
BString status(fUser->GetName());
|
2021-06-20 12:44:20 -05:00
|
|
|
status << UserStatusToString(fUser->GetNotifyStatus());
|
2012-03-11 10:11:29 -05:00
|
|
|
|
|
|
|
status << "\n\n ID : ";
|
2021-05-23 15:10:14 -05:00
|
|
|
status << fUser->GetId();
|
2012-03-11 10:11:29 -05:00
|
|
|
|
|
|
|
fStatus = new BTextView("status", B_WILL_DRAW);
|
|
|
|
fStatus->SetText(status);
|
|
|
|
fStatus->MakeEditable(false);
|
|
|
|
fStatus->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
|
|
|
|
|
|
|
SetLayout(new BGroupLayout(B_HORIZONTAL));
|
|
|
|
|
2021-05-23 15:10:14 -05:00
|
|
|
fAvatar = new BitmapView("UserIcon");
|
2012-03-11 10:11:29 -05:00
|
|
|
fAvatar->SetExplicitMaxSize(BSize(70, 70));
|
|
|
|
fAvatar->SetExplicitMinSize(BSize(50, 50));
|
|
|
|
fAvatar->SetExplicitPreferredSize(BSize(50, 50));
|
|
|
|
fAvatar->SetExplicitAlignment(BAlignment(B_ALIGN_RIGHT, B_ALIGN_MIDDLE));
|
2021-05-23 15:10:14 -05:00
|
|
|
fAvatar->SetBitmap(fUser->AvatarBitmap());
|
2012-03-11 10:11:29 -05:00
|
|
|
|
|
|
|
AddChild(BGroupLayoutBuilder(B_VERTICAL, 10)
|
|
|
|
.AddGroup(B_HORIZONTAL)
|
|
|
|
.Add(fStatus)
|
|
|
|
.Add(fAvatar)
|
|
|
|
.End()
|
|
|
|
.AddGroup(B_HORIZONTAL)
|
|
|
|
.Add(fPersonalMessage)
|
|
|
|
.End()
|
|
|
|
.SetInsets(5, 5, 5, 5)
|
|
|
|
);
|
|
|
|
|
|
|
|
MoveTo(BAlert::AlertPosition(Bounds().Width(), Bounds().Height() / 2));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2021-05-23 15:10:14 -05:00
|
|
|
UserInfoWindow::MessageReceived(BMessage* message)
|
2012-03-11 10:11:29 -05:00
|
|
|
{
|
|
|
|
switch (message->what) {
|
|
|
|
default:
|
|
|
|
BWindow::MessageReceived(message);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|