Chat-O-Matic/application/views/ConversationItem.cpp
Jaidyn Ann ce4d3c2a26 Fix checking of ConversationView's visibility
Since ConversationViews were manually removed/added previously, now
that a BCardLayout is used, the visibility-detection/some actions
change (e.g., using BView::Show instead of BView::AttachedToWindow).
2022-02-21 18:09:54 -06:00

79 lines
1.3 KiB
C++

/*
* Copyright 2021, Jaidyn Levesque <jadedctrl@teknik.io>
* All rights reserved. Distributed under the terms of the MIT license.
*/
#include "ConversationItem.h"
#include <InterfaceDefs.h>
#include <View.h>
#include "Conversation.h"
#include "NotifyMessage.h"
#include "Utils.h"
const int8 kMentioned = 1;
const int8 kMessage = 2;
ConversationItem::ConversationItem(const char* name, Conversation* chat)
:
BStringItem(name),
fChat(chat),
fStatus(0)
{
}
void
ConversationItem::DrawItem(BView* owner, BRect frame, bool complete)
{
rgb_color old = owner->HighColor();
if (fStatus & kMentioned)
owner->SetHighUIColor(B_SUCCESS_COLOR);
else if (fStatus & kMessage)
owner->SetHighColor(TintColor(ui_color(B_LIST_ITEM_TEXT_COLOR), 2));
BStringItem::DrawItem(owner, frame, complete);
owner->SetHighColor(old);
}
Conversation*
ConversationItem::GetConversation()
{
return fChat;
}
void
ConversationItem::ObserveString(int32 what, BString str)
{
switch (what)
{
case STR_ROOM_NAME:
SetText(str.String());
break;
}
}
void
ConversationItem::ObserveInteger(int32 what, int32 num)
{
switch (what)
{
case INT_NEW_MESSAGE:
fStatus |= kMessage;
break;
case INT_NEW_MENTION:
fStatus |= kMentioned;
break;
case INT_CONV_VIEW_SELECTED:
fStatus = 0;
break;
}
}