2021-05-31 10:50:43 -05:00
|
|
|
/*
|
|
|
|
* Copyright 2021, Jaidyn Levesque <jadedctrl@teknik.io>
|
|
|
|
* All rights reserved. Distributed under the terms of the MIT license.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "UserItem.h"
|
|
|
|
|
2021-06-03 23:41:23 -05:00
|
|
|
#include <InterfaceDefs.h>
|
|
|
|
#include <View.h>
|
|
|
|
|
|
|
|
#include "CayaConstants.h"
|
2021-06-04 13:57:04 -05:00
|
|
|
#include "CayaUtils.h"
|
2021-06-02 16:53:03 -05:00
|
|
|
#include "NotifyMessage.h"
|
2021-05-31 10:50:43 -05:00
|
|
|
#include "User.h"
|
|
|
|
|
|
|
|
|
2021-06-03 23:41:23 -05:00
|
|
|
UserItem::UserItem(const char* name, User* user, int32 status)
|
2021-05-31 10:50:43 -05:00
|
|
|
:
|
|
|
|
BStringItem(name),
|
2021-06-03 23:41:23 -05:00
|
|
|
fUser(user),
|
2021-06-04 13:57:04 -05:00
|
|
|
fStatus(status)
|
2021-05-31 10:50:43 -05:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-06-03 23:41:23 -05:00
|
|
|
void
|
|
|
|
UserItem::DrawItem(BView* owner, BRect frame, bool complete)
|
2021-05-31 10:50:43 -05:00
|
|
|
{
|
2021-06-03 23:41:23 -05:00
|
|
|
rgb_color highColor = owner->HighColor();
|
2021-06-04 13:57:04 -05:00
|
|
|
owner->SetHighColor(_GetTextColor(highColor));
|
2021-06-03 23:41:23 -05:00
|
|
|
|
|
|
|
BStringItem::DrawItem(owner, frame, complete);
|
|
|
|
|
|
|
|
owner->SetHighColor(highColor);
|
2021-05-31 10:50:43 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
UserItem::ObserveString(int32 what, BString str)
|
|
|
|
{
|
2021-06-02 16:53:03 -05:00
|
|
|
switch (what) {
|
|
|
|
case STR_CONTACT_NAME:
|
|
|
|
SetText(str);
|
|
|
|
break;
|
|
|
|
}
|
2021-05-31 10:50:43 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-06-03 23:41:23 -05:00
|
|
|
void
|
|
|
|
UserItem::ObserveInteger(int32 what, int32 value)
|
|
|
|
{
|
|
|
|
switch (what) {
|
|
|
|
case INT_CONTACT_STATUS:
|
|
|
|
{
|
2021-06-04 13:57:04 -05:00
|
|
|
fStatus = value;
|
2021-06-03 23:41:23 -05:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
User*
|
|
|
|
UserItem::GetUser()
|
|
|
|
{
|
|
|
|
return fUser;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-06-04 13:57:04 -05:00
|
|
|
rgb_color
|
|
|
|
UserItem::_GetTextColor(rgb_color highColor)
|
2021-06-03 23:41:23 -05:00
|
|
|
{
|
2021-06-04 13:57:04 -05:00
|
|
|
switch (fStatus)
|
2021-06-03 23:41:23 -05:00
|
|
|
{
|
|
|
|
case CAYA_AWAY:
|
2021-06-04 13:57:04 -05:00
|
|
|
return CayaTintColor(ui_color(B_LIST_ITEM_TEXT_COLOR), 1);
|
2021-06-03 23:41:23 -05:00
|
|
|
case CAYA_INVISIBLE:
|
|
|
|
case CAYA_DO_NOT_DISTURB:
|
2021-06-04 13:57:04 -05:00
|
|
|
return CayaTintColor(ui_color(B_LIST_ITEM_TEXT_COLOR), 2);
|
2021-06-03 23:41:23 -05:00
|
|
|
case CAYA_OFFLINE:
|
2021-06-04 13:57:04 -05:00
|
|
|
return CayaTintColor(ui_color(B_LIST_ITEM_TEXT_COLOR), 3);
|
2021-06-03 23:41:23 -05:00
|
|
|
}
|
2021-06-04 13:57:04 -05:00
|
|
|
return highColor;
|
2021-06-03 23:41:23 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|