2010-05-07 04:47:10 -05:00
|
|
|
#include "CayaRenderView.h"
|
2021-05-19 16:12:19 -05:00
|
|
|
|
|
|
|
#include <librunview/RunView.h>
|
|
|
|
#include <librunview/Theme.h>
|
|
|
|
|
|
|
|
#include "CayaPreferences.h"
|
2010-05-07 04:47:10 -05:00
|
|
|
|
2010-05-20 13:37:01 -05:00
|
|
|
|
2012-10-18 15:59:15 -05:00
|
|
|
CayaRenderView::CayaRenderView(const char *name, const char* smileyConfig)
|
|
|
|
:
|
2021-06-14 14:42:38 -05:00
|
|
|
RunView(BRect(0, 0, 1, 1), name,
|
|
|
|
fTheme = new Theme(name, COL_MAX_COLORS + 1, COL_MAX_COLORS + 1,
|
|
|
|
MAX_RENDERS + 1),
|
|
|
|
B_FOLLOW_ALL, B_WILL_DRAW)
|
2010-05-07 04:47:10 -05:00
|
|
|
{
|
|
|
|
if (smileyConfig)
|
|
|
|
Emoticor::Get()->LoadConfig(smileyConfig);
|
2010-05-20 13:37:01 -05:00
|
|
|
|
2010-05-07 04:47:10 -05:00
|
|
|
PrepareTheme(fTheme);
|
2010-05-20 13:37:01 -05:00
|
|
|
|
2021-06-14 14:42:38 -05:00
|
|
|
SetTimeStampFormat("[%H:%M]");
|
2010-05-07 04:47:10 -05:00
|
|
|
if ( IsHidden() )
|
|
|
|
Show();
|
|
|
|
ScrollToBottom();
|
|
|
|
}
|
|
|
|
|
2021-05-24 01:47:21 -05:00
|
|
|
|
2010-05-20 13:37:01 -05:00
|
|
|
void
|
2021-06-07 20:01:14 -05:00
|
|
|
CayaRenderView::AppendMessage(const char* nick, const char* message,
|
|
|
|
rgb_color nameColor)
|
2010-05-07 04:47:10 -05:00
|
|
|
{
|
2021-06-07 20:01:14 -05:00
|
|
|
rgb_color bg = ui_color(B_PANEL_BACKGROUND_COLOR);
|
|
|
|
rgb_color fg = ui_color(B_PANEL_TEXT_COLOR);
|
|
|
|
|
2021-06-14 14:42:38 -05:00
|
|
|
Append("<", nameColor, bg, nameColor, time(NULL));
|
2021-06-08 13:04:56 -05:00
|
|
|
Append(nick, fg, bg, fg);
|
|
|
|
Append("> ", nameColor, bg, nameColor);
|
2021-06-07 20:01:14 -05:00
|
|
|
// AddEmoticText(message, fg, bg);
|
|
|
|
Append(message, fg, bg, fg);
|
|
|
|
Append("\n", fg, bg, fg);
|
2010-05-20 13:37:01 -05:00
|
|
|
ScrollToSelection();
|
2010-05-07 04:47:10 -05:00
|
|
|
}
|
2010-05-20 13:37:01 -05:00
|
|
|
|
2010-05-07 04:47:10 -05:00
|
|
|
|
2021-05-24 19:12:42 -05:00
|
|
|
void
|
|
|
|
CayaRenderView::AppendGenericMessage(const char* message)
|
|
|
|
{
|
2021-06-07 20:01:14 -05:00
|
|
|
rgb_color bg = ui_color(B_PANEL_BACKGROUND_COLOR);
|
|
|
|
rgb_color fg = ui_color(B_PANEL_TEXT_COLOR);
|
|
|
|
|
2021-06-14 14:42:38 -05:00
|
|
|
Append(message, fg, bg, fg, time(NULL));
|
2021-05-24 19:12:42 -05:00
|
|
|
ScrollToSelection();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-05-07 04:47:10 -05:00
|
|
|
void
|
2021-06-07 20:01:14 -05:00
|
|
|
CayaRenderView::AddEmoticText(const char * txt, rgb_color fore, rgb_color bg)
|
2010-05-20 13:37:01 -05:00
|
|
|
{
|
|
|
|
if (CayaPreferences::Item()->IgnoreEmoticons)
|
2021-06-07 20:01:14 -05:00
|
|
|
Append(txt, fore, bg, fore);
|
2010-05-20 13:37:01 -05:00
|
|
|
else
|
2021-06-07 20:01:14 -05:00
|
|
|
Emoticor::Get()->AddText(this, txt, fore, fore, bg, fore);
|
2010-05-07 04:47:10 -05:00
|
|
|
}
|
|
|
|
|
2021-05-24 01:47:21 -05:00
|
|
|
|
2010-05-07 04:47:10 -05:00
|
|
|
void
|
|
|
|
CayaRenderView::PrepareTheme(Theme *fTheme)
|
|
|
|
{
|
|
|
|
Theme::TimestampFore = COL_TIMESTAMP_DUMMY;
|
|
|
|
Theme::TimestampBack = COL_TIMESTAMP_DUMMY;
|
|
|
|
Theme::TimespaceFore = COL_MAX_COLORS;
|
|
|
|
Theme::TimespaceBack = COL_MAX_COLORS;
|
|
|
|
Theme::TimespaceFont = MAX_RENDERS;
|
|
|
|
Theme::TimestampFont = R_TIMESTAMP_DUMMY;
|
|
|
|
Theme::NormalFore = COL_TEXT;
|
|
|
|
Theme::NormalBack = COL_TEXT;
|
|
|
|
Theme::NormalFont = R_TEXT;
|
|
|
|
Theme::SelectionBack = COL_SELECTION;
|
|
|
|
|
|
|
|
fTheme->WriteLock();
|
2021-05-30 19:34:07 -05:00
|
|
|
rgb_color bg = ui_color(B_PANEL_BACKGROUND_COLOR);
|
|
|
|
rgb_color fg = ui_color(B_PANEL_TEXT_COLOR);
|
2010-05-20 13:37:01 -05:00
|
|
|
|
2021-05-30 19:34:07 -05:00
|
|
|
fTheme->SetForeground(COL_URL, ui_color(B_LINK_TEXT_COLOR));
|
|
|
|
fTheme->SetBackground(COL_URL, bg);
|
2010-05-07 04:47:10 -05:00
|
|
|
|
2021-05-30 19:34:07 -05:00
|
|
|
fTheme->SetForeground(COL_TIMESTAMP, fg);
|
|
|
|
fTheme->SetBackground(COL_TIMESTAMP, bg);
|
2010-05-20 13:37:01 -05:00
|
|
|
|
2021-05-30 19:34:07 -05:00
|
|
|
fTheme->SetForeground(COL_TEXT, fg);
|
|
|
|
fTheme->SetBackground(COL_TEXT, bg);
|
2010-05-20 13:37:01 -05:00
|
|
|
|
2021-05-30 19:34:07 -05:00
|
|
|
fTheme->SetForeground(COL_ACTION, fg);
|
|
|
|
fTheme->SetBackground(COL_ACTION, bg);
|
|
|
|
|
|
|
|
fTheme->SetForeground(COL_SELECTION, ui_color(B_MENU_SELECTED_ITEM_TEXT_COLOR));
|
|
|
|
fTheme->SetBackground(COL_SELECTION, ui_color(B_MENU_SELECTED_BACKGROUND_COLOR));
|
2010-05-07 04:47:10 -05:00
|
|
|
|
|
|
|
fTheme->SetForeground(COL_OWNNICK, 0, 0, 255);
|
2021-05-30 19:34:07 -05:00
|
|
|
fTheme->SetBackground(COL_OWNNICK, bg);
|
2010-05-20 13:37:01 -05:00
|
|
|
|
2010-05-07 04:47:10 -05:00
|
|
|
fTheme->SetForeground(COL_OTHERNICK, 255, 0, 0);
|
2021-05-30 19:34:07 -05:00
|
|
|
fTheme->SetBackground(COL_OTHERNICK, bg);
|
2010-05-20 13:37:01 -05:00
|
|
|
|
|
|
|
fTheme->SetTextRender(R_EMOTICON, &str);
|
2010-05-07 04:47:10 -05:00
|
|
|
|
|
|
|
fTheme->SetSoftLineIndent(5.0);
|
|
|
|
fTheme->SetTextMargin(5.0);
|
|
|
|
|
|
|
|
fTheme->WriteUnlock();
|
|
|
|
}
|
2021-05-24 01:47:21 -05:00
|
|
|
|
|
|
|
|