diff options
Diffstat (limited to 'plugins/NewStory')
-rw-r--r-- | plugins/NewStory/src/history_array.cpp | 56 | ||||
-rw-r--r-- | plugins/NewStory/src/history_array.h | 3 | ||||
-rw-r--r-- | plugins/NewStory/src/history_control.cpp | 91 | ||||
-rw-r--r-- | plugins/NewStory/src/options.cpp | 18 |
4 files changed, 74 insertions, 94 deletions
diff --git a/plugins/NewStory/src/history_array.cpp b/plugins/NewStory/src/history_array.cpp index 3b8512738e..c8c5fc44a4 100644 --- a/plugins/NewStory/src/history_array.cpp +++ b/plugins/NewStory/src/history_array.cpp @@ -38,7 +38,9 @@ bool Filter::check(ItemData *item) return true; }; +///////////////////////////////////////////////////////////////////////////////////////// // Event + void ItemData::load(bool bFullLoad) { if (!bFullLoad || bLoaded) @@ -91,6 +93,60 @@ ItemData::~ItemData() MTextDestroy(data); } +int ItemData::getTemplate() const +{ + switch (dbe.eventType) { + case EVENTTYPE_MESSAGE: return isGrouped() ? TPL_MSG_GRP : TPL_MESSAGE; + case EVENTTYPE_FILE: return TPL_FILE; + case EVENTTYPE_STATUSCHANGE: return TPL_SIGN; + case EVENTTYPE_AUTHREQUEST: return TPL_AUTH; + case EVENTTYPE_ADDED: return TPL_ADDED; + case EVENTTYPE_JABBER_PRESENCE: return TPL_PRESENCE; + default: + return TPL_OTHER; + } +} + +void ItemData::getFontColor(int &fontId, int &colorId) const +{ + switch (dbe.eventType) { + case EVENTTYPE_MESSAGE: + fontId = !(dbe.flags & DBEF_SENT) ? FONT_INMSG : FONT_OUTMSG; + colorId = !(dbe.flags & DBEF_SENT) ? COLOR_INMSG : COLOR_OUTMSG; + break; + + case EVENTTYPE_FILE: + fontId = !(dbe.flags & DBEF_SENT) ? FONT_INFILE : FONT_OUTFILE; + colorId = !(dbe.flags & DBEF_SENT) ? COLOR_INFILE : COLOR_OUTFILE; + break; + + case EVENTTYPE_STATUSCHANGE: + fontId = FONT_STATUS; + colorId = COLOR_STATUS; + break; + + case EVENTTYPE_AUTHREQUEST: + fontId = FONT_INOTHER; + colorId = COLOR_INOTHER; + break; + + case EVENTTYPE_ADDED: + fontId = FONT_INOTHER; + colorId = COLOR_INOTHER; + break; + + case EVENTTYPE_JABBER_PRESENCE: + fontId = !(dbe.flags & DBEF_SENT) ? FONT_INOTHER : FONT_OUTOTHER; + colorId = !(dbe.flags & DBEF_SENT) ? COLOR_INOTHER : COLOR_OUTOTHER; + break; + + default: + fontId = !(dbe.flags & DBEF_SENT) ? FONT_INOTHER : FONT_OUTOTHER; + colorId = !(dbe.flags & DBEF_SENT) ? COLOR_INOTHER : COLOR_OUTOTHER; + break; + } +} + // Array HistoryArray::HistoryArray() : pages(50), diff --git a/plugins/NewStory/src/history_array.h b/plugins/NewStory/src/history_array.h index 22b1327dad..07768f03dd 100644 --- a/plugins/NewStory/src/history_array.h +++ b/plugins/NewStory/src/history_array.h @@ -22,6 +22,9 @@ struct ItemData void load(bool bFullLoad); bool isGrouped() const; + int getTemplate() const; + void getFontColor(int &fontId, int &colorId) const; + inline wchar_t *getWBuf() { load(true); diff --git a/plugins/NewStory/src/history_control.cpp b/plugins/NewStory/src/history_control.cpp index 36ecde6e4a..726b586a8f 100644 --- a/plugins/NewStory/src/history_control.cpp +++ b/plugins/NewStory/src/history_control.cpp @@ -258,48 +258,12 @@ struct NewstoryListData : public MZeroedObject return 0; } - int tpl; - int fontid; - switch (item->dbe.eventType) { - case EVENTTYPE_MESSAGE: - tpl = item->isGrouped() ? TPL_MSG_GRP : TPL_MESSAGE; - fontid = !(item->dbe.flags & DBEF_SENT) ? FONT_INMSG : FONT_OUTMSG; - break; - - case EVENTTYPE_FILE: - tpl = TPL_FILE; - fontid = !(item->dbe.flags & DBEF_SENT) ? FONT_INFILE : FONT_OUTFILE; - break; - - case EVENTTYPE_STATUSCHANGE: - tpl = TPL_SIGN; - fontid = FONT_STATUS; - break; - - case EVENTTYPE_AUTHREQUEST: - tpl = TPL_AUTH; - fontid = FONT_INOTHER; - break; - - case EVENTTYPE_ADDED: - tpl = TPL_ADDED; - fontid = FONT_INOTHER; - break; - - case EVENTTYPE_JABBER_PRESENCE: - tpl = TPL_PRESENCE; - fontid = !(item->dbe.flags & DBEF_SENT) ? FONT_INOTHER : FONT_OUTOTHER; - break; - - default: - tpl = TPL_OTHER; - fontid = !(item->dbe.flags & DBEF_SENT) ? FONT_INOTHER : FONT_OUTOTHER; - break; - } + int fontid, colorid; + item->getFontColor(fontid, colorid); HFONT hfnt = (HFONT)SelectObject(hdc, g_fontTable[fontid].hfnt); if (!item->data) - item->data = MTextCreateW(htuLog, ptrW(TplFormatString(tpl, item->hContact, item))); + item->data = MTextCreateW(htuLog, ptrW(TplFormatString(item->getTemplate(), item->hContact, item))); SIZE sz; sz.cx = width - 6; @@ -317,52 +281,9 @@ struct NewstoryListData : public MZeroedObject // LOGFONT lfText; COLORREF clText, clBack, clLine; - int tpl; - int fontid; - int colorid; - switch (item->dbe.eventType) { - case EVENTTYPE_MESSAGE: - tpl = item->isGrouped() ? TPL_MSG_GRP : TPL_MESSAGE; - fontid = !(item->dbe.flags & DBEF_SENT) ? FONT_INMSG : FONT_OUTMSG; - colorid = !(item->dbe.flags & DBEF_SENT) ? COLOR_INMSG : COLOR_OUTMSG; - break; - - case EVENTTYPE_FILE: - tpl = TPL_FILE; - fontid = !(item->dbe.flags & DBEF_SENT) ? FONT_INFILE : FONT_OUTFILE; - colorid = !(item->dbe.flags & DBEF_SENT) ? COLOR_INFILE : COLOR_OUTFILE; - break; - - case EVENTTYPE_STATUSCHANGE: - tpl = TPL_SIGN; - fontid = FONT_STATUS; - colorid = COLOR_STATUS; - break; - - case EVENTTYPE_AUTHREQUEST: - tpl = TPL_AUTH; - fontid = FONT_INOTHER; - colorid = COLOR_INOTHER; - break; + int fontid, colorid; + item->getFontColor(fontid, colorid); - case EVENTTYPE_ADDED: - tpl = TPL_ADDED; - fontid = FONT_INOTHER; - colorid = COLOR_INOTHER; - break; - - case EVENTTYPE_JABBER_PRESENCE: - tpl = TPL_PRESENCE; - fontid = !(item->dbe.flags & DBEF_SENT) ? FONT_INOTHER : FONT_OUTOTHER; - colorid = !(item->dbe.flags & DBEF_SENT) ? COLOR_INOTHER : COLOR_OUTOTHER; - break; - - default: - tpl = TPL_OTHER; - fontid = !(item->dbe.flags & DBEF_SENT) ? FONT_INOTHER : FONT_OUTOTHER; - colorid = !(item->dbe.flags & DBEF_SENT) ? COLOR_INOTHER : COLOR_OUTOTHER; - break; - } clText = g_fontTable[fontid].cl; if (item->bSelected) { MTextSendMessage(0, item->data, EM_SETSEL, 0, -1); @@ -377,7 +298,7 @@ struct NewstoryListData : public MZeroedObject } if (!item->data) { - item->data = MTextCreateW(htuLog, ptrW(TplFormatString(tpl, item->hContact, item))); + item->data = MTextCreateW(htuLog, ptrW(TplFormatString(item->getTemplate(), item->hContact, item))); if (!item->data) return 0; } diff --git a/plugins/NewStory/src/options.cpp b/plugins/NewStory/src/options.cpp index f5306862bd..e63d4ac88f 100644 --- a/plugins/NewStory/src/options.cpp +++ b/plugins/NewStory/src/options.cpp @@ -73,6 +73,14 @@ public: bthVarHelp.OnClick = Callback(this, &CTemplateOptsDlg::onVarHelp); m_tree.OnSelChanged = Callback(this, &CTemplateOptsDlg::onSelChanged); + } + + bool OnInitDialog() override + { + HIMAGELIST himgTree = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_COLOR32 | ILC_MASK, 1, 1); + m_tree.SetImageList(himgTree, TVSIL_NORMAL); + + ImageList_AddIcon(himgTree, g_plugin.getIcon(ICO_TPLGROUP)); m_hContact = db_add_contact(); Proto_AddToContact(m_hContact, META_PROTO); @@ -82,19 +90,11 @@ public: DBEVENTINFO dbei = {}; dbei.pBlob = (BYTE *)"The quick brown fox jumps over the lazy dog"; - dbei.cbBlob = (DWORD)strlen((char*)dbei.pBlob); + dbei.cbBlob = (DWORD)strlen((char *)dbei.pBlob); dbei.flags = DBEF_TEMPORARY; dbei.eventType = EVENTTYPE_MESSAGE; dbei.timestamp = time(0); m_hDbEVent = db_event_add(m_hContact, &dbei); - } - - bool OnInitDialog() override - { - HIMAGELIST himgTree = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_COLOR32 | ILC_MASK, 1, 1); - m_tree.SetImageList(himgTree, TVSIL_NORMAL); - - ImageList_AddIcon(himgTree, g_plugin.getIcon(ICO_TPLGROUP)); HTREEITEM hGroup = 0, hFirst = 0; const wchar_t *pwszPrevGroup = nullptr; |