diff options
author | George Hazan <ghazan@miranda.im> | 2019-03-12 13:43:31 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2019-03-12 13:43:31 +0300 |
commit | 8dd4143614ffa1a309f07f0b1a19921955f9c3f5 (patch) | |
tree | c99f5116020adb618d020fe4df7283fb5268d9ab | |
parent | 6312425c1ad093cad87a688497728fdb12e24385 (diff) |
MirandaG15: warning fixes + massive code cleaning
54 files changed, 1996 insertions, 2372 deletions
diff --git a/plugins/MirandaG15/src/CAppletManager.cpp b/plugins/MirandaG15/src/CAppletManager.cpp index da2980fe03..583f847b54 100644 --- a/plugins/MirandaG15/src/CAppletManager.cpp +++ b/plugins/MirandaG15/src/CAppletManager.cpp @@ -576,7 +576,7 @@ void CAppletManager::HandleEvent(CEvent *pEvent) // if the applet is in foreground, skip notifications for the chatsession contact if (pEvent->hContact && GetLCDConnection()->IsForeground() && pEvent->hContact == m_ChatScreen.GetContact() && (!m_ChatScreen.IsInputActive() || !CConfig::GetBoolSetting(NOTIFY_NO_SKIP_REPLY))) { - if (pEvent->eType == EVENT_STATUS && CConfig::GetBoolSetting(NOTIFY_SKIP_STATUS)) + if (pEvent->eType == EVENT_STATUS && CConfig::GetBoolSetting(NOTIFY_SKIP_STATUS)) pEvent->bNotification = false; if (pEvent->eType == EVENT_SIGNED_ON && CConfig::GetBoolSetting(NOTIFY_SKIP_SIGNON)) pEvent->bNotification = false; @@ -1627,7 +1627,7 @@ int CAppletManager::HookSettingChanged(WPARAM hContact, LPARAM lParam) Event.hContact = hContact; if (!strcmp(dbcws->szSetting, "Nick") || !strcmp(dbcws->szSetting, "MyHandle")) { - DBVARIANT dbv = { 0 }; + DBVARIANT dbv = {0}; // if the protocol nick has changed, check if a custom handle is set if (!strcmp(dbcws->szSetting, "Nick")) { if (!db_get_ws(Event.hContact, "CList", "MyHandle", &dbv)) { diff --git a/plugins/MirandaG15/src/CAppletManager.h b/plugins/MirandaG15/src/CAppletManager.h index f80b612c83..12e4978469 100644 --- a/plugins/MirandaG15/src/CAppletManager.h +++ b/plugins/MirandaG15/src/CAppletManager.h @@ -45,11 +45,11 @@ public: bool Update();
// the update timer's callback function
- static VOID CALLBACK UpdateTimer(HWND hwnd,UINT uMsg,UINT_PTR idEvent,DWORD dwTime);
+ static VOID CALLBACK UpdateTimer(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime);
// called when the plugin's configuration has changed
void OnConfigChanged();
-
+
// called to process the specified event
void HandleEvent(CEvent *pEvent);
@@ -64,24 +64,24 @@ public: // hook functions
static int HookMessageWindowEvent(WPARAM wParam, LPARAM lParam);
static int HookContactIsTyping(WPARAM wParam, LPARAM lParam);
- static int HookEventAdded(WPARAM wParam, LPARAM lParam);
+ static int HookEventAdded(WPARAM wParam, LPARAM lParam);
static int HookStatusChanged(WPARAM wParam, LPARAM lParam);
static int HookProtoAck(WPARAM wParam, LPARAM lParam);
static int HookContactAdded(WPARAM wParam, LPARAM lParam);
static int HookContactDeleted(WPARAM wParam, LPARAM lParam);
- static int HookSettingChanged(WPARAM wParam,LPARAM lParam);
- static int HookChatInbound(WPARAM wParam,LPARAM lParam);
+ static int HookSettingChanged(WPARAM wParam, LPARAM lParam);
+ static int HookChatInbound(WPARAM wParam, LPARAM lParam);
// check if a contacts message window is opened
static bool IsMessageWindowOpen(MCONTACT hContact);
// marks the given event as read
static void MarkMessageAsRead(MCONTACT hContact, MEVENT hEvent);
// translates the given database event
- static bool TranslateDBEvent(CEvent *pEvent,WPARAM wParam, LPARAM lParam);
+ static bool TranslateDBEvent(CEvent *pEvent, WPARAM wParam, LPARAM lParam);
// sends a message to the specified contact
- static MEVENT SendMessageToContact(MCONTACT hContact,tstring strMessage);
+ static MEVENT SendMessageToContact(MCONTACT hContact, tstring strMessage);
// sends typing notifications to the specified contact
- static void SendTypingNotification(MCONTACT hContact,bool bEnable);
+ static void SendTypingNotification(MCONTACT hContact, bool bEnable);
// returns a formatted timestamp string
static tstring GetFormattedTimestamp(tm *time);
@@ -89,11 +89,11 @@ public: // returns the contacts group
static tstring GetContactGroup(MCONTACT hContact);
// returns the contacts displayname
- static tstring GetContactDisplayname(MCONTACT hContact,bool bShortened=false);
+ static tstring GetContactDisplayname(MCONTACT hContact, bool bShortened = false);
// returns the history class for the specified IRC channel
CIRCHistory *GetIRCHistory(MCONTACT hContact);
- CIRCHistory *GetIRCHistoryByName(tstring strProtocol,tstring strChannel);
+ CIRCHistory *GetIRCHistoryByName(tstring strProtocol, tstring strChannel);
// returns the IRC connection class for the specified protocol
CIRCConnection *GetIRCConnection(tstring strProtocol);
@@ -108,15 +108,15 @@ public: // checks if the patched IRC protocol is in place
bool IsIRCHookEnabled();
- static tstring TranslateString(wchar_t *szString,...);
+ static tstring TranslateString(wchar_t *szString, ...);
private:
list<CIRCHistory*> m_LIRCHistorys;
// deletes the history class for the specified IRC channel
void DeleteIRCHistory(MCONTACT hContact);
// creates a history class for the specified IRC channel
- CIRCHistory *CreateIRCHistory(MCONTACT hContact,tstring strChannel);
- CIRCHistory *CreateIRCHistoryByName(tstring strProtocol,tstring strChannel);
+ CIRCHistory *CreateIRCHistory(MCONTACT hContact, tstring strChannel);
+ CIRCHistory *CreateIRCHistoryByName(tstring strProtocol, tstring strChannel);
// activate a screen
void ActivateScreen(CScreen *pScreen);
@@ -128,7 +128,7 @@ private: void OnConnectionChanged(int iConnectionState);
// Called when the active screen has expired
void OnScreenExpired(CLCDScreen *pScreen);
-
+
// updates all pending message jobs
void UpdateMessageJobs();
// adds a message job to the list
@@ -149,15 +149,15 @@ private: list<SMessageJob*> m_MessageJobs;
// update timer handle
- UINT m_uiTimer;
+ UINT m_uiTimer;
// screens
- CNotificationScreen m_NotificationScreen;
- CEventScreen m_EventScreen;
- CContactlistScreen m_ContactlistScreen;
- CChatScreen m_ChatScreen;
- CCreditsScreen m_CreditsScreen;
- CScreensaverScreen m_ScreensaverScreen;
+ CNotificationScreen m_NotificationScreen;
+ CEventScreen m_EventScreen;
+ CContactlistScreen m_ContactlistScreen;
+ CChatScreen m_ChatScreen;
+ CCreditsScreen m_CreditsScreen;
+ CScreensaverScreen m_ScreensaverScreen;
// protocol data
vector<CProtocolData*> m_vProtocolData;
@@ -166,8 +166,8 @@ private: // hook handles
HANDLE m_hMIHookMessageWindowEvent;
HANDLE m_hMIHookContactIsTyping;
- HANDLE m_hMIHookEventAdded;
- HANDLE m_hMIHookStatusChanged;
+ HANDLE m_hMIHookEventAdded;
+ HANDLE m_hMIHookStatusChanged;
HANDLE m_hMIHookProtoAck;
HANDLE m_hMIHookSettingChanged;
HANDLE m_hMIHookContactDeleted;
@@ -178,7 +178,7 @@ private: // last active screen
CScreen *m_pLastScreen;
-
+
bool m_bScreensaver;
HBITMAP m_ahStatusBitmaps[8];
@@ -186,4 +186,4 @@ private: HBITMAP m_ahLargeEventBitmaps[4];
};
-#endif
\ No newline at end of file +#endif
diff --git a/plugins/MirandaG15/src/CChatScreen.cpp b/plugins/MirandaG15/src/CChatScreen.cpp index 8fb8c7af79..580d5aa024 100644 --- a/plugins/MirandaG15/src/CChatScreen.cpp +++ b/plugins/MirandaG15/src/CChatScreen.cpp @@ -6,11 +6,7 @@ //************************************************************************
// Constructor
//************************************************************************
-CChatScreen::CChatScreen() : m_bTyping(false), m_bHideTitle(false), m_bContactTyping(false),
- m_bHideLabels(false), m_bMaximizedTimer(false), m_bCloseTimer(false),
- m_bIRCProtocol(false), m_dwCloseTimer(0), m_dwMaximizedTimer(0),
- m_dwMaximizedDuration(0), m_eReplyState(REPLY_STATE_NONE), m_iStatus(ID_STATUS_OFFLINE),
- m_hContact(NULL), m_hMessage(0)
+CChatScreen::CChatScreen()
{
}
@@ -26,7 +22,7 @@ CChatScreen::~CChatScreen() //************************************************************************
bool CChatScreen::Initialize()
{
- if(!CScreen::Initialize())
+ if (!CScreen::Initialize())
return false;
m_InfoText.Initialize();
@@ -36,7 +32,7 @@ bool CChatScreen::Initialize() m_Input.Initialize();
m_TextLog.Initialize();
m_Scrollbar.Initialize();
-
+
UpdateObjects();
// other attributes
m_InfoText.SetAlignment(DT_CENTER);
@@ -52,16 +48,16 @@ bool CChatScreen::Initialize() m_UserStatus.SetAlignment(DT_LEFT);
m_UserStatus.SetWordWrap(TRUE);
m_UserStatus.SetText(L"Status");
-
-
+
+
m_UserProto.SetAlignment(DT_RIGHT);
m_UserProto.SetWordWrap(TRUE);
m_UserProto.SetText(L"User");
m_Input.Show(0);
-
+
m_TextLog.Show(1);
-
+
m_TextLog.SetScrollbar(&m_Scrollbar);
AddObject(&m_Scrollbar);
@@ -73,10 +69,10 @@ bool CChatScreen::Initialize() AddObject(&m_UserProto);
- SetButtonBitmap(0,IDB_UP);
- SetButtonBitmap(1,IDB_DOWN);
- SetButtonBitmap(2,IDB_HISTORY);
- SetButtonBitmap(3,IDB_REPLY);
+ SetButtonBitmap(0, IDB_UP);
+ SetButtonBitmap(1, IDB_DOWN);
+ SetButtonBitmap(2, IDB_HISTORY);
+ SetButtonBitmap(3, IDB_REPLY);
return true;
}
@@ -86,7 +82,7 @@ bool CChatScreen::Initialize() //************************************************************************
bool CChatScreen::Shutdown()
{
- if(!CScreen::Shutdown())
+ if (!CScreen::Shutdown())
return false;
return true;
@@ -99,13 +95,12 @@ void CChatScreen::UpdateObjects() {
m_bHideTitle = false;
m_bHideLabels = !CConfig::GetBoolSetting(SHOW_LABELS);
-
- if(IsMaximized())
- {
- if(!m_bHideTitle && !CConfig::GetBoolSetting(MAXIMIZED_TITLE))
+
+ if (IsMaximized()) {
+ if (!m_bHideTitle && !CConfig::GetBoolSetting(MAXIMIZED_TITLE))
m_bHideTitle = true;
- if(!m_bHideLabels && !CConfig::GetBoolSetting(MAXIMIZED_LABELS))
+ if (!m_bHideLabels && !CConfig::GetBoolSetting(MAXIMIZED_LABELS))
m_bHideLabels = true;
}
@@ -117,45 +112,45 @@ void CChatScreen::UpdateObjects() m_UserName.SetFont(CConfig::GetFont(FONT_TITLE));
m_UserStatus.SetFont(CConfig::GetFont(FONT_TITLE));
m_UserProto.SetFont(CConfig::GetFont(FONT_TITLE));
-
+
int w = GetWidth() - 8;
// Sizes
m_UserName.SetSize(w*0.4, CConfig::GetFontHeight(FONT_TITLE));
m_UserStatus.SetSize(w*0.25, CConfig::GetFontHeight(FONT_TITLE));
m_UserProto.SetSize(w*0.3, CConfig::GetFontHeight(FONT_TITLE));
-
- int iHeight =GetHeight();
- iHeight -= m_bHideTitle?0:CConfig::GetFontHeight(FONT_TITLE)+2;
- iHeight -= m_bHideLabels?0:5;
-
- m_Input.SetSize(GetWidth()-5, iHeight);
- m_TextLog.SetSize(GetWidth()-5, iHeight);
-
+
+ int iHeight = GetHeight();
+ iHeight -= m_bHideTitle ? 0 : CConfig::GetFontHeight(FONT_TITLE) + 2;
+ iHeight -= m_bHideLabels ? 0 : 5;
+
+ m_Input.SetSize(GetWidth() - 5, iHeight);
+ m_TextLog.SetSize(GetWidth() - 5, iHeight);
+
m_InfoText.SetSize(160, 28);
- m_InfoText.SetOrigin(0,(iHeight-CConfig::GetFontHeight(FONT_SESSION))/2);
+ m_InfoText.SetOrigin(0, (iHeight - CConfig::GetFontHeight(FONT_SESSION)) / 2);
// Origins
-
- m_UserName.SetOrigin(8+w*0.25, 0);
+
+ m_UserName.SetOrigin(8 + w * 0.25, 0);
m_UserStatus.SetOrigin(8, 0);
- m_UserProto.SetOrigin(GetWidth()-w*0.3, 0);
-
- m_TextLog.SetOrigin(0, m_bHideTitle?0:CConfig::GetFontHeight(FONT_TITLE)+2);
- m_Input.SetOrigin(0,m_bHideTitle?0:CConfig::GetFontHeight(FONT_TITLE)+2);
-
+ m_UserProto.SetOrigin(GetWidth() - w * 0.3, 0);
+
+ m_TextLog.SetOrigin(0, m_bHideTitle ? 0 : CConfig::GetFontHeight(FONT_TITLE) + 2);
+ m_Input.SetOrigin(0, m_bHideTitle ? 0 : CConfig::GetFontHeight(FONT_TITLE) + 2);
+
m_InfoText.SetOrigin(0, 10);
-
+
m_UserName.Show(!m_bHideTitle);
m_UserStatus.Show(!m_bHideTitle);
m_UserProto.Show(!m_bHideTitle);
- m_Scrollbar.SetOrigin(GetWidth()-4,(m_bHideTitle?0:CConfig::GetFontHeight(FONT_TITLE)+2));
- m_Scrollbar.SetSize(4,iHeight);
+ m_Scrollbar.SetOrigin(GetWidth() - 4, (m_bHideTitle ? 0 : CConfig::GetFontHeight(FONT_TITLE) + 2));
+ m_Scrollbar.SetSize(4, iHeight);
// other options
m_TextLog.SetLogSize(CConfig::GetIntSetting(SESSION_LOGSIZE));
-
- m_Input.SetBreakKeys(CConfig::GetBoolSetting(SESSION_SENDRETURN)?KEYS_RETURN:KEYS_CTRL_RETURN);
+
+ m_Input.SetBreakKeys(CConfig::GetBoolSetting(SESSION_SENDRETURN) ? KEYS_RETURN : KEYS_CTRL_RETURN);
m_Input.ShowSymbols(CConfig::GetBoolSetting(SESSION_SYMBOLS));
ShowButtons(!m_bHideLabels);
@@ -172,20 +167,19 @@ void CChatScreen::UpdateLabels() tstring strProto = L"";
tstring strStatus = L"";
- if(szProto != nullptr)
- {
+ if (szProto != nullptr) {
strProto = L"(" + toTstring(szProto) + L")";
- m_iStatus = db_get_w(m_hContact,szProto,"Status",ID_STATUS_OFFLINE);
+ m_iStatus = db_get_w(m_hContact, szProto, "Status", ID_STATUS_OFFLINE);
}
-
+
wchar_t *szStatus = Clist_GetStatusModeDescription(m_iStatus, 0);
- if(szStatus != nullptr)
+ if (szStatus != nullptr)
strStatus = toTstring(szStatus);
m_UserName.SetText(strNickname.c_str());
m_UserStatus.SetText(strStatus.c_str());
- if(m_bContactTyping && CConfig::GetBoolSetting(SESSION_SHOWTYPING))
+ if (m_bContactTyping && CConfig::GetBoolSetting(SESSION_SHOWTYPING))
m_UserProto.SetText(CAppletManager::TranslateString(L"typing.."));
else
m_UserProto.SetText(strProto.c_str());
@@ -194,7 +188,7 @@ void CChatScreen::UpdateLabels() // returns wether the input mode is active
bool CChatScreen::IsInputActive()
{
- if(m_eReplyState != REPLY_STATE_NONE)
+ if (m_eReplyState != REPLY_STATE_NONE)
return true;
else
return false;
@@ -213,29 +207,28 @@ MCONTACT CChatScreen::GetContact() //************************************************************************
bool CChatScreen::SetContact(MCONTACT hContact)
{
- if(hContact == NULL)
- {
+ if (hContact == NULL) {
m_hContact = NULL;
return true;
}
-
+
// Check if the contact is valid
char *szProto = GetContactProto(hContact);
m_strProto = toTstring(szProto);
CIRCConnection *pIRCCon = CAppletManager::GetInstance()->GetIRCConnection(m_strProto);
- if(pIRCCon)
+ if (pIRCCon)
m_bIRCProtocol = true;
else
m_bIRCProtocol = false;
-
-
- if(!szProto)
+
+
+ if (!szProto)
return false;
- if(m_eReplyState != REPLY_STATE_NONE)
+ if (m_eReplyState != REPLY_STATE_NONE)
DeactivateMessageMode();
- else if(IsMaximized())
+ else if (IsMaximized())
Minimize();
m_bContactTyping = false;
@@ -253,83 +246,70 @@ bool CChatScreen::SetContact(MCONTACT hContact) //************************************************************************
void CChatScreen::LoadHistory()
{
- if(!m_hContact)
+ if (!m_hContact)
return;
char *szProto = GetContactProto(m_hContact);
-
- if(m_bIRCProtocol && db_get_b(m_hContact, szProto, "ChatRoom", 0) != 0)
- {
- if(!CAppletManager::GetInstance()->IsIRCHookEnabled())
- {
+
+ if (m_bIRCProtocol && db_get_b(m_hContact, szProto, "ChatRoom", 0) != 0) {
+ if (!CAppletManager::GetInstance()->IsIRCHookEnabled()) {
time_t now;
tm tm_now;
time(&now);
- localtime_s(&tm_now,&now);
+ localtime_s(&tm_now, &now);
- AddIncomingMessage(CAppletManager::TranslateString(L"IRC-Chatroom support is disabled!\nYou need to install the patched IRC.dll (see the readme) to use IRC-Chatrooms on the LCD"),&tm_now,true);
+ AddIncomingMessage(CAppletManager::TranslateString(L"IRC-Chatroom support is disabled!\nYou need to install the patched IRC.dll (see the readme) to use IRC-Chatrooms on the LCD"), &tm_now, true);
}
- else
- {
+ else {
CIRCHistory *pHistory = CAppletManager::GetInstance()->GetIRCHistory(m_hContact);
- if(pHistory)
- {
+ if (pHistory) {
list<SIRCMessage>::iterator iter = pHistory->LMessages.begin();
- while(iter != pHistory->LMessages.end())
- {
- if((*iter).bIsMe)
- AddOutgoingMessage((*iter).strMessage,&((*iter).Time),true);
+ while (iter != pHistory->LMessages.end()) {
+ if ((*iter).bIsMe)
+ AddOutgoingMessage((*iter).strMessage, &((*iter).Time), true);
else
- AddIncomingMessage((*iter).strMessage,&((*iter).Time),true);
+ AddIncomingMessage((*iter).strMessage, &((*iter).Time), true);
iter++;
}
}
}
}
- else
- {
+ else {
// Get last events from database
CEvent Event;
list<MEVENT> LHandles;
MEVENT hEvent = db_event_last(m_hContact);
MEVENT hUnread = db_event_firstUnread(m_hContact);
-
- if(CConfig::GetBoolSetting(SESSION_LOADDB))
- {
- while(hEvent != NULL && hUnread != NULL)
- {
+
+ if (CConfig::GetBoolSetting(SESSION_LOADDB)) {
+ while (hEvent != NULL && hUnread != NULL) {
LHandles.push_front(hEvent);
- if(CConfig::GetBoolSetting(SESSION_LOADDB) && *(LHandles.begin()) == hUnread)
+ if (CConfig::GetBoolSetting(SESSION_LOADDB) && *(LHandles.begin()) == hUnread)
break;
hEvent = db_event_prev(m_hContact, hEvent);
}
}
- else
- {
- for (int i = CConfig::GetIntSetting(SESSION_LOGSIZE); i > 0 && hEvent!=NULL; i--)
- {
+ else {
+ for (int i = CConfig::GetIntSetting(SESSION_LOGSIZE); i > 0 && hEvent != NULL; i--) {
LHandles.push_front(hEvent);
hEvent = db_event_prev(m_hContact, hEvent);
}
}
bool bRead = true;
- while(!(LHandles.empty()))
- {
- if(CAppletManager::TranslateDBEvent(&Event,(LPARAM)m_hContact,(WPARAM)*(LHandles.begin())))
- {
- if(Event.hValue == hUnread)
+ while (!(LHandles.empty())) {
+ if (CAppletManager::TranslateDBEvent(&Event, (LPARAM)m_hContact, (WPARAM)*(LHandles.begin()))) {
+ if (Event.hValue == hUnread)
bRead = false;
- if(Event.eType == EVENT_MSG_RECEIVED)
- {
- AddIncomingMessage(Event.strValue,&Event.Time);
- if(!bRead && CConfig::GetBoolSetting(SESSION_MARKREAD) && !CAppletManager::IsMessageWindowOpen(m_hContact))
- CAppletManager::MarkMessageAsRead(m_hContact,Event.hValue);
+ if (Event.eType == EVENT_MSG_RECEIVED) {
+ AddIncomingMessage(Event.strValue, &Event.Time);
+ if (!bRead && CConfig::GetBoolSetting(SESSION_MARKREAD) && !CAppletManager::IsMessageWindowOpen(m_hContact))
+ CAppletManager::MarkMessageAsRead(m_hContact, Event.hValue);
}
else
- AddOutgoingMessage(Event.strValue,&Event.Time);
+ AddOutgoingMessage(Event.strValue, &Event.Time);
- }
+ }
LHandles.pop_front();
}
}
@@ -340,16 +320,16 @@ void CChatScreen::LoadHistory() //************************************************************************
bool CChatScreen::Update()
{
- if(!CScreen::Update())
+ if (!CScreen::Update())
return false;
-
- if(CConfig::GetBoolSetting(SESSION_CLOSE)) {
- if(!CAppletManager::GetInstance()->GetLCDConnection()->IsForeground()) {
- if(!m_bCloseTimer && CConfig::GetIntSetting(SESSION_CLOSETIMER) != 0) {
+
+ if (CConfig::GetBoolSetting(SESSION_CLOSE)) {
+ if (!CAppletManager::GetInstance()->GetLCDConnection()->IsForeground()) {
+ if (!m_bCloseTimer && CConfig::GetIntSetting(SESSION_CLOSETIMER) != 0) {
m_bCloseTimer = true;
m_dwCloseTimer = GetTickCount();
}
- else if(CConfig::GetIntSetting(SESSION_CLOSETIMER) == 0 || GetTickCount() - m_dwCloseTimer >= CConfig::GetIntSetting(SESSION_CLOSETIMER)) {
+ else if (CConfig::GetIntSetting(SESSION_CLOSETIMER) == 0 || GetTickCount() - m_dwCloseTimer >= CConfig::GetIntSetting(SESSION_CLOSETIMER)) {
m_bCloseTimer = false;
CAppletManager::GetInstance()->ActivateEventScreen();
return true;
@@ -357,36 +337,30 @@ bool CChatScreen::Update() }
}
- if(m_bMaximizedTimer && m_dwMaximizedDuration != INFINITE)
- {
- if(m_dwMaximizedTimer + m_dwMaximizedDuration <= GetTickCount())
+ if (m_bMaximizedTimer && m_dwMaximizedDuration != INFINITE) {
+ if (m_dwMaximizedTimer + m_dwMaximizedDuration <= GetTickCount())
Minimize();
}
- if(m_eReplyState == REPLY_STATE_INPUT && !m_Input.IsInputActive())
+ if (m_eReplyState == REPLY_STATE_INPUT && !m_Input.IsInputActive())
SendCurrentMessage();
-
+
// Handle Typing notifications
- if(IsInputActive())
- {
- if(m_Input.GetLastInputTime() + 10000 <= GetTickCount())
- {
- if(m_bTyping)
- {
+ if (IsInputActive()) {
+ if (m_Input.GetLastInputTime() + 10000 <= GetTickCount()) {
+ if (m_bTyping) {
m_bTyping = false;
- CAppletManager::GetInstance()->SendTypingNotification(m_hContact,0);
+ CAppletManager::GetInstance()->SendTypingNotification(m_hContact, 0);
}
}
- else if(CConfig::GetBoolSetting(SESSION_SENDTYPING) && !m_bTyping)
- {
+ else if (CConfig::GetBoolSetting(SESSION_SENDTYPING) && !m_bTyping) {
m_bTyping = true;
- CAppletManager::GetInstance()->SendTypingNotification(m_hContact,1);
+ CAppletManager::GetInstance()->SendTypingNotification(m_hContact, 1);
}
}
- else if(m_bTyping)
- {
+ else if (m_bTyping) {
m_bTyping = false;
- CAppletManager::GetInstance()->SendTypingNotification(m_hContact,0);
+ CAppletManager::GetInstance()->SendTypingNotification(m_hContact, 0);
}
return true;
@@ -397,15 +371,14 @@ bool CChatScreen::Update() //************************************************************************
bool CChatScreen::Draw(CLCDGfx *pGfx)
{
- if(!CScreen::Draw(pGfx))
+ if (!CScreen::Draw(pGfx))
return false;
- if(!m_bHideTitle)
- {
- int iTitleHeight = CConfig::GetFontHeight(FONT_TITLE)+1;
- pGfx->DrawLine(0,iTitleHeight<6?6:iTitleHeight,GetWidth(),iTitleHeight<6?6:iTitleHeight);
- int iOffset = (iTitleHeight-5)/2;
- pGfx->DrawBitmap(1,iOffset,5,5,CAppletManager::GetInstance()->GetStatusBitmap(m_iStatus));
+ if (!m_bHideTitle) {
+ int iTitleHeight = CConfig::GetFontHeight(FONT_TITLE) + 1;
+ pGfx->DrawLine(0, iTitleHeight < 6 ? 6 : iTitleHeight, GetWidth(), iTitleHeight < 6 ? 6 : iTitleHeight);
+ int iOffset = (iTitleHeight - 5) / 2;
+ pGfx->DrawBitmap(1, iOffset, 5, 5, CAppletManager::GetInstance()->GetStatusBitmap(m_iStatus));
}
return true;
@@ -414,34 +387,33 @@ bool CChatScreen::Draw(CLCDGfx *pGfx) //************************************************************************
// Adds an outgoing message to the log
//************************************************************************
-void CChatScreen::AddOutgoingMessage(tstring strMessage,tm *time,bool bIRC)
+void CChatScreen::AddOutgoingMessage(tstring strMessage, tm *time, bool bIRC)
{
- tstring strPrefix = bIRC?L"":L">> ";
- if(CConfig::GetBoolSetting(SESSION_TIMESTAMPS))
+ tstring strPrefix = bIRC ? L"" : L">> ";
+ if (CConfig::GetBoolSetting(SESSION_TIMESTAMPS))
strPrefix += CAppletManager::GetFormattedTimestamp(time) + L" ";
// adjust the scroll mode
m_TextLog.SetAutoscrollMode(SCROLL_LINE);
// add the message
- m_TextLog.AddText(strPrefix + strMessage,true);
+ m_TextLog.AddText(strPrefix + strMessage, true);
}
//************************************************************************
// Adds an incoming message to the log
//************************************************************************
-void CChatScreen::AddIncomingMessage(tstring strMessage,tm *time,bool bIRC)
+void CChatScreen::AddIncomingMessage(tstring strMessage, tm *time, bool bIRC)
{
- tstring strPrefix = bIRC?L"":L"<< ";
- if(CConfig::GetBoolSetting(SESSION_TIMESTAMPS))
+ tstring strPrefix = bIRC ? L"" : L"<< ";
+ if (CConfig::GetBoolSetting(SESSION_TIMESTAMPS))
strPrefix += CAppletManager::GetFormattedTimestamp(time) + L" ";
-
+
// adjust the scroll mode
EScrollMode eMode;
- switch(CConfig::GetIntSetting(SESSION_AUTOSCROLL))
- {
+ switch (CConfig::GetIntSetting(SESSION_AUTOSCROLL)) {
case SESSION_AUTOSCROLL_FIRST: eMode = SCROLL_MESSAGE; break;
case SESSION_AUTOSCROLL_LAST: eMode = SCROLL_LINE; break;
default: eMode = SCROLL_NONE;
@@ -462,7 +434,7 @@ void CChatScreen::ActivateMessageMode() m_TextLog.SetScrollbar(nullptr);
m_Input.SetScrollbar(&m_Scrollbar);
- if(m_eReplyState != REPLY_STATE_FAILED)
+ if (m_eReplyState != REPLY_STATE_FAILED)
m_Input.Reset();
m_Input.Show(1);
@@ -470,10 +442,10 @@ void CChatScreen::ActivateMessageMode() m_eReplyState = REPLY_STATE_INPUT;
- SetButtonBitmap(2,IDB_BACK);
- SetButtonBitmap(3,IDB_SEND);
+ SetButtonBitmap(2, IDB_BACK);
+ SetButtonBitmap(3, IDB_SEND);
- if(CConfig::GetBoolSetting(SESSION_REPLY_MAXIMIZED))
+ if (CConfig::GetBoolSetting(SESSION_REPLY_MAXIMIZED))
Maximize();
else
Minimize();
@@ -484,8 +456,7 @@ void CChatScreen::ActivateMessageMode() //************************************************************************
void CChatScreen::SendCurrentMessage()
{
- if(m_Input.GetText().empty())
- {
+ if (m_Input.GetText().empty()) {
DeactivateMessageMode();
return;
}
@@ -498,15 +469,14 @@ void CChatScreen::SendCurrentMessage() m_InfoText.SetText(CAppletManager::TranslateString(L"Sending message..."));
m_InfoText.Show(1);
m_Input.Show(0);
-
- m_hMessage = CAppletManager::SendMessageToContact(m_hContact,m_Input.GetText());
- if(m_hMessage == NULL)
- {
+
+ m_hMessage = CAppletManager::SendMessageToContact(m_hContact, m_Input.GetText());
+ if (m_hMessage == NULL) {
DeactivateMessageMode();
return;
}
- SetButtonBitmap(2,NULL);
- SetButtonBitmap(3,NULL);
+ SetButtonBitmap(2, NULL);
+ SetButtonBitmap(3, NULL);
}
//************************************************************************
@@ -518,10 +488,10 @@ void CChatScreen::InvalidateMessageMode(tstring strError) m_InfoText.SetText(strError);
- SetButtonBitmap(2,IDB_BACK);
- SetButtonBitmap(3,IDB_SEND);
+ SetButtonBitmap(2, IDB_BACK);
+ SetButtonBitmap(3, IDB_SEND);
- if(IsMaximized())
+ if (IsMaximized())
Minimize();
}
@@ -538,15 +508,15 @@ void CChatScreen::DeactivateMessageMode() m_TextLog.Show(1);
m_InfoText.Show(0);
m_Input.Show(0);
-
+
m_Input.DeactivateInput();
m_eReplyState = REPLY_STATE_NONE;
-
- SetButtonBitmap(2,IDB_HISTORY);
- SetButtonBitmap(3,IDB_REPLY);
- if(IsMaximized())
+ SetButtonBitmap(2, IDB_HISTORY);
+ SetButtonBitmap(3, IDB_REPLY);
+
+ if (IsMaximized())
Minimize();
}
@@ -607,47 +577,45 @@ void CChatScreen::OnConfigChanged() void CChatScreen::OnEventReceived(CEvent *pEvent)
{
// only let events for this contact pass
- if(pEvent->hContact != m_hContact &&
+ if (pEvent->hContact != m_hContact &&
// expect for IRC events without a contact -> global notifications
!((pEvent->eType == EVENT_IRC_SENT || pEvent->eType == EVENT_IRC_RECEIVED) && pEvent->hContact == NULL))
return;
-
- switch(pEvent->eType)
- {
+
+ switch (pEvent->eType) {
case EVENT_MESSAGE_ACK:
- if(pEvent->hValue != m_hMessage)
+ if (pEvent->hValue != m_hMessage)
return;
- if(pEvent->iValue == ACKRESULT_SUCCESS)
+ if (pEvent->iValue == ACKRESULT_SUCCESS)
DeactivateMessageMode();
else
- InvalidateMessageMode(pEvent->strValue.empty()?CAppletManager::TranslateString(L"Could not send the message!"):pEvent->strValue);
+ InvalidateMessageMode(pEvent->strValue.empty() ? CAppletManager::TranslateString(L"Could not send the message!") : pEvent->strValue);
break;
case EVENT_IRC_SENT:
// Add the message to the log
- AddOutgoingMessage(pEvent->strValue,&pEvent->Time,true);
+ AddOutgoingMessage(pEvent->strValue, &pEvent->Time, true);
break;
case EVENT_IRC_RECEIVED:
// Add the message to the log
- AddIncomingMessage(pEvent->strValue,&pEvent->Time,true);
+ AddIncomingMessage(pEvent->strValue, &pEvent->Time, true);
break;
case EVENT_MSG_RECEIVED:
// mark it as read if required
- if(CConfig::GetBoolSetting(SESSION_MARKREAD) && !CAppletManager::IsMessageWindowOpen(m_hContact))
- CAppletManager::MarkMessageAsRead(m_hContact,pEvent->hValue);
+ if (CConfig::GetBoolSetting(SESSION_MARKREAD) && !CAppletManager::IsMessageWindowOpen(m_hContact))
+ CAppletManager::MarkMessageAsRead(m_hContact, pEvent->hValue);
// Add the message to the log
- AddIncomingMessage(pEvent->strValue,&pEvent->Time);
+ AddIncomingMessage(pEvent->strValue, &pEvent->Time);
break;
case EVENT_MSG_SENT:
// Add the message to the log
- AddOutgoingMessage(pEvent->strValue,&pEvent->Time);
+ AddOutgoingMessage(pEvent->strValue, &pEvent->Time);
break;
case EVENT_CONTACT_HIDDEN:
// contact is set to hidden
- if(pEvent->iValue == 1)
- {
+ if (pEvent->iValue == 1) {
// Close the chat screen if the contact is an irc chatroom
- if(!(m_bIRCProtocol && db_get_b(pEvent->hContact, toNarrowString(m_strProto).c_str(), "ChatRoom", 0) != 0))
+ if (!(m_bIRCProtocol && db_get_b(pEvent->hContact, toNarrowString(m_strProto).c_str(), "ChatRoom", 0) != 0))
break;
}
else
@@ -673,59 +641,60 @@ void CChatScreen::OnEventReceived(CEvent *pEvent) //************************************************************************
void CChatScreen::OnLCDButtonDown(int iButton)
{
- switch(m_eReplyState)
- {
+ switch (m_eReplyState) {
case REPLY_STATE_NONE:
- if(iButton == LGLCDBUTTON_CANCEL) {
+ if (iButton == LGLCDBUTTON_CANCEL) {
CAppletManager::GetInstance()->ActivatePreviousScreen();
- } else if(iButton == LGLCDBUTTON_BUTTON2 || iButton == LGLCDBUTTON_MENU)
+ }
+ else if (iButton == LGLCDBUTTON_BUTTON2 || iButton == LGLCDBUTTON_MENU)
CAppletManager::GetInstance()->ActivateEventScreen();
// enter reply mode
- else if(iButton == LGLCDBUTTON_BUTTON3 || iButton == LGLCDBUTTON_OK)
+ else if (iButton == LGLCDBUTTON_BUTTON3 || iButton == LGLCDBUTTON_OK)
ActivateMessageMode();
else {
bool bRes = false;
- if(iButton == LGLCDBUTTON_BUTTON0 || iButton == LGLCDBUTTON_UP) {
+ if (iButton == LGLCDBUTTON_BUTTON0 || iButton == LGLCDBUTTON_UP) {
bRes = m_TextLog.ScrollUp();
- } else if(iButton == LGLCDBUTTON_BUTTON1 || iButton == LGLCDBUTTON_DOWN) {
+ }
+ else if (iButton == LGLCDBUTTON_BUTTON1 || iButton == LGLCDBUTTON_DOWN) {
bRes = m_TextLog.ScrollDown();
}
- if(bRes && CConfig::GetBoolSetting(SESSION_SCROLL_MAXIMIZED)) {
+ if (bRes && CConfig::GetBoolSetting(SESSION_SCROLL_MAXIMIZED)) {
Maximize(5000);
}
}
break;
+
case REPLY_STATE_FAILED:
- if(iButton == LGLCDBUTTON_BUTTON2 || iButton == LGLCDBUTTON_CANCEL) {
+ if (iButton == LGLCDBUTTON_BUTTON2 || iButton == LGLCDBUTTON_CANCEL) {
DeactivateMessageMode();
- } else if(iButton == LGLCDBUTTON_BUTTON3 || iButton == LGLCDBUTTON_OK) {
- ActivateMessageMode();
}
-/*
- // Dead code
- else if(iButton == LGLCDBUTTON_CANCEL) {
- DeactivateMessageMode();
- CAppletManager::GetInstance()->ActivatePreviousScreen();
+ else if (iButton == LGLCDBUTTON_BUTTON3 || iButton == LGLCDBUTTON_OK) {
+ ActivateMessageMode();
}
-*/
- else if(iButton == LGLCDBUTTON_MENU) {
+ else if (iButton == LGLCDBUTTON_MENU) {
DeactivateMessageMode();
CAppletManager::GetInstance()->ActivateEventScreen();
}
break;
+
case REPLY_STATE_SENDING:
break;
+
case REPLY_STATE_INPUT:
- if(iButton == LGLCDBUTTON_BUTTON0 || iButton == LGLCDBUTTON_UP) {
+ if (iButton == LGLCDBUTTON_BUTTON0 || iButton == LGLCDBUTTON_UP) {
m_Input.ScrollLine(0);
- } else if(iButton == LGLCDBUTTON_BUTTON1 || iButton == LGLCDBUTTON_DOWN) {
+ }
+ else if (iButton == LGLCDBUTTON_BUTTON1 || iButton == LGLCDBUTTON_DOWN) {
m_Input.ScrollLine(1);
- // send the message
- } else if(iButton == LGLCDBUTTON_BUTTON3 || iButton == LGLCDBUTTON_OK) {
+ // send the message
+ }
+ else if (iButton == LGLCDBUTTON_BUTTON3 || iButton == LGLCDBUTTON_OK) {
SendCurrentMessage();
- // cancel message mode
- } else if(iButton == LGLCDBUTTON_BUTTON2 || iButton == LGLCDBUTTON_CANCEL) {
+ // cancel message mode
+ }
+ else if (iButton == LGLCDBUTTON_BUTTON2 || iButton == LGLCDBUTTON_CANCEL) {
DeactivateMessageMode();
}
break;
@@ -737,24 +706,23 @@ void CChatScreen::OnLCDButtonDown(int iButton) //************************************************************************
void CChatScreen::OnLCDButtonRepeated(int iButton)
{
- switch(m_eReplyState)
- {
+ switch (m_eReplyState) {
case REPLY_STATE_NONE:
- if(iButton < 2)
- {
+ if (iButton < 2) {
bool bRes = false;
- if(iButton == LGLCDBUTTON_BUTTON0) {
+ if (iButton == LGLCDBUTTON_BUTTON0) {
bRes = m_TextLog.ScrollUp();
}
- if(bRes && CConfig::GetBoolSetting(SESSION_SCROLL_MAXIMIZED))
+ if (bRes && CConfig::GetBoolSetting(SESSION_SCROLL_MAXIMIZED))
Maximize(5000);
}
break;
case REPLY_STATE_INPUT:
- if(iButton == LGLCDBUTTON_BUTTON0 || iButton == LGLCDBUTTON_UP) {
+ if (iButton == LGLCDBUTTON_BUTTON0 || iButton == LGLCDBUTTON_UP) {
m_Input.ScrollLine(0);
- } else if(iButton == LGLCDBUTTON_BUTTON1 || iButton == LGLCDBUTTON_DOWN) {
+ }
+ else if (iButton == LGLCDBUTTON_BUTTON1 || iButton == LGLCDBUTTON_DOWN) {
m_Input.ScrollLine(1);
}
}
@@ -765,7 +733,6 @@ void CChatScreen::OnLCDButtonRepeated(int iButton) //************************************************************************
void CChatScreen::OnLCDButtonUp(int)
{
-
}
//************************************************************************
@@ -781,11 +748,11 @@ void CChatScreen::OnActivation() //************************************************************************
void CChatScreen::OnDeactivation()
{
-}
+}
//************************************************************************
// Called when the screen has expired
//************************************************************************
void CChatScreen::OnExpiration()
{
-}
\ No newline at end of file +}
diff --git a/plugins/MirandaG15/src/CChatScreen.h b/plugins/MirandaG15/src/CChatScreen.h index 371cbaf4fd..d888c62a92 100644 --- a/plugins/MirandaG15/src/CChatScreen.h +++ b/plugins/MirandaG15/src/CChatScreen.h @@ -47,7 +47,7 @@ public: bool SetContact(MCONTACT hContact);
// returns the chat contact
MCONTACT GetContact();
-
+
// returns wether the input mode is active
bool IsInputActive();
protected:
@@ -55,12 +55,12 @@ protected: void LoadHistory();
// Adds an outgoing message to the log
- void AddOutgoingMessage(tstring strMessage,tm *time,bool bIRC = false);
+ void AddOutgoingMessage(tstring strMessage, tm *time, bool bIRC = false);
// Adds an incoming message to the log
- void AddIncomingMessage(tstring strMessage,tm *time,bool bIRC = false);
+ void AddIncomingMessage(tstring strMessage, tm *time, bool bIRC = false);
// maximizes the content object
- void Maximize(DWORD dwTimer=INFINITE);
+ void Maximize(DWORD dwTimer = INFINITE);
// minimizes the content object
void Minimize();
// returns wether the content is maximized
@@ -80,22 +80,22 @@ protected: // update's the screens title labels
void UpdateLabels();
- bool m_bHideLabels,m_bHideTitle;
- bool m_bMaximizedTimer;
-
- bool m_bContactTyping;
- bool m_bTyping;
+ bool m_bHideLabels = false, m_bHideTitle = false;
+ bool m_bMaximizedTimer = false;
+
+ bool m_bContactTyping = false;
+ bool m_bTyping = false;
- enum { REPLY_STATE_NONE,REPLY_STATE_INPUT,REPLY_STATE_SENDING,REPLY_STATE_FAILED} m_eReplyState;
- DWORD m_dwCloseTimer;
- bool m_bCloseTimer;
- DWORD m_dwMaximizedTimer;
- DWORD m_dwMaximizedDuration;
+ enum { REPLY_STATE_NONE, REPLY_STATE_INPUT, REPLY_STATE_SENDING, REPLY_STATE_FAILED } m_eReplyState = REPLY_STATE_NONE;
+ DWORD m_dwCloseTimer = 0;
+ bool m_bCloseTimer = false;
+ DWORD m_dwMaximizedTimer = 0;
+ DWORD m_dwMaximizedDuration = 0;
- MCONTACT m_hContact;
- MEVENT m_hMessage;
+ MCONTACT m_hContact = 0;
+ MEVENT m_hMessage = 0;
- int m_iStatus;
+ int m_iStatus = ID_STATUS_OFFLINE;
CLCDLabel m_UserProto;
CLCDLabel m_UserName;
@@ -107,7 +107,7 @@ protected: CLCDBar m_Scrollbar;
tstring m_strProto;
- bool m_bIRCProtocol;
+ bool m_bIRCProtocol = false;
};
-#endif
\ No newline at end of file +#endif
diff --git a/plugins/MirandaG15/src/CConfig.cpp b/plugins/MirandaG15/src/CConfig.cpp index 3c630eb4e9..d38fce1acb 100644 --- a/plugins/MirandaG15/src/CConfig.cpp +++ b/plugins/MirandaG15/src/CConfig.cpp @@ -281,7 +281,7 @@ void CConfig::SaveFontSettings(int iFont) // Height
mir_snprintf(szSetting, "Font%dHeight", iFont);
db_set_b(0, "MirandaG15", szSetting, m_logfont[iFont].lfHeight);
-
+
// Style
int style = 0;
if (m_logfont[iFont].lfWeight == FW_BOLD)
@@ -290,11 +290,11 @@ void CConfig::SaveFontSettings(int iFont) style |= FONTF_ITALIC;
mir_snprintf(szSetting, "Font%dStyle", iFont);
db_set_b(0, "MirandaG15", szSetting, style);
-
+
// Charset
mir_snprintf(szSetting, "Font%dCharset", iFont);
db_set_b(0, "MirandaG15", szSetting, m_logfont[iFont].lfCharSet);
-
+
// Name
mir_snprintf(szSetting, "Font%dName", iFont);
db_set_ws(0, "MirandaG15", szSetting, m_logfont[iFont].lfFaceName);
@@ -434,7 +434,7 @@ INT_PTR CALLBACK CConfig::AppearanceDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wPar };
if (iFont >= 0) {
- CHOOSEFONT cf = { 0 };
+ CHOOSEFONT cf = {0};
cf.lStructSize = sizeof(cf);
cf.hwndOwner = hwndDlg;
cf.lpLogFont = &m_templogfont[iFont];
diff --git a/plugins/MirandaG15/src/CContactList.cpp b/plugins/MirandaG15/src/CContactList.cpp index 5b48ed6975..f62ed747c2 100644 --- a/plugins/MirandaG15/src/CContactList.cpp +++ b/plugins/MirandaG15/src/CContactList.cpp @@ -3,32 +3,33 @@ #include "CConfig.h"
#include "CAppletManager.h"
-const int aiStatusPriority[] = { 0, // ID_STATUS_OFFLINE 40071
- 9, // ID_STATUS_ONLINE 40072
- 8, // ID_STATUS_AWAY 40073
- 1, // ID_STATUS_DND 40074
- 7, // ID_STATUS_NA 40075
- 6, // ID_STATUS_OCCUPIED 40076
- 10, // ID_STATUS_FREECHAT 40077
- 9, // ID_STATUS_INVISIBLE 40078
- 8, // ID_STATUS_ONTHEPHONE 40079
- 8 // ID_STATUS_OUTTOLUNCH 40080
+const int aiStatusPriority[] =
+{
+ 0, // ID_STATUS_OFFLINE 40071
+ 9, // ID_STATUS_ONLINE 40072
+ 8, // ID_STATUS_AWAY 40073
+ 1, // ID_STATUS_DND 40074
+ 7, // ID_STATUS_NA 40075
+ 6, // ID_STATUS_OCCUPIED 40076
+ 10, // ID_STATUS_FREECHAT 40077
+ 9, // ID_STATUS_INVISIBLE 40078
+ 8, // ID_STATUS_ONTHEPHONE 40079
+ 8 // ID_STATUS_OUTTOLUNCH 40080
};
//************************************************************************
// constructor
//************************************************************************
-CContactList::CContactList()
- : m_bUseGroups(false),
- m_bUseMetaContacts(false),
- m_dwLastScroll(0)
-{}
+CContactList::CContactList()
+{
+}
//************************************************************************
// destructor
//************************************************************************
CContactList::~CContactList()
-{}
+{
+}
//************************************************************************
// initializes the list
@@ -39,9 +40,7 @@ bool CContactList::Initialize() return false;
InitializeGroupObjects();
-
RefreshList();
-
return true;
}
@@ -54,12 +53,9 @@ bool CContactList::Shutdown() return false;
UninitializeGroupObjects();
-
return false;
}
-
-
//************************************************************************
// returns the contacts ccontactlistentry class
//************************************************************************
@@ -71,8 +67,6 @@ CContactListEntry *CContactList::GetContactData(CListEntry<CContactListEntry*, C return ((CListContainer<CContactListEntry*, CContactListGroup*>*)pEntry)->GetGroupData()->pContactListEntry;
}
-
-
//************************************************************************
// returns the contacts group path
//************************************************************************
@@ -87,8 +81,8 @@ tstring CContactList::GetContactGroupPath(MCONTACT hContact) tstring strMetaName = CAppletManager::GetContactDisplayname(hMetaContact);
strGroup += (strGroup.empty() ? L"" : L"\\") + strMetaName;
}
- else
- strGroup = CAppletManager::GetContactGroup(hContact);
+ else strGroup = CAppletManager::GetContactGroup(hContact);
+
return strGroup;
}
@@ -115,7 +109,6 @@ void CContactList::AddContact(MCONTACT hContact) psContact->strName = strName;
psContact->iMessages = 0;
psContact->hHandle = hContact;
-
psContact->iStatus = iStatus;
if (szStatus != nullptr)
@@ -188,14 +181,12 @@ void CContactList::AddContact(MCONTACT hContact) //************************************************************************
bool CContactList::IsVisible(CContactListEntry *pEntry)
{
- if (!pEntry) {
+ if (!pEntry)
return false;
- }
if (pEntry->strProto != L"MetaContacts") {
- if (pEntry->iStatus == ID_STATUS_OFFLINE && CConfig::GetBoolSetting(CLIST_HIDEOFFLINE)) {
+ if (pEntry->iStatus == ID_STATUS_OFFLINE && CConfig::GetBoolSetting(CLIST_HIDEOFFLINE))
return false;
- }
}
else {
if (pEntry->iStatus == ID_STATUS_OFFLINE) {
@@ -240,8 +231,6 @@ void CContactList::RemoveContact(MCONTACT hContact) {
CListContainer<CContactListEntry*, CContactListGroup*> *pGroup = nullptr;
- ///tstring strGroup = GetContactGroupPath(hContact);
-
CListEntry<CContactListEntry*, CContactListGroup*> *pContactEntry = FindContact(hContact);
if (!pContactEntry)
return;
@@ -409,7 +398,7 @@ void CContactList::DrawEntry(CLCDGfx *pGfx, CContactListEntry *pEntry, bool bSel pGfx->DrawBitmap(1, ceil((pGfx->GetClipHeight() - 5) / 2.0f), 5, 5, CAppletManager::GetInstance()->GetStatusBitmap(pEntry->iStatus));
if (bSelected && (GetTickCount() - m_dwLastScroll < 1000 || !CConfig::GetBoolSetting(CLIST_SELECTION))) {
- RECT invert = { 0,0,GetWidth(),m_iFontHeight };
+ RECT invert = {0,0,GetWidth(),m_iFontHeight};
InvertRect(pGfx->GetHDC(), &invert);
}
}
@@ -452,7 +441,7 @@ void CContactList::DrawGroup(CLCDGfx *pGfx, CContactListGroup *pGroup, bool bOpe pGfx->DrawText(1, 0, L"+");
if (bSelected && (GetTickCount() - m_dwLastScroll < 1000 || !CConfig::GetBoolSetting(CLIST_SELECTION))) {
- RECT invert2 = { 0,0,GetWidth(),m_iFontHeight };
+ RECT invert2 = {0,0,GetWidth(),m_iFontHeight};
InvertRect(pGfx->GetHDC(), &invert2);
}
}
diff --git a/plugins/MirandaG15/src/CContactList.h b/plugins/MirandaG15/src/CContactList.h index ed556ce872..ba60174b2c 100644 --- a/plugins/MirandaG15/src/CContactList.h +++ b/plugins/MirandaG15/src/CContactList.h @@ -29,19 +29,19 @@ public: CContactListEntry *pContactListEntry;
};
-class CContactList : public CLCDList<CContactListEntry*,CContactListGroup*>
+class CContactList : public CLCDList<CContactListEntry*, CContactListGroup*>
{
public:
// constructor
CContactList();
// destructor
~CContactList();
-
+
// initializes the list
bool Initialize();
// deinitializes the list
bool Shutdown();
-
+
// called when a contact has been added
void OnContactAdded(MCONTACT hContact);
// called when a contact has been deleted
@@ -49,28 +49,28 @@ public: // called when the configuration has changed
void OnConfigChanged();
// called when a contacts group has changed
- void OnContactGroupChanged(MCONTACT hContact,tstring strGroup);
+ void OnContactGroupChanged(MCONTACT hContact, tstring strGroup);
// called when a contacts hidden flag has changed
- void OnContactHiddenChanged(MCONTACT hContact, bool bVisibility);
+ void OnContactHiddenChanged(MCONTACT hContact, bool bVisibility);
// called when a contacts nickname has changed
void OnContactNickChanged(MCONTACT hContact, tstring strNick);
// called when a contacts status has changed
- void OnStatusChange(MCONTACT hContact,int iStatus);
+ void OnStatusChange(MCONTACT hContact, int iStatus);
// called when the contacts message count has changed
void OnMessageCountChanged(MCONTACT hContact);
// returns the contact's status
int GetContactStatus(MCONTACT hContact);
// Called to compare two entrys
- static bool CompareEntries(CListEntry<CContactListEntry*,CContactListGroup*> *pLeft,CListEntry<CContactListEntry*,CContactListGroup*> *pRight);
+ static bool CompareEntries(CListEntry<CContactListEntry*, CContactListGroup*> *pLeft, CListEntry<CContactListEntry*, CContactListGroup*> *pRight);
- void SetPosition(CListEntry<CContactListEntry*,CContactListGroup*> *pEntry);
+ void SetPosition(CListEntry<CContactListEntry*, CContactListGroup*> *pEntry);
bool ScrollUp();
bool ScrollDown();
void ShowSelection();
bool SetFont(LOGFONT &lf);
-protected:
+protected:
// returns the contacts group path
tstring GetContactGroupPath(MCONTACT hContact);
@@ -78,7 +78,7 @@ protected: void AddContact(MCONTACT hContact);
// removes a contact from the list
void RemoveContact(MCONTACT hContact);
-
+
// uninitializes the group objects
void UninitializeGroupObjects();
@@ -92,52 +92,52 @@ protected: void DeleteGroupObjectByPath(tstring strPath);
// changes the groups membercount
- void ChangeGroupObjectCounters(tstring strGroup,int iMembers,int iOnline=0,int iEvents=0);
+ void ChangeGroupObjectCounters(tstring strGroup, int iMembers, int iOnline = 0, int iEvents = 0);
// returns wether a contact should be listed or not
bool IsVisible(CContactListEntry *pEntry);
// sorts all entries of a group
- void SortGroup(CListContainer<CContactListEntry*,CContactListGroup*> *pGroup);
+ void SortGroup(CListContainer<CContactListEntry*, CContactListGroup*> *pGroup);
// tries to find a contact in the specified group
- CListEntry<CContactListEntry*,CContactListGroup*> *FindContactInGroup(MCONTACT hContact,CListContainer<CContactListEntry*,CContactListGroup*> *pGroup);
-
+ CListEntry<CContactListEntry*, CContactListGroup*> *FindContactInGroup(MCONTACT hContact, CListContainer<CContactListEntry*, CContactListGroup*> *pGroup);
+
// tries to find a group in the specified group
- CListContainer<CContactListEntry*,CContactListGroup*> *FindGroupInGroup(tstring strGroup,CListContainer<CContactListEntry*,CContactListGroup*> *pGroup);
+ CListContainer<CContactListEntry*, CContactListGroup*> *FindGroupInGroup(tstring strGroup, CListContainer<CContactListEntry*, CContactListGroup*> *pGroup);
// Adds a group
- CListContainer<CContactListEntry*,CContactListGroup*> *AddGroupByString(tstring strGroup);
+ CListContainer<CContactListEntry*, CContactListGroup*> *AddGroupByString(tstring strGroup);
// get group by string
- CListContainer<CContactListEntry*,CContactListGroup*> *GetGroupByString(tstring strGroup);
+ CListContainer<CContactListEntry*, CContactListGroup*> *GetGroupByString(tstring strGroup);
// updates the message counter for the specified entry
- void UpdateMessageCounter(CListEntry<CContactListEntry*,CContactListGroup*> *pContactEntry);
+ void UpdateMessageCounter(CListEntry<CContactListEntry*, CContactListGroup*> *pContactEntry);
// refreshes the list
void RefreshList();
// returns the entry for the specified handle
- CListEntry<CContactListEntry*,CContactListGroup*> *FindContact(MCONTACT hContact);
-
+ CListEntry<CContactListEntry*, CContactListGroup*> *FindContact(MCONTACT hContact);
+
// returns the entry for the specified group name
- CListContainer<CContactListEntry*,CContactListGroup*> *FindGroup(tstring strGroup);
+ CListContainer<CContactListEntry*, CContactListGroup*> *FindGroup(tstring strGroup);
// returns the contacts ccontactlistentry class
- static CContactListEntry *GetContactData(CListEntry<CContactListEntry*,CContactListGroup*> *pEntry);
+ static CContactListEntry *GetContactData(CListEntry<CContactListEntry*, CContactListGroup*> *pEntry);
// Called to delete the specified item
void DeleteItem(CContactListEntry *pEntry);
// Called to delete the specified group
void DeleteGroup(CContactListGroup* pGroup);
// Called to draw the specified group
- void DrawGroup(CLCDGfx *pGfx,CContactListGroup* pGroup,bool bOpen,bool bSelected);
+ void DrawGroup(CLCDGfx *pGfx, CContactListGroup* pGroup, bool bOpen, bool bSelected);
// Called to draw the specified entry
- void DrawEntry(CLCDGfx *pGfx,CContactListEntry *pEntry,bool bSelected);
-
- bool m_bUseGroups;
- bool m_bUseMetaContacts;
+ void DrawEntry(CLCDGfx *pGfx, CContactListEntry *pEntry, bool bSelected);
+
+ bool m_bUseGroups = false;
+ bool m_bUseMetaContacts = false;
vector<CContactListGroup*> m_Groups;
- DWORD m_dwLastScroll;
+ DWORD m_dwLastScroll = 0;
HBITMAP m_ahBitmaps[8];
};
diff --git a/plugins/MirandaG15/src/CContactlistScreen.cpp b/plugins/MirandaG15/src/CContactlistScreen.cpp index 5aa16328ac..672ef088aa 100644 --- a/plugins/MirandaG15/src/CContactlistScreen.cpp +++ b/plugins/MirandaG15/src/CContactlistScreen.cpp @@ -22,29 +22,29 @@ CContactlistScreen::~CContactlistScreen() //************************************************************************
bool CContactlistScreen::Initialize()
{
- if(!CScreen::Initialize())
+ if (!CScreen::Initialize())
return false;
m_ContactList.Initialize();
m_ContactList.SetOrigin(0, 0);
- m_ContactList.SetSize(GetWidth()-5, GetHeight()-(CConfig::GetBoolSetting(SHOW_LABELS)?6:0));
+ m_ContactList.SetSize(GetWidth() - 5, GetHeight() - (CConfig::GetBoolSetting(SHOW_LABELS) ? 6 : 0));
m_ContactList.SetFont(CConfig::GetFont(FONT_CLIST));
m_ContactList.SetDrawTreeLines(CConfig::GetBoolSetting(CLIST_DRAWLINES));
- m_ContactList.SetColumns(CConfig::GetBoolSetting(CLIST_COLUMNS)?2:1);
+ m_ContactList.SetColumns(CConfig::GetBoolSetting(CLIST_COLUMNS) ? 2 : 1);
AddObject(&m_ContactList);
m_Scrollbar.Initialize();
- m_Scrollbar.SetOrigin(GetWidth()-4,0);
- m_Scrollbar.SetSize(4,GetHeight()-(CConfig::GetBoolSetting(SHOW_LABELS)?5:0));
+ m_Scrollbar.SetOrigin(GetWidth() - 4, 0);
+ m_Scrollbar.SetSize(4, GetHeight() - (CConfig::GetBoolSetting(SHOW_LABELS) ? 5 : 0));
m_ContactList.SetScrollbar(&m_Scrollbar);
AddObject(&m_Scrollbar);
- SetButtonBitmap(0,IDB_UP);
- SetButtonBitmap(1,IDB_DOWN);
- SetButtonBitmap(2,IDB_HISTORY);
- SetButtonBitmap(3,IDB_CHAT);
+ SetButtonBitmap(0, IDB_UP);
+ SetButtonBitmap(1, IDB_DOWN);
+ SetButtonBitmap(2, IDB_HISTORY);
+ SetButtonBitmap(3, IDB_CHAT);
return true;
}
@@ -54,7 +54,7 @@ bool CContactlistScreen::Initialize() //************************************************************************
bool CContactlistScreen::Shutdown()
{
- if(!CScreen::Shutdown())
+ if (!CScreen::Shutdown())
return false;
return true;
@@ -65,7 +65,7 @@ bool CContactlistScreen::Shutdown() //************************************************************************
bool CContactlistScreen::Update()
{
- if(!CScreen::Update())
+ if (!CScreen::Update())
return false;
return true;
@@ -76,7 +76,7 @@ bool CContactlistScreen::Update() //************************************************************************
bool CContactlistScreen::Draw(CLCDGfx *pGfx)
{
- if(!CScreen::Draw(pGfx))
+ if (!CScreen::Draw(pGfx))
return false;
return true;
@@ -96,8 +96,7 @@ int CContactlistScreen::GetContactStatus(MCONTACT hContact) void CContactlistScreen::ResetPosition()
{
// collapse all groups if setting is active
- switch(CConfig::GetIntSetting(CLIST_GA))
- {
+ switch (CConfig::GetIntSetting(CLIST_GA)) {
case CLIST_GA_COLLAPSE:
m_ContactList.CollapseAll();
break;
@@ -105,9 +104,9 @@ void CContactlistScreen::ResetPosition() m_ContactList.ExpandAll();
break;
}
-
+
// select the first item if setting is active
- if(CConfig::GetBoolSetting(CLIST_POSITION))
+ if (CConfig::GetBoolSetting(CLIST_POSITION))
m_ContactList.SetPosition(m_ContactList.GetFirstEntry());
UpdateUseSoftkeyLabel();
@@ -121,10 +120,10 @@ void CContactlistScreen::OnSizeChanged() CScreen::OnSizeChanged();
m_ContactList.OnConfigChanged();
- m_ContactList.SetSize(GetWidth()-5, GetHeight()-(CConfig::GetBoolSetting(SHOW_LABELS)?6:0));
-
- m_Scrollbar.SetOrigin(GetWidth()-4,0);
- m_Scrollbar.SetSize(4,GetHeight()-(CConfig::GetBoolSetting(SHOW_LABELS)?5:0));
+ m_ContactList.SetSize(GetWidth() - 5, GetHeight() - (CConfig::GetBoolSetting(SHOW_LABELS) ? 6 : 0));
+
+ m_Scrollbar.SetOrigin(GetWidth() - 4, 0);
+ m_Scrollbar.SetSize(4, GetHeight() - (CConfig::GetBoolSetting(SHOW_LABELS) ? 5 : 0));
}
//************************************************************************
@@ -136,12 +135,12 @@ void CContactlistScreen::OnConfigChanged() m_ContactList.OnConfigChanged();
m_ContactList.SetDrawTreeLines(CConfig::GetBoolSetting(CLIST_DRAWLINES));
- m_ContactList.SetSize(GetWidth()-5, GetHeight()-(CConfig::GetBoolSetting(SHOW_LABELS)?6:0));
+ m_ContactList.SetSize(GetWidth() - 5, GetHeight() - (CConfig::GetBoolSetting(SHOW_LABELS) ? 6 : 0));
m_ContactList.SetFont(CConfig::GetFont(FONT_CLIST));
- m_ContactList.SetColumns(CConfig::GetBoolSetting(CLIST_COLUMNS)?2:1);
-
- m_Scrollbar.SetOrigin(GetWidth()-4,0);
- m_Scrollbar.SetSize(4,GetHeight()-(CConfig::GetBoolSetting(SHOW_LABELS)?5:0));
+ m_ContactList.SetColumns(CConfig::GetBoolSetting(CLIST_COLUMNS) ? 2 : 1);
+
+ m_Scrollbar.SetOrigin(GetWidth() - 4, 0);
+ m_Scrollbar.SetSize(4, GetHeight() - (CConfig::GetBoolSetting(SHOW_LABELS) ? 5 : 0));
}
//************************************************************************
@@ -149,14 +148,14 @@ void CContactlistScreen::OnConfigChanged() //************************************************************************
void CContactlistScreen::OnEventReceived(CEvent *pEvent)
{
- switch(pEvent->eType) {
+ switch (pEvent->eType) {
case EVENT_SIGNED_ON:
case EVENT_SIGNED_OFF:
case EVENT_STATUS:
- m_ContactList.OnStatusChange(pEvent->hContact,pEvent->iValue);
+ m_ContactList.OnStatusChange(pEvent->hContact, pEvent->iValue);
break;
case EVENT_CONTACT_NICK:
- m_ContactList.OnContactNickChanged(pEvent->hContact,pEvent->strValue);
+ m_ContactList.OnContactNickChanged(pEvent->hContact, pEvent->strValue);
break;
case EVENT_CONTACT_ADDED:
m_ContactList.OnContactAdded(pEvent->hContact);
@@ -169,10 +168,10 @@ void CContactlistScreen::OnEventReceived(CEvent *pEvent) m_ContactList.OnMessageCountChanged(pEvent->hContact);
break;
case EVENT_CONTACT_HIDDEN:
- m_ContactList.OnContactHiddenChanged(pEvent->hContact,pEvent->iValue != 0);
+ m_ContactList.OnContactHiddenChanged(pEvent->hContact, pEvent->iValue != 0);
break;
case EVENT_CONTACT_GROUP:
- m_ContactList.OnContactGroupChanged(pEvent->hContact,pEvent->strValue);
+ m_ContactList.OnContactGroupChanged(pEvent->hContact, pEvent->strValue);
break;
}
}
@@ -191,28 +190,32 @@ void CContactlistScreen::OnSessionOpened(MCONTACT hContact) void CContactlistScreen::OnLCDButtonDown(int iButton)
{
m_bLongPress = false;
- if(iButton == LGLCDBUTTON_CANCEL) {
+ if (iButton == LGLCDBUTTON_CANCEL) {
CAppletManager::GetInstance()->ActivatePreviousScreen();
- } else if(iButton == LGLCDBUTTON_BUTTON1 || iButton == LGLCDBUTTON_DOWN) {
+ }
+ else if (iButton == LGLCDBUTTON_BUTTON1 || iButton == LGLCDBUTTON_DOWN) {
m_ContactList.ScrollDown();
- } else if(iButton == LGLCDBUTTON_BUTTON0 || iButton == LGLCDBUTTON_UP) {
+ }
+ else if (iButton == LGLCDBUTTON_BUTTON0 || iButton == LGLCDBUTTON_UP) {
m_ContactList.ScrollUp();
- } else if(iButton == LGLCDBUTTON_BUTTON2 || iButton == LGLCDBUTTON_MENU) {
+ }
+ else if (iButton == LGLCDBUTTON_BUTTON2 || iButton == LGLCDBUTTON_MENU) {
CAppletManager::GetInstance()->ActivateEventScreen();
return;
- } else if(iButton == LGLCDBUTTON_BUTTON3 || iButton == LGLCDBUTTON_OK) {
- CListEntry<CContactListEntry*,CContactListGroup*> *pEntry = m_ContactList.GetSelectedEntry();
- if(!pEntry)
+ }
+ else if (iButton == LGLCDBUTTON_BUTTON3 || iButton == LGLCDBUTTON_OK) {
+ CListEntry<CContactListEntry*, CContactListGroup*> *pEntry = m_ContactList.GetSelectedEntry();
+ if (!pEntry)
return;
- if(pEntry->GetType() == CONTAINER) {
- CListContainer<CContactListEntry*,CContactListGroup*> *pContainer = (CListContainer<CContactListEntry*,CContactListGroup*>*)pEntry;
- if(pContainer->GetGroupData()->hMetaContact == NULL) {
+ if (pEntry->GetType() == CONTAINER) {
+ CListContainer<CContactListEntry*, CContactListGroup*> *pContainer = (CListContainer<CContactListEntry*, CContactListGroup*>*)pEntry;
+ if (pContainer->GetGroupData()->hMetaContact == NULL) {
pContainer->ToggleOpen();
}
- } else if(pEntry->GetType() == ITEM)
- {
- CContactListEntry *pContact = ((CListItem<CContactListEntry*,CContactListGroup*>*)pEntry)->GetItemData();
- if(!pContact->hHandle)
+ }
+ else if (pEntry->GetType() == ITEM) {
+ CContactListEntry *pContact = ((CListItem<CContactListEntry*, CContactListGroup*>*)pEntry)->GetItemData();
+ if (!pContact->hHandle)
return;
CAppletManager::GetInstance()->ActivateChatScreen(pContact->hHandle);
return;
@@ -228,13 +231,15 @@ void CContactlistScreen::OnLCDButtonDown(int iButton) void CContactlistScreen::OnLCDButtonRepeated(int iButton)
{
m_bLongPress = true;
- if(iButton == LGLCDBUTTON_BUTTON1 || iButton == LGLCDBUTTON_DOWN) {
+ if (iButton == LGLCDBUTTON_BUTTON1 || iButton == LGLCDBUTTON_DOWN) {
m_ContactList.ScrollDown();
- } else if(iButton == LGLCDBUTTON_BUTTON0 || iButton == LGLCDBUTTON_UP) {
+ }
+ else if (iButton == LGLCDBUTTON_BUTTON0 || iButton == LGLCDBUTTON_UP) {
m_ContactList.ScrollUp();
- } else if(iButton == LGLCDBUTTON_BUTTON3 || iButton == LGLCDBUTTON_OK) {
+ }
+ else if (iButton == LGLCDBUTTON_BUTTON3 || iButton == LGLCDBUTTON_OK) {
UpdateUseSoftkeyLabel();
- }
+ }
}
//************************************************************************
@@ -242,16 +247,16 @@ void CContactlistScreen::OnLCDButtonRepeated(int iButton) //************************************************************************
void CContactlistScreen::OnLCDButtonUp(int iButton)
{
- if(iButton == LGLCDBUTTON_BUTTON3 || iButton == LGLCDBUTTON_OK) {
+ if (iButton == LGLCDBUTTON_BUTTON3 || iButton == LGLCDBUTTON_OK) {
m_ContactList.ShowSelection();
- CListEntry<CContactListEntry*,CContactListGroup*> *pEntry = m_ContactList.GetSelectedEntry();
- if(!pEntry)
+ CListEntry<CContactListEntry*, CContactListGroup*> *pEntry = m_ContactList.GetSelectedEntry();
+ if (!pEntry)
return;
- if(pEntry->GetType() == CONTAINER) {
- CListContainer<CContactListEntry*,CContactListGroup*> *pContainer = (CListContainer<CContactListEntry*,CContactListGroup*>*)pEntry;
- if(pContainer->GetGroupData()->hMetaContact != NULL) {
- if(m_bLongPress)
+ if (pEntry->GetType() == CONTAINER) {
+ CListContainer<CContactListEntry*, CContactListGroup*> *pContainer = (CListContainer<CContactListEntry*, CContactListGroup*>*)pEntry;
+ if (pContainer->GetGroupData()->hMetaContact != NULL) {
+ if (m_bLongPress)
pContainer->ToggleOpen();
else
CAppletManager::GetInstance()->ActivateChatScreen(pContainer->GetGroupData()->hMetaContact);
@@ -267,7 +272,6 @@ void CContactlistScreen::OnLCDButtonUp(int iButton) //************************************************************************
void CContactlistScreen::OnActivation()
{
-
}
//************************************************************************
@@ -289,24 +293,19 @@ void CContactlistScreen::OnExpiration() //************************************************************************
void CContactlistScreen::UpdateUseSoftkeyLabel()
{
- CListEntry<CContactListEntry*,CContactListGroup*> *pEntry = m_ContactList.GetSelectedEntry();
- if(!pEntry)
+ CListEntry<CContactListEntry*, CContactListGroup*> *pEntry = m_ContactList.GetSelectedEntry();
+ if (!pEntry)
return;
- if(pEntry->GetType() == CONTAINER)
- {
- CListContainer<CContactListEntry*,CContactListGroup*> *pContainer = (CListContainer<CContactListEntry*,CContactListGroup*>*)pEntry;
- if(pContainer->GetGroupData()->hMetaContact == NULL || m_bLongPress) {
- if(((CListContainer<CContactListEntry*,CContactListGroup*>*)pEntry)->IsOpen())
- SetButtonBitmap(3,IDB_MINUS);
+ if (pEntry->GetType() == CONTAINER) {
+ CListContainer<CContactListEntry*, CContactListGroup*> *pContainer = (CListContainer<CContactListEntry*, CContactListGroup*>*)pEntry;
+ if (pContainer->GetGroupData()->hMetaContact == NULL || m_bLongPress) {
+ if (((CListContainer<CContactListEntry*, CContactListGroup*>*)pEntry)->IsOpen())
+ SetButtonBitmap(3, IDB_MINUS);
else
- SetButtonBitmap(3,IDB_PLUS);
- } else {
- SetButtonBitmap(3,IDB_CHAT);
+ SetButtonBitmap(3, IDB_PLUS);
}
+ else SetButtonBitmap(3, IDB_CHAT);
}
- else
- {
- SetButtonBitmap(3,IDB_CHAT);
- }
-}
\ No newline at end of file + else SetButtonBitmap(3, IDB_CHAT);
+}
diff --git a/plugins/MirandaG15/src/CContactlistScreen.h b/plugins/MirandaG15/src/CContactlistScreen.h index 329532a231..181e926a0f 100644 --- a/plugins/MirandaG15/src/CContactlistScreen.h +++ b/plugins/MirandaG15/src/CContactlistScreen.h @@ -21,7 +21,7 @@ public: bool Update();
// Draws the screen
bool Draw(CLCDGfx *pGfx);
-
+
// resets the position of the contactlist
void ResetPosition();
diff --git a/plugins/MirandaG15/src/CCreditsScreen.cpp b/plugins/MirandaG15/src/CCreditsScreen.cpp index 9a025ffe51..72f679523e 100644 --- a/plugins/MirandaG15/src/CCreditsScreen.cpp +++ b/plugins/MirandaG15/src/CCreditsScreen.cpp @@ -5,7 +5,7 @@ //************************************************************************
// Constructor
//************************************************************************
-CCreditsScreen::CCreditsScreen() : m_dwActivation(0), m_dwDuration(0), m_iPosition(0)
+CCreditsScreen::CCreditsScreen()
{
}
@@ -21,7 +21,7 @@ CCreditsScreen::~CCreditsScreen() //************************************************************************
bool CCreditsScreen::Initialize()
{
- if(!CScreen::Initialize())
+ if (!CScreen::Initialize())
return false;
m_Label.Initialize();
@@ -45,7 +45,7 @@ bool CCreditsScreen::Initialize() //************************************************************************
bool CCreditsScreen::Shutdown()
{
- if(!CScreen::Shutdown())
+ if (!CScreen::Shutdown())
return false;
return true;
@@ -56,50 +56,48 @@ bool CCreditsScreen::Shutdown() //************************************************************************
bool CCreditsScreen::Update()
{
- if(!CScreen::Update())
+ if (!CScreen::Update())
return false;
DWORD dwTimeElapsed = GetTickCount() - m_dwActivation;
int iOldPosition = m_iPosition;
- if(dwTimeElapsed > m_dwDuration)
- {
+ if (dwTimeElapsed > m_dwDuration) {
m_dwDuration = 4000;
m_Label.SetText(L"");
m_Label2.SetText(L"");
- switch(m_iPosition)
- {
+ switch (m_iPosition) {
case 0:
m_Label.SetText(L"MirandaG15");
m_Label2.SetText(L"2008 by Martin Kleinhans");
m_dwDuration = 2500;
break;
case 1:
- m_Label.SetSize(GetWidth(),GetHeight());
+ m_Label.SetSize(GetWidth(), GetHeight());
m_Label.SetText(L"Special thanks to:");
m_dwDuration = 2000;
break;
- case 2:
- m_Label.SetSize(GetWidth(),25);
+ case 2:
+ m_Label.SetSize(GetWidth(), 25);
m_Label.SetText(L"Shere Khan\n");
m_Label2.SetText(L"Concept, Ideas, Testing");
m_dwDuration = 2500;
break;
case 3:
- m_Label.SetSize(GetWidth(),25);
+ m_Label.SetSize(GetWidth(), 25);
m_Label.SetText(L"Tauu and Cloonix\n");
m_Label2.SetText(L"Ideas, Testing");
m_dwDuration = 2500;
break;
- case 4:
- m_Label.SetSize(GetWidth(),GetHeight());
+ case 4:
+ m_Label.SetSize(GetWidth(), GetHeight());
m_Label.SetFontPointSize(10);
m_Label.SetFontWeight(FW_BOLD);
m_Label.SetText(L"Betatesters:");
m_dwDuration = 2000;
break;
case 5:
- m_Label.SetSize(GetWidth(),25);
+ m_Label.SetSize(GetWidth(), 25);
m_Label2.SetFontPointSize(10);
m_Label2.SetFontWeight(FW_BOLD);
m_Label.SetText(L"Cyberz");
@@ -121,12 +119,12 @@ bool CCreditsScreen::Update() m_dwDuration = 2000;
break;
case 9:
- m_Label.SetSize(GetWidth(),GetHeight());
+ m_Label.SetSize(GetWidth(), GetHeight());
m_Label.SetText(L"Additional thanks to:");
m_dwDuration = 2000;
break;
case 10:
- m_Label.SetSize(GetWidth(),25);
+ m_Label.SetSize(GetWidth(), 25);
m_Label2.SetFontPointSize(8);
m_Label2.SetFontWeight(FW_NORMAL);
m_Label.SetText(L"Everyone");
@@ -141,16 +139,16 @@ bool CCreditsScreen::Update() case 12:
m_Label.SetFontPointSize(10);
m_Label.SetFontWeight(FW_BOLD);
- m_Label.SetSize(GetWidth(),25);
+ m_Label.SetSize(GetWidth(), 25);
m_Label.SetText(L"Logitech");
m_Label2.SetText(L"for obvious reasons");
m_dwDuration = 2000;
break;
case 13:
- m_Label.SetSize(GetWidth(),10);
+ m_Label.SetSize(GetWidth(), 10);
m_Label.SetText(L"You can contact me at:");
- m_Label2.SetSize(GetWidth(),33);
- m_Label2.SetOrigin(0,10);
+ m_Label2.SetSize(GetWidth(), 33);
+ m_Label2.SetOrigin(0, 10);
m_Label2.SetFontPointSize(8);
m_Label2.SetText(L"mail@mkleinhans.de\nwww.mkleinhans.de");
m_dwDuration = 2500;
@@ -162,8 +160,8 @@ bool CCreditsScreen::Update() m_iPosition++;
CAppletManager::GetInstance()->StartTransition(TRANSITION_MORPH);
}
-
- if(m_iPosition != iOldPosition)
+
+ if (m_iPosition != iOldPosition)
m_dwActivation = GetTickCount();
return true;
}
@@ -175,9 +173,9 @@ void CCreditsScreen::Reset() {
m_dwActivation = GetTickCount();
m_dwDuration = 0;
-
+
m_iPosition = 0;
-
+
CAppletManager::GetInstance()->GetLCDConnection()->SetAsForeground(true);
m_Label2.SetAlignment(DT_CENTER);
@@ -186,11 +184,11 @@ void CCreditsScreen::Reset() m_Label2.SetFontFaceName(L"Microsoft Sans Serif");
m_Label2.SetFontPointSize(8);
- m_Label.SetOrigin(0,0);
- m_Label.SetSize(GetWidth(),20);
+ m_Label.SetOrigin(0, 0);
+ m_Label.SetSize(GetWidth(), 20);
- m_Label2.SetOrigin(0,23);
- m_Label2.SetSize(GetWidth(),20);
+ m_Label2.SetOrigin(0, 23);
+ m_Label2.SetSize(GetWidth(), 20);
}
@@ -199,7 +197,7 @@ void CCreditsScreen::Reset() //************************************************************************
bool CCreditsScreen::Draw(CLCDGfx *pGfx)
{
- if(!CScreen::Draw(pGfx))
+ if (!CScreen::Draw(pGfx))
return false;
return true;
diff --git a/plugins/MirandaG15/src/CCreditsScreen.h b/plugins/MirandaG15/src/CCreditsScreen.h index c239094114..fce21c0551 100644 --- a/plugins/MirandaG15/src/CCreditsScreen.h +++ b/plugins/MirandaG15/src/CCreditsScreen.h @@ -45,9 +45,9 @@ private: CLCDLabel m_Label;
CLCDLabel m_Label2;
- DWORD m_dwActivation;
- DWORD m_dwDuration;
- int m_iPosition;
+ DWORD m_dwActivation = 0;
+ DWORD m_dwDuration = 0;
+ int m_iPosition = 0;
};
#endif
\ No newline at end of file diff --git a/plugins/MirandaG15/src/CEvent.h b/plugins/MirandaG15/src/CEvent.h index e7c683123d..677e7b07a1 100644 --- a/plugins/MirandaG15/src/CEvent.h +++ b/plugins/MirandaG15/src/CEvent.h @@ -1,39 +1,42 @@ #ifndef _CEVENT_H_
#define _CEVENT_H_
-enum EventType { EVENT_MSG_RECEIVED = 0,
- EVENT_MSG_SENT = 3,
- EVENT_MESSAGE_ACK = 4,
- EVENT_STATUS = 1,
- EVENT_MSG_ACK = 2,
+enum EventType
+{
+ EVENT_MSG_RECEIVED = 0,
+ EVENT_MSG_SENT = 3,
+ EVENT_MESSAGE_ACK = 4,
+ EVENT_STATUS = 1,
+ EVENT_MSG_ACK = 2,
- EVENT_FILE = 6,
- EVENT_AUTHREQUEST = 7,
- EVENT_CONTACTS = 8,
- EVENT_ADDED = 9,
+ EVENT_FILE = 6,
+ EVENT_AUTHREQUEST = 7,
+ EVENT_CONTACTS = 8,
+ EVENT_ADDED = 9,
- EVENT_CONTACT_ADDED = 10,
- EVENT_CONTACT_DELETED = 11,
- EVENT_CONTACT_NICK = 12,
- EVENT_CONTACT_HIDDEN = 13,
- EVENT_CONTACT_GROUP = 14,
+ EVENT_CONTACT_ADDED = 10,
+ EVENT_CONTACT_DELETED = 11,
+ EVENT_CONTACT_NICK = 12,
+ EVENT_CONTACT_HIDDEN = 13,
+ EVENT_CONTACT_GROUP = 14,
- EVENT_SIGNED_ON = 15,
- EVENT_SIGNED_OFF = 16,
+ EVENT_SIGNED_ON = 15,
+ EVENT_SIGNED_OFF = 16,
- EVENT_PROTO_STATUS = 17,
- EVENT_PROTO_CONNECTED = 18,
- EVENT_PROTO_DISCONNECTED = 19,
+ EVENT_PROTO_STATUS = 17,
+ EVENT_PROTO_CONNECTED = 18,
+ EVENT_PROTO_DISCONNECTED = 19,
- EVENT_TYPING_NOTIFICATION = 20,
- EVENT_MESSAGEWINDOW = 21,
- EVENT_IRC_SENT = 22,
- EVENT_IRC_RECEIVED = 23};
+ EVENT_TYPING_NOTIFICATION = 20,
+ EVENT_MESSAGEWINDOW = 21,
+ EVENT_IRC_SENT = 22,
+ EVENT_IRC_RECEIVED = 23
+};
#define MSG_READ 0
#define MSG_UNREAD 1
-class CEvent
+class CEvent
{
public:
CEvent()
diff --git a/plugins/MirandaG15/src/CEventLog.cpp b/plugins/MirandaG15/src/CEventLog.cpp index dd82d923f4..783f6160d2 100644 --- a/plugins/MirandaG15/src/CEventLog.cpp +++ b/plugins/MirandaG15/src/CEventLog.cpp @@ -8,7 +8,6 @@ //************************************************************************
CEventLog::CEventLog()
{
- m_dwLastScroll = 0;
}
//************************************************************************
@@ -16,7 +15,6 @@ CEventLog::CEventLog() //************************************************************************
CEventLog::~CEventLog()
{
-
}
//************************************************************************
@@ -24,7 +22,7 @@ CEventLog::~CEventLog() //************************************************************************
bool CEventLog::Shutdown()
{
- if(!CLCDList<CEventLogEntry*>::Shutdown())
+ if (!CLCDList<CEventLogEntry*>::Shutdown())
return false;
return true;
@@ -35,7 +33,7 @@ bool CEventLog::Shutdown() //************************************************************************
bool CEventLog::Initialize()
{
- if(!CLCDList<CEventLogEntry*>::Initialize())
+ if (!CLCDList<CEventLogEntry*>::Initialize())
return false;
return true;
@@ -46,11 +44,10 @@ bool CEventLog::Initialize() //************************************************************************
bool CEventLog::SetFont(LOGFONT &lf)
{
- if(!CLCDList<CEventLogEntry*>::SetFont(lf))
+ if (!CLCDList<CEventLogEntry*>::SetFont(lf))
return false;
- SetEntryHeight(m_iFontHeight<6?6:m_iFontHeight);
-
+ SetEntryHeight(m_iFontHeight < 6 ? 6 : m_iFontHeight);
return true;
}
@@ -60,10 +57,10 @@ bool CEventLog::SetFont(LOGFONT &lf) CListItem<CEventLogEntry*> *CEventLog::AddItem(CEventLogEntry *pEntry)
{
CListItem<CEventLogEntry*> *pItem = CLCDList<CEventLogEntry*>::AddItem(pEntry);
- if(GetEntryCount() > CConfig::GetIntSetting(NOTIFY_LOGSIZE))
+ if (GetEntryCount() > CConfig::GetIntSetting(NOTIFY_LOGSIZE))
RemoveItem(((CListItem<CEventLogEntry*>*)GetFirstEntry())->GetItemData());
-
- if(GetTickCount() - m_dwLastScroll > 10000)
+
+ if (GetTickCount() - m_dwLastScroll > 10000)
SetPosition(pItem);
return pItem;
}
@@ -79,25 +76,24 @@ void CEventLog::DeleteEntry(CEventLogEntry *pEntry) //************************************************************************
// Called to draw the specified entry
//************************************************************************
-void CEventLog::DrawEntry(CLCDGfx *pGfx,CEventLogEntry *pEntry,bool bSelected)
+void CEventLog::DrawEntry(CLCDGfx *pGfx, CEventLogEntry *pEntry, bool bSelected)
{
- SelectObject(pGfx->GetHDC(),m_hFont);
+ SelectObject(pGfx->GetHDC(), m_hFont);
bool bLargeIcons = GetEntryHeight() > 8;
- int iOffset = (m_iFontHeight-(bLargeIcons?8:6))/2;
- HBITMAP hBitmap = CAppletManager::GetInstance()->GetEventBitmap(pEntry->eType,bLargeIcons);
- pGfx->DrawBitmap(0,iOffset<0?0:iOffset,bLargeIcons?8:6,bLargeIcons?8:6,hBitmap);
+ int iOffset = (m_iFontHeight - (bLargeIcons ? 8 : 6)) / 2;
+ HBITMAP hBitmap = CAppletManager::GetInstance()->GetEventBitmap(pEntry->eType, bLargeIcons);
+ pGfx->DrawBitmap(0, iOffset < 0 ? 0 : iOffset, bLargeIcons ? 8 : 6, bLargeIcons ? 8 : 6, hBitmap);
- iOffset = bLargeIcons?10:7;
- if(CConfig::GetBoolSetting(NOTIFY_TIMESTAMPS))
- pGfx->DrawText(iOffset,0,pGfx->GetClipWidth()-iOffset,pEntry->strTimestamp + pEntry->strValue);
+ iOffset = bLargeIcons ? 10 : 7;
+ if (CConfig::GetBoolSetting(NOTIFY_TIMESTAMPS))
+ pGfx->DrawText(iOffset, 0, pGfx->GetClipWidth() - iOffset, pEntry->strTimestamp + pEntry->strValue);
else
- pGfx->DrawText(iOffset,0,pGfx->GetClipWidth()-iOffset,pEntry->strValue);
+ pGfx->DrawText(iOffset, 0, pGfx->GetClipWidth() - iOffset, pEntry->strValue);
- if(bSelected && GetTickCount() - m_dwLastScroll < 1000)
- {
- RECT invert = { 0,0,GetWidth(),m_iFontHeight};
- InvertRect(pGfx->GetHDC(),&invert);
+ if (bSelected && GetTickCount() - m_dwLastScroll < 1000) {
+ RECT invert = {0,0,GetWidth(),m_iFontHeight};
+ InvertRect(pGfx->GetHDC(), &invert);
}
}
diff --git a/plugins/MirandaG15/src/CEventLog.h b/plugins/MirandaG15/src/CEventLog.h index 9c27fe64e8..cf08b5f214 100644 --- a/plugins/MirandaG15/src/CEventLog.h +++ b/plugins/MirandaG15/src/CEventLog.h @@ -20,14 +20,14 @@ public: CEventLog();
// destructor
~CEventLog();
-
+
// initializes the list
bool Initialize();
// deinitializes the list
bool Shutdown();
// adds an entry to the list
CListItem<CEventLogEntry*> *AddItem(CEventLogEntry *);
-
+
void SetPosition(CListEntry<CEventLogEntry*> *pEntry);
bool ScrollUp();
bool ScrollDown();
@@ -38,9 +38,9 @@ protected: // Called to delete the specified entry
void DeleteEntry(CEventLogEntry *pEntry);
// Called to draw the specified entry
- void DrawEntry(CLCDGfx *pGfx,CEventLogEntry *pEntry,bool bSelected);
+ void DrawEntry(CLCDGfx *pGfx, CEventLogEntry *pEntry, bool bSelected);
- DWORD m_dwLastScroll;
+ DWORD m_dwLastScroll = 0;
};
-#endif
\ No newline at end of file +#endif
diff --git a/plugins/MirandaG15/src/CEventScreen.cpp b/plugins/MirandaG15/src/CEventScreen.cpp index 1d240265a8..169a2caef9 100644 --- a/plugins/MirandaG15/src/CEventScreen.cpp +++ b/plugins/MirandaG15/src/CEventScreen.cpp @@ -22,28 +22,27 @@ CEventScreen::~CEventScreen() //************************************************************************
bool CEventScreen::Initialize()
{
- if(!CScreen::Initialize())
+ if (!CScreen::Initialize())
return false;
m_EventLog.Initialize();
- m_EventLog.SetOrigin(0,0);
- m_EventLog.SetSize(GetWidth()-5,GetHeight()-(CConfig::GetBoolSetting(SHOW_LABELS)?6:0));
+ m_EventLog.SetOrigin(0, 0);
+ m_EventLog.SetSize(GetWidth() - 5, GetHeight() - (CConfig::GetBoolSetting(SHOW_LABELS) ? 6 : 0));
m_EventLog.SetFont(CConfig::GetFont(FONT_LOG));
AddObject(&m_EventLog);
m_Scrollbar.Initialize();
- m_Scrollbar.SetOrigin(GetWidth()-4,0);
- m_Scrollbar.SetSize(4,GetHeight()-(CConfig::GetBoolSetting(SHOW_LABELS)?5:0));
+ m_Scrollbar.SetOrigin(GetWidth() - 4, 0);
+ m_Scrollbar.SetSize(4, GetHeight() - (CConfig::GetBoolSetting(SHOW_LABELS) ? 5 : 0));
m_EventLog.SetScrollbar(&m_Scrollbar);
AddObject(&m_Scrollbar);
- SetButtonBitmap(0,IDB_UP);
- SetButtonBitmap(1,IDB_DOWN);
- SetButtonBitmap(2,IDB_CLIST);
- SetButtonBitmap(3,NULL);
-
+ SetButtonBitmap(0, IDB_UP);
+ SetButtonBitmap(1, IDB_DOWN);
+ SetButtonBitmap(2, IDB_CLIST);
+ SetButtonBitmap(3, NULL);
return true;
}
@@ -52,7 +51,7 @@ bool CEventScreen::Initialize() //************************************************************************
bool CEventScreen::Shutdown()
{
- if(!CScreen::Shutdown())
+ if (!CScreen::Shutdown())
return false;
return true;
@@ -63,7 +62,7 @@ bool CEventScreen::Shutdown() //************************************************************************
bool CEventScreen::Update()
{
- if(!CScreen::Update())
+ if (!CScreen::Update())
return false;
return true;
@@ -74,7 +73,7 @@ bool CEventScreen::Update() //************************************************************************
bool CEventScreen::Draw(CLCDGfx *pGfx)
{
- if(!CScreen::Draw(pGfx))
+ if (!CScreen::Draw(pGfx))
return false;
return true;
@@ -88,11 +87,10 @@ void CEventScreen::OnSizeChanged() CScreen::OnSizeChanged();
m_EventLog.SetFont(CConfig::GetFont(FONT_LOG));
- m_EventLog.SetSize(GetWidth()-5,GetHeight()-(CConfig::GetBoolSetting(SHOW_LABELS)?6:0));
+ m_EventLog.SetSize(GetWidth() - 5, GetHeight() - (CConfig::GetBoolSetting(SHOW_LABELS) ? 6 : 0));
- m_Scrollbar.SetOrigin(GetWidth()-4,0);
-
- m_Scrollbar.SetSize(4,GetHeight()-(CConfig::GetBoolSetting(SHOW_LABELS)?5:0));
+ m_Scrollbar.SetOrigin(GetWidth() - 4, 0);
+ m_Scrollbar.SetSize(4, GetHeight() - (CConfig::GetBoolSetting(SHOW_LABELS) ? 5 : 0));
}
//************************************************************************
@@ -103,19 +101,18 @@ void CEventScreen::OnConfigChanged() CScreen::OnConfigChanged();
m_EventLog.SetFont(CConfig::GetFont(FONT_LOG));
- m_EventLog.SetSize(GetWidth()-5,GetHeight()-(CConfig::GetBoolSetting(SHOW_LABELS)?6:0));
+ m_EventLog.SetSize(GetWidth() - 5, GetHeight() - (CConfig::GetBoolSetting(SHOW_LABELS) ? 6 : 0));
// Update all timestamps
- list<CListEntry<CEventLogEntry*>*>::iterator iter = m_EventLog.begin();
+ list<CListEntry<CEventLogEntry*>*>::iterator iter = m_EventLog.begin();
CListItem<CEventLogEntry*> *pItem = nullptr;
- while(iter != m_EventLog.end())
- {
+ while (iter != m_EventLog.end()) {
pItem = static_cast<CListItem<CEventLogEntry*>*>(*iter);
pItem->GetItemData()->strTimestamp = CAppletManager::GetFormattedTimestamp(&pItem->GetItemData()->Time) + L" ";
iter++;
}
- m_Scrollbar.SetSize(4,GetHeight()-(CConfig::GetBoolSetting(SHOW_LABELS)?5:0));
+ m_Scrollbar.SetSize(4, GetHeight() - (CConfig::GetBoolSetting(SHOW_LABELS) ? 5 : 0));
}
//************************************************************************
@@ -124,7 +121,7 @@ void CEventScreen::OnConfigChanged() void CEventScreen::OnEventReceived(CEvent *pEvent)
{
// check if the event needs to be listed
- if(!pEvent->bLog)
+ if (!pEvent->bLog)
return;
// create a list entry structure
@@ -148,13 +145,13 @@ void CEventScreen::OnEventReceived(CEvent *pEvent) void CEventScreen::UpdateChatButton()
{
CListEntry<CEventLogEntry*> *pItem = m_EventLog.GetSelectedEntry();
- if(!pItem || pItem->GetType() != ITEM)
- return;
+ if (!pItem || pItem->GetType() != ITEM)
+ return;
CEventLogEntry *pEntry = ((CListItem<CEventLogEntry*>*)pItem)->GetItemData();
- if(pEntry->hContact)
- SetButtonBitmap(3,IDB_CHAT);
+ if (pEntry->hContact)
+ SetButtonBitmap(3, IDB_CHAT);
else
- SetButtonBitmap(3,NULL);
+ SetButtonBitmap(3, NULL);
}
//************************************************************************
@@ -162,32 +159,35 @@ void CEventScreen::UpdateChatButton() //************************************************************************
void CEventScreen::OnLCDButtonDown(int iButton)
{
- if(iButton == LGLCDBUTTON_CANCEL) {
+ if (iButton == LGLCDBUTTON_CANCEL) {
CAppletManager::GetInstance()->ActivatePreviousScreen();
- } else if(iButton == LGLCDBUTTON_BUTTON1 || iButton == LGLCDBUTTON_DOWN) {
+ }
+ else if (iButton == LGLCDBUTTON_BUTTON1 || iButton == LGLCDBUTTON_DOWN) {
m_EventLog.ScrollDown();
UpdateChatButton();
- } else if(iButton == LGLCDBUTTON_BUTTON0 || iButton == LGLCDBUTTON_UP) {
+ }
+ else if (iButton == LGLCDBUTTON_BUTTON0 || iButton == LGLCDBUTTON_UP) {
m_EventLog.ScrollUp();
UpdateChatButton();
- } else if(iButton == LGLCDBUTTON_BUTTON2 || iButton == LGLCDBUTTON_MENU) {
+ }
+ else if (iButton == LGLCDBUTTON_BUTTON2 || iButton == LGLCDBUTTON_MENU) {
CAppletManager::GetInstance()->ActivateCListScreen();
- } else if(iButton == LGLCDBUTTON_BUTTON3 || iButton == LGLCDBUTTON_OK)
- {
+ }
+ else if (iButton == LGLCDBUTTON_BUTTON3 || iButton == LGLCDBUTTON_OK) {
CListEntry<CEventLogEntry*> *pItem = m_EventLog.GetSelectedEntry();
- if(!pItem || pItem->GetType() != ITEM)
- return;
+ if (!pItem || pItem->GetType() != ITEM)
+ return;
CEventLogEntry *pEntry = ((CListItem<CEventLogEntry*>*)pItem)->GetItemData();
- if(!pEntry->hContact)
+ if (!pEntry->hContact)
return;
-
+
// if the contact is an irc chatroom, check if it is hidden (user left the channel)
char *szProto = GetContactProto(pEntry->hContact);
CIRCConnection *pIRCCon = CAppletManager::GetInstance()->GetIRCConnection(toTstring(szProto));
- if(pIRCCon && db_get_b(pEntry->hContact, szProto, "ChatRoom", 0) != 0 &&
- db_get_b(pEntry->hContact,"CList","Hidden",0))
+ if (pIRCCon && db_get_b(pEntry->hContact, szProto, "ChatRoom", 0) != 0 &&
+ db_get_b(pEntry->hContact, "CList", "Hidden", 0))
return;
CAppletManager::GetInstance()->ActivateChatScreen(pEntry->hContact);
@@ -199,10 +199,11 @@ void CEventScreen::OnLCDButtonDown(int iButton) //************************************************************************
void CEventScreen::OnLCDButtonRepeated(int iButton)
{
- if(iButton == LGLCDBUTTON_BUTTON1 || iButton == LGLCDBUTTON_DOWN) {
+ if (iButton == LGLCDBUTTON_BUTTON1 || iButton == LGLCDBUTTON_DOWN) {
m_EventLog.ScrollDown();
UpdateChatButton();
- } else if(iButton == LGLCDBUTTON_BUTTON0 || iButton == LGLCDBUTTON_UP) {
+ }
+ else if (iButton == LGLCDBUTTON_BUTTON0 || iButton == LGLCDBUTTON_UP) {
m_EventLog.ScrollUp();
UpdateChatButton();
}
@@ -213,7 +214,6 @@ void CEventScreen::OnLCDButtonRepeated(int iButton) //************************************************************************
void CEventScreen::OnLCDButtonUp(int)
{
-
}
//************************************************************************
@@ -221,7 +221,6 @@ void CEventScreen::OnLCDButtonUp(int) //************************************************************************
void CEventScreen::OnActivation()
{
-
}
//************************************************************************
@@ -236,4 +235,4 @@ void CEventScreen::OnDeactivation() //************************************************************************
void CEventScreen::OnExpiration()
{
-}
\ No newline at end of file +}
diff --git a/plugins/MirandaG15/src/CIRCHistory.h b/plugins/MirandaG15/src/CIRCHistory.h index d4865ddba0..5b46ae32c9 100644 --- a/plugins/MirandaG15/src/CIRCHistory.h +++ b/plugins/MirandaG15/src/CIRCHistory.h @@ -8,7 +8,6 @@ struct SIRCMessage tstring strMessage;
};
-
class CIRCHistory
{
public:
@@ -19,5 +18,4 @@ public: list<tstring> LUsers;
};
-
#endif
\ No newline at end of file diff --git a/plugins/MirandaG15/src/CNotificationScreen.cpp b/plugins/MirandaG15/src/CNotificationScreen.cpp index 671c315276..bb0c8a95eb 100644 --- a/plugins/MirandaG15/src/CNotificationScreen.cpp +++ b/plugins/MirandaG15/src/CNotificationScreen.cpp @@ -8,8 +8,6 @@ //************************************************************************
CNotificationScreen::CNotificationScreen()
{
- m_pEntry = nullptr;
- //m_bMessageMode = false;
}
//************************************************************************
@@ -24,7 +22,7 @@ CNotificationScreen::~CNotificationScreen() //************************************************************************
bool CNotificationScreen::Initialize()
{
- if(!CScreen::Initialize())
+ if (!CScreen::Initialize())
return false;
m_EventText.Initialize();
@@ -54,8 +52,8 @@ bool CNotificationScreen::Initialize() AddObject(&m_Timestamp);
//AddObject(&m_Input);
- SetButtonBitmap(0,IDB_UP);
- SetButtonBitmap(1,IDB_DOWN);
+ SetButtonBitmap(0, IDB_UP);
+ SetButtonBitmap(1, IDB_DOWN);
return true;
}
@@ -66,16 +64,15 @@ bool CNotificationScreen::Initialize() bool CNotificationScreen::Shutdown()
{
CNotificationEntry *pEntry = nullptr;
- while(!m_LNotifications.empty())
- {
+ while (!m_LNotifications.empty()) {
pEntry = *(m_LNotifications.begin());
m_LNotifications.pop_front();
delete pEntry;
}
- if(!CScreen::Shutdown())
+ if (!CScreen::Shutdown())
return false;
-
+
return true;
}
@@ -84,7 +81,7 @@ bool CNotificationScreen::Shutdown() //************************************************************************
bool CNotificationScreen::Update()
{
- if(!CScreen::Update())
+ if (!CScreen::Update())
return false;
return true;
@@ -95,18 +92,16 @@ bool CNotificationScreen::Update() //************************************************************************
bool CNotificationScreen::Draw(CLCDGfx *pGfx)
{
- if(!CScreen::Draw(pGfx))
+ if (!CScreen::Draw(pGfx))
return false;
-
- if(CConfig::GetIntSetting(NOTIFY_TITLE) != NOTIFY_TITLE_HIDE)
- {
+
+ if (CConfig::GetIntSetting(NOTIFY_TITLE) != NOTIFY_TITLE_HIDE) {
int iTitleHeight = CConfig::GetFontHeight(FONT_TITLE);
- pGfx->DrawLine(0,iTitleHeight < 7?7:iTitleHeight,GetWidth(),iTitleHeight < 7?7:iTitleHeight);
- if(m_pEntry)
- {
- int iOffset = (iTitleHeight-(iTitleHeight>8?8:6))/2;
- HBITMAP hBitmap = CAppletManager::GetInstance()->GetEventBitmap(m_pEntry->eType,iTitleHeight>8);
- pGfx->DrawBitmap(0,iOffset,iTitleHeight>8?8:6,iTitleHeight>8?8:6,hBitmap);
+ pGfx->DrawLine(0, iTitleHeight < 7 ? 7 : iTitleHeight, GetWidth(), iTitleHeight < 7 ? 7 : iTitleHeight);
+ if (m_pEntry) {
+ int iOffset = (iTitleHeight - (iTitleHeight > 8 ? 8 : 6)) / 2;
+ HBITMAP hBitmap = CAppletManager::GetInstance()->GetEventBitmap(m_pEntry->eType, iTitleHeight > 8);
+ pGfx->DrawBitmap(0, iOffset, iTitleHeight > 8 ? 8 : 6, iTitleHeight > 8 ? 8 : 6, hBitmap);
}
}
return true;
@@ -117,44 +112,41 @@ bool CNotificationScreen::Draw(CLCDGfx *pGfx) //************************************************************************
void CNotificationScreen::DisplayNotification(CNotificationEntry *pEntry)
{
- if(m_pEntry != nullptr)
+ if (m_pEntry != nullptr)
delete m_pEntry;
-
tstring strTime = CAppletManager::GetFormattedTimestamp(&pEntry->Time);
m_pEntry = pEntry;
- if(CConfig::GetIntSetting(NOTIFY_TITLE) == NOTIFY_TITLE_NAME || pEntry->strTitle.empty())
+ if (CConfig::GetIntSetting(NOTIFY_TITLE) == NOTIFY_TITLE_NAME || pEntry->strTitle.empty())
m_TitleText.SetText(L"Miranda-IM");
else
m_TitleText.SetText(pEntry->strTitle);
-
- if(CConfig::GetBoolSetting(NOTIFY_TIMESTAMPS))
+
+ if (CConfig::GetBoolSetting(NOTIFY_TIMESTAMPS))
m_Timestamp.SetText(strTime);
else
m_Timestamp.SetText(L"");
- if(pEntry->hContact)
- SetButtonBitmap(3,IDB_CHAT);
+ if (pEntry->hContact)
+ SetButtonBitmap(3, IDB_CHAT);
else
- SetButtonBitmap(3,NULL);
+ SetButtonBitmap(3, NULL);
- if(pEntry->bMessage)
- {
- SetButtonBitmap(0,IDB_UP);
- SetButtonBitmap(1,IDB_DOWN);
+ if (pEntry->bMessage) {
+ SetButtonBitmap(0, IDB_UP);
+ SetButtonBitmap(1, IDB_DOWN);
m_MessageText.Show(1);
m_Scrollbar.Show(1);
m_EventText.Show(0);
m_MessageText.SetText(pEntry->strText.c_str());
}
- else
- {
- SetButtonBitmap(0,NULL);
- SetButtonBitmap(1,NULL);
-
+ else {
+ SetButtonBitmap(0, NULL);
+ SetButtonBitmap(1, NULL);
+
m_Scrollbar.Show(0);
m_MessageText.Show(0);
m_EventText.Show(1);
@@ -167,45 +159,42 @@ void CNotificationScreen::DisplayNotification(CNotificationEntry *pEntry) //************************************************************************
void CNotificationScreen::UpdateObjects()
{
- int iHeight = GetHeight() - (CConfig::GetBoolSetting(SHOW_LABELS)?6:0);
+ int iHeight = GetHeight() - (CConfig::GetBoolSetting(SHOW_LABELS) ? 6 : 0);
int iOrigin = 0;
- if(CConfig::GetIntSetting(NOTIFY_TITLE) == NOTIFY_TITLE_HIDE)
- {
+ if (CConfig::GetIntSetting(NOTIFY_TITLE) == NOTIFY_TITLE_HIDE) {
m_TitleText.Show(false);
m_Timestamp.Show(false);
}
- else
- {
+ else {
iOrigin = CConfig::GetFontHeight(FONT_TITLE);
iHeight -= iOrigin;
m_Timestamp.Show(true);
m_TitleText.Show(true);
}
-
m_MessageText.SetFont(CConfig::GetFont(FONT_NOTIFICATION));
m_TitleText.SetFont(CConfig::GetFont(FONT_TITLE));
m_EventText.SetFont(CConfig::GetFont(FONT_NOTIFICATION));
m_Timestamp.SetFont(CConfig::GetFont(FONT_TITLE));
-
- m_Timestamp.SetSize((GetWidth()/3),CConfig::GetFontHeight(FONT_TITLE));
- m_Timestamp.SetOrigin((GetWidth()/3)*2,0);
- m_TitleText.SetSize(((GetWidth()/3)*2) -5,CConfig::GetFontHeight(FONT_TITLE));
- m_TitleText.SetOrigin(9,0);
+ m_Timestamp.SetSize((GetWidth() / 3), CConfig::GetFontHeight(FONT_TITLE));
+ m_Timestamp.SetOrigin((GetWidth() / 3) * 2, 0);
+
+ m_TitleText.SetSize(((GetWidth() / 3) * 2) - 5, CConfig::GetFontHeight(FONT_TITLE));
+ m_TitleText.SetOrigin(9, 0);
- m_EventText.SetOrigin(0,iOrigin + 1);
- m_EventText.SetSize(GetWidth()-4, iHeight);
+ m_EventText.SetOrigin(0, iOrigin + 1);
+ m_EventText.SetSize(GetWidth() - 4, iHeight);
+
+ m_MessageText.SetOrigin(0, iOrigin + 1);
+ m_MessageText.SetSize(GetWidth() - 4, iHeight);
- m_MessageText.SetOrigin(0, iOrigin+1);
- m_MessageText.SetSize(GetWidth()-4, iHeight);
-
//m_Input.SetOrigin(0, iOrigin+1);
//m_Input.SetSize(GetWidth()-4, iHeight);
- m_Scrollbar.SetOrigin(GetWidth()-4,iOrigin+1);
- m_Scrollbar.SetSize(4,iHeight);
+ m_Scrollbar.SetOrigin(GetWidth() - 4, iOrigin + 1);
+ m_Scrollbar.SetSize(4, iHeight);
}
//************************************************************************
@@ -234,27 +223,25 @@ void CNotificationScreen::OnConfigChanged() void CNotificationScreen::OnEventReceived(CEvent *pEvent)
{
// check wether this events needs notification
- if(!pEvent->bNotification)
+ if (!pEvent->bNotification)
return;
CNotificationEntry *pEntry = new CNotificationEntry();
pEntry->eType = pEvent->eType;
pEntry->strTitle = pEvent->strSummary;
- if(pEvent->eType == EVENT_MSG_RECEIVED ||
- (pEvent->eType == EVENT_IRC_RECEIVED && (pEvent->iValue == GC_EVENT_MESSAGE || pEvent->iValue == GC_EVENT_NOTICE)))
- {
+ if (pEvent->eType == EVENT_MSG_RECEIVED ||
+ (pEvent->eType == EVENT_IRC_RECEIVED && (pEvent->iValue == GC_EVENT_MESSAGE || pEvent->iValue == GC_EVENT_NOTICE))) {
pEntry->bMessage = true;
tstring strUser = CAppletManager::GetContactDisplayname(pEvent->hContact);
- if(CConfig::GetIntSetting(NOTIFY_TITLE) == NOTIFY_TITLE_INFO)
+ if (CConfig::GetIntSetting(NOTIFY_TITLE) == NOTIFY_TITLE_INFO)
pEntry->strText = pEvent->strValue;
else
- pEntry->strText = strUser + (pEvent->eType == EVENT_IRC_RECEIVED?L" - ":L": ")+ pEvent->strValue;
+ pEntry->strText = strUser + (pEvent->eType == EVENT_IRC_RECEIVED ? L" - " : L": ") + pEvent->strValue;
}
- else
- {
+ else {
pEntry->bMessage = false;
- if(CConfig::GetIntSetting(NOTIFY_TITLE) == NOTIFY_TITLE_INFO && pEvent->eType == EVENT_IRC_RECEIVED )
+ if (CConfig::GetIntSetting(NOTIFY_TITLE) == NOTIFY_TITLE_INFO && pEvent->eType == EVENT_IRC_RECEIVED)
pEntry->strText = pEvent->strValue;
else
pEntry->strText = pEvent->strDescription;
@@ -262,16 +249,14 @@ void CNotificationScreen::OnEventReceived(CEvent *pEvent) pEntry->hContact = pEvent->hContact;
pEntry->Time = pEvent->Time;
-
- if(m_pEntry)
- {
+
+ if (m_pEntry) {
m_LNotifications.push_back(pEntry);
- SetButtonBitmap(2,IDB_NEXT);
+ SetButtonBitmap(2, IDB_NEXT);
}
- else
- {
+ else {
DisplayNotification(pEntry);
- SetButtonBitmap(2,NULL);
+ SetButtonBitmap(2, NULL);
}
}
//************************************************************************
@@ -279,39 +264,40 @@ void CNotificationScreen::OnEventReceived(CEvent *pEvent) //************************************************************************
void CNotificationScreen::OnLCDButtonDown(int iButton)
{
- CScreen::OnLCDButtonDown(iButton);
+ CScreen::OnLCDButtonDown(iButton);
- if((iButton == LGLCDBUTTON_BUTTON2 || iButton == LGLCDBUTTON_RIGHT) && m_LNotifications.size() >= 1)
- {
+ if ((iButton == LGLCDBUTTON_BUTTON2 || iButton == LGLCDBUTTON_RIGHT) && m_LNotifications.size() >= 1) {
CNotificationEntry *pEntry = *(m_LNotifications.begin());
m_LNotifications.pop_front();
-
- if(m_LNotifications.size() >= 1)
- SetButtonBitmap(2,IDB_NEXT);
+
+ if (m_LNotifications.size() >= 1)
+ SetButtonBitmap(2, IDB_NEXT);
else
- SetButtonBitmap(2,NULL);
+ SetButtonBitmap(2, NULL);
DisplayNotification(pEntry);
- SetExpiration(CConfig::GetIntSetting(NOTIFY_DURATION)*1000);
+ SetExpiration(CConfig::GetIntSetting(NOTIFY_DURATION) * 1000);
}
- else if((iButton == LGLCDBUTTON_BUTTON3 || iButton == LGLCDBUTTON_OK) && m_pEntry && m_pEntry->hContact)
- {
+ else if ((iButton == LGLCDBUTTON_BUTTON3 || iButton == LGLCDBUTTON_OK) && m_pEntry && m_pEntry->hContact) {
SetExpiration(0);
- CLCDConnection *pLCDCon = CAppletManager::GetInstance()->GetLCDConnection();
+ CLCDConnection *pLCDCon = CAppletManager::GetInstance()->GetLCDConnection();
pLCDCon->SetAsForeground(1);
pLCDCon->SetAsForeground(0);
CAppletManager::GetInstance()->ActivateChatScreen(m_pEntry->hContact);
- } else if(!m_MessageText.IsVisible()) {
+ }
+ else if (!m_MessageText.IsVisible()) {
SetExpiration(0);
- } else {
- if(iButton == LGLCDBUTTON_BUTTON1 || iButton == LGLCDBUTTON_DOWN) {
+ }
+ else {
+ if (iButton == LGLCDBUTTON_BUTTON1 || iButton == LGLCDBUTTON_DOWN) {
m_MessageText.ScrollDown();
- } else if(iButton == LGLCDBUTTON_BUTTON0 || iButton == LGLCDBUTTON_UP) {
+ }
+ else if (iButton == LGLCDBUTTON_BUTTON0 || iButton == LGLCDBUTTON_UP) {
m_MessageText.ScrollUp();
}
- SetExpiration(CConfig::GetIntSetting(NOTIFY_DURATION)*1000);
- }
+ SetExpiration(CConfig::GetIntSetting(NOTIFY_DURATION) * 1000);
+ }
}
//************************************************************************
@@ -319,14 +305,15 @@ void CNotificationScreen::OnLCDButtonDown(int iButton) //************************************************************************
void CNotificationScreen::OnLCDButtonRepeated(int iButton)
{
- CScreen::OnLCDButtonDown(iButton);
- if(m_MessageText.IsVisible()) {
- if(iButton == LGLCDBUTTON_BUTTON1 || iButton == LGLCDBUTTON_DOWN) {
+ CScreen::OnLCDButtonDown(iButton);
+ if (m_MessageText.IsVisible()) {
+ if (iButton == LGLCDBUTTON_BUTTON1 || iButton == LGLCDBUTTON_DOWN) {
m_MessageText.ScrollDown();
- } else if(iButton == LGLCDBUTTON_BUTTON0 || iButton == LGLCDBUTTON_UP) {
+ }
+ else if (iButton == LGLCDBUTTON_BUTTON0 || iButton == LGLCDBUTTON_UP) {
m_MessageText.ScrollUp();
}
- SetExpiration(CConfig::GetIntSetting(NOTIFY_DURATION)*1000);
+ SetExpiration(CConfig::GetIntSetting(NOTIFY_DURATION) * 1000);
}
}
@@ -335,7 +322,6 @@ void CNotificationScreen::OnLCDButtonRepeated(int iButton) //************************************************************************
void CNotificationScreen::OnLCDButtonUp(int)
{
-
}
//************************************************************************
@@ -343,7 +329,6 @@ void CNotificationScreen::OnLCDButtonUp(int) //************************************************************************
void CNotificationScreen::OnActivation()
{
-
}
//************************************************************************
@@ -360,8 +345,7 @@ void CNotificationScreen::OnExpiration() {
// clear the cached events
CNotificationEntry *pEntry = nullptr;
- while(!m_LNotifications.empty())
- {
+ while (!m_LNotifications.empty()) {
pEntry = *(m_LNotifications.begin());
m_LNotifications.pop_front();
delete pEntry;
@@ -371,4 +355,4 @@ void CNotificationScreen::OnExpiration() m_MessageText.SetText(L"");
m_pEntry = nullptr;
-}
\ No newline at end of file +}
diff --git a/plugins/MirandaG15/src/CNotificationScreen.h b/plugins/MirandaG15/src/CNotificationScreen.h index f5142c554c..21038450ba 100644 --- a/plugins/MirandaG15/src/CNotificationScreen.h +++ b/plugins/MirandaG15/src/CNotificationScreen.h @@ -79,17 +79,9 @@ private: CLCDLabel m_TitleText;
CLCDLabel m_Timestamp;
CLCDBar m_Scrollbar;
- //CLCDInput m_Input;
// Contact off the current event
- CNotificationEntry *m_pEntry;
-
- // message mode variables
- /*
- bool m_bMessageMode;
- enum { REPLY_STATE_NONE,REPLY_STATE_INPUT,REPLY_STATE_SENDING,REPLY_STATE_FAILED} m_eReplyState;
- HANDLE m_hMessage;
- */
+ CNotificationEntry *m_pEntry = nullptr;
};
-#endif
\ No newline at end of file +#endif
diff --git a/plugins/MirandaG15/src/CScreen.cpp b/plugins/MirandaG15/src/CScreen.cpp index 90d053ed23..abb3122104 100644 --- a/plugins/MirandaG15/src/CScreen.cpp +++ b/plugins/MirandaG15/src/CScreen.cpp @@ -21,24 +21,24 @@ CScreen::~CScreen() //************************************************************************
bool CScreen::Initialize()
{
- if(!CLCDScreen::Initialize())
+ if (!CLCDScreen::Initialize())
return false;
// initialize the four button labels
- for (int i = 0; i < 4; i++)
- {
- m_aButtons[i].Initialize();
- m_aButtons[i].SetSize(17, 3);
- m_aButtons[i].Show(0);
+ for (int i = 0; i < 4; i++) {
+ m_aButtons[i].Initialize();
+ m_aButtons[i].SetSize(17, 3);
+ m_aButtons[i].Show(0);
m_abShowButtons[i] = false;
m_ahBitmaps[i] = nullptr;
- if(GetWidth() == 160) {
- m_aButtons[i].SetOrigin(10+i*29+(i/2)*36, GetHeight()-3);
- } else {
- m_aButtons[i].SetOrigin((280/4)*(i+0.5f) + (i/2)*40, GetHeight()-3);
+ if (GetWidth() == 160) {
+ m_aButtons[i].SetOrigin(10 + i * 29 + (i / 2) * 36, GetHeight() - 3);
+ }
+ else {
+ m_aButtons[i].SetOrigin((280 / 4)*(i + 0.5f) + (i / 2) * 40, GetHeight() - 3);
}
AddObject(&m_aButtons[i]);
- }
+ }
/*
m_Clock.Initialize();
@@ -61,11 +61,11 @@ bool CScreen::Initialize() //************************************************************************
bool CScreen::Shutdown()
{
- if(!CLCDScreen::Shutdown())
+ if (!CLCDScreen::Shutdown())
return false;
-
- for(int i=0; i < 4; i++)
- if(m_ahBitmaps[i] != nullptr)
+
+ for (int i = 0; i < 4; i++)
+ if (m_ahBitmaps[i] != nullptr)
DeleteObject(m_ahBitmaps[i]);
return true;
@@ -76,7 +76,7 @@ bool CScreen::Shutdown() //************************************************************************
bool CScreen::Update()
{
- if(!CLCDScreen::Update())
+ if (!CLCDScreen::Update())
return false;
return true;
@@ -87,13 +87,12 @@ bool CScreen::Update() //************************************************************************
bool CScreen::Draw(CLCDGfx *pGfx)
{
- if(!CLCDScreen::Draw(pGfx))
+ if (!CLCDScreen::Draw(pGfx))
return false;
-
- for(int i=0;i<4;i++)
- if(m_aButtons[i].IsVisible())
- {
- pGfx->DrawLine(0,GetHeight()-5,GetWidth(),GetHeight()-5);
+
+ for (int i = 0; i < 4; i++)
+ if (m_aButtons[i].IsVisible()) {
+ pGfx->DrawLine(0, GetHeight() - 5, GetWidth(), GetHeight() - 5);
break;
}
@@ -105,23 +104,21 @@ bool CScreen::Draw(CLCDGfx *pGfx) //************************************************************************
void CScreen::SetButtonBitmap(int iButton, int iBitmap)
{
- if(iButton <0 || iButton > 3)
+ if (iButton < 0 || iButton > 3)
return;
- if(iBitmap == 0)
- {
+ if (iBitmap == 0) {
m_aButtons[iButton].Show(0);
m_abShowButtons[iButton] = false;
}
- else
- {
- if(m_ahBitmaps[iButton] != nullptr)
+ else {
+ if (m_ahBitmaps[iButton] != nullptr)
DeleteObject(m_ahBitmaps[iButton]);
m_ahBitmaps[iButton] = (HBITMAP)LoadImage(g_plugin.getInst(), MAKEINTRESOURCE(iBitmap),
- IMAGE_BITMAP,17, 3, LR_MONOCHROME);
+ IMAGE_BITMAP, 17, 3, LR_MONOCHROME);
m_aButtons[iButton].SetBitmap(m_ahBitmaps[iButton]);
- if(CConfig::GetBoolSetting(SHOW_LABELS))
+ if (CConfig::GetBoolSetting(SHOW_LABELS))
m_aButtons[iButton].Show(1);
m_abShowButtons[iButton] = true;
}
@@ -141,15 +138,15 @@ void CScreen::ShowButtons(bool bShow) //************************************************************************
void CScreen::UpdateButtons()
{
- for (int i = 0; i < 4; i++)
- {
- if(GetWidth() == 160) {
- m_aButtons[i].SetOrigin(10+i*29+(i/2)*36, GetHeight()-3);
- } else {
- m_aButtons[i].SetOrigin((280/4)*(i+0.5f) + (i/2)*40, GetHeight()-3);
+ for (int i = 0; i < 4; i++) {
+ if (GetWidth() == 160) {
+ m_aButtons[i].SetOrigin(10 + i * 29 + (i / 2) * 36, GetHeight() - 3);
+ }
+ else {
+ m_aButtons[i].SetOrigin((280 / 4)*(i + 0.5f) + (i / 2) * 40, GetHeight() - 3);
}
-
- if(m_abShowButtons[i])
+
+ if (m_abShowButtons[i])
m_aButtons[i].Show(CConfig::GetBoolSetting(SHOW_LABELS) && !m_bHideButtons);
}
}
@@ -172,8 +169,9 @@ void CScreen::OnConfigChanged() //************************************************************************
// Called when the screens size has changed
//************************************************************************
-void CScreen::OnSizeChanged() {
+void CScreen::OnSizeChanged()
+{
CLCDScreen::OnSizeChanged();
UpdateButtons();
-}
\ No newline at end of file +}
diff --git a/plugins/MirandaG15/src/CScreen.h b/plugins/MirandaG15/src/CScreen.h index 9bcb6ef589..c9f1853146 100644 --- a/plugins/MirandaG15/src/CScreen.h +++ b/plugins/MirandaG15/src/CScreen.h @@ -3,7 +3,6 @@ #include "LCDFramework/CLCDScreen.h"
#include "LCDFramework/CLCDBitmap.h"
-//#include "CLCDLabel.h"
class CScreen : public CLCDScreen
{
@@ -44,4 +43,4 @@ private: void UpdateButtons();
};
-#endif
\ No newline at end of file +#endif
diff --git a/plugins/MirandaG15/src/CScreensaverScreen.cpp b/plugins/MirandaG15/src/CScreensaverScreen.cpp index 0ba40da901..492274a2cc 100644 --- a/plugins/MirandaG15/src/CScreensaverScreen.cpp +++ b/plugins/MirandaG15/src/CScreensaverScreen.cpp @@ -5,8 +5,7 @@ //************************************************************************
// Constructor
//************************************************************************
-CScreensaverScreen::CScreensaverScreen() : m_dwActivation(0),
- m_dwDuration(0), m_iPosition(0)
+CScreensaverScreen::CScreensaverScreen()
{
}
@@ -22,7 +21,7 @@ CScreensaverScreen::~CScreensaverScreen() //************************************************************************
bool CScreensaverScreen::Initialize()
{
- if(!CScreen::Initialize())
+ if (!CScreen::Initialize())
return false;
m_Label.Initialize();
@@ -34,24 +33,21 @@ bool CScreensaverScreen::Initialize() m_Label.SetFontFaceName(L"Microsoft Sans Serif");
m_Label.SetFontPointSize(10);
m_Label.SetFontWeight(FW_BOLD);
-
+
m_Label2.SetAlignment(DT_CENTER);
m_Label2.SetWordWrap(TRUE);
m_Label2.SetText(L"");
m_Label2.SetFontFaceName(L"Microsoft Sans Serif");
m_Label2.SetFontPointSize(8);
- m_Label.SetOrigin(0,0);
- m_Label.SetSize(GetWidth(),20);
+ m_Label.SetOrigin(0, 0);
+ m_Label.SetSize(GetWidth(), 20);
- m_Label2.SetOrigin(0,23);
- m_Label2.SetSize(GetWidth(),20);
-
-
+ m_Label2.SetOrigin(0, 23);
+ m_Label2.SetSize(GetWidth(), 20);
AddObject(&m_Label);
AddObject(&m_Label2);
-
return true;
}
@@ -60,7 +56,7 @@ bool CScreensaverScreen::Initialize() //************************************************************************
bool CScreensaverScreen::Shutdown()
{
- if(!CScreen::Shutdown())
+ if (!CScreen::Shutdown())
return false;
return true;
@@ -71,19 +67,17 @@ bool CScreensaverScreen::Shutdown() //************************************************************************
bool CScreensaverScreen::Update()
{
- if(!CScreen::Update())
+ if (!CScreen::Update())
return false;
DWORD dwTimeElapsed = GetTickCount() - m_dwActivation;
int iOldPosition = m_iPosition;
- if(dwTimeElapsed > m_dwDuration)
- {
+ if (dwTimeElapsed > m_dwDuration) {
m_dwDuration = 4000;
m_Label.SetText(L"");
m_Label2.SetText(L"");
- switch(m_iPosition)
- {
+ switch (m_iPosition) {
case 0:
m_Label.SetFontPointSize(8);
m_Label.SetText(L"MirandaG15");
@@ -97,7 +91,7 @@ bool CScreensaverScreen::Update() m_dwDuration = 1800;
m_iPosition = -1;
break;
-
+
default:
CAppletManager::GetInstance()->ActivateEventScreen();
return true;
@@ -105,10 +99,10 @@ bool CScreensaverScreen::Update() m_iPosition++;
CAppletManager::GetInstance()->StartTransition(TRANSITION_MORPH);
}
-
- if(m_iPosition != iOldPosition)
+
+ if (m_iPosition != iOldPosition)
m_dwActivation = GetTickCount();
-
+
return true;
}
@@ -119,7 +113,7 @@ void CScreensaverScreen::Reset() {
m_dwDuration = 0;
m_iPosition = 0;
-
+
m_Label.SetFontPointSize(10);
m_Label.SetText(L"");
@@ -134,7 +128,7 @@ void CScreensaverScreen::Reset() //************************************************************************
bool CScreensaverScreen::Draw(CLCDGfx *pGfx)
{
- if(!CScreen::Draw(pGfx))
+ if (!CScreen::Draw(pGfx))
return false;
return true;
diff --git a/plugins/MirandaG15/src/CScreensaverScreen.h b/plugins/MirandaG15/src/CScreensaverScreen.h index 4a42df56ea..9390df47b5 100644 --- a/plugins/MirandaG15/src/CScreensaverScreen.h +++ b/plugins/MirandaG15/src/CScreensaverScreen.h @@ -42,10 +42,10 @@ public: void Reset();
private:
- CLCDLabel m_Label,m_Label2;
- DWORD m_dwActivation;
- DWORD m_dwDuration;
- int m_iPosition;
+ CLCDLabel m_Label, m_Label2;
+ DWORD m_dwActivation = 0;
+ DWORD m_dwDuration = 0;
+ int m_iPosition = 0;
};
-#endif
\ No newline at end of file +#endif
diff --git a/plugins/MirandaG15/src/LCDFramework/CLCDBar.cpp b/plugins/MirandaG15/src/LCDFramework/CLCDBar.cpp index f5701edd35..ea6e6d0651 100644 --- a/plugins/MirandaG15/src/LCDFramework/CLCDBar.cpp +++ b/plugins/MirandaG15/src/LCDFramework/CLCDBar.cpp @@ -8,13 +8,6 @@ //************************************************************************
CLCDBar::CLCDBar()
{
- m_iSliderSize = 0;
- m_iPosition = 0;
- m_iMin = 0;
- m_iMax = 0;
- m_iMode = MODE_SCROLLBAR;
- m_iOrientation = DIRECTION_VERTICAL;
- m_iAlignment = TOP;
}
//************************************************************************
@@ -61,8 +54,7 @@ void CLCDBar::SetOrientation(int iOrientation) //************************************************************************
bool CLCDBar::ScrollDown()
{
- if(m_iPosition < m_iMax)
- {
+ if (m_iPosition < m_iMax) {
m_iPosition++;
return true;
}
@@ -74,8 +66,7 @@ bool CLCDBar::ScrollDown() //************************************************************************
bool CLCDBar::ScrollUp()
{
- if(m_iPosition > m_iMin)
- {
+ if (m_iPosition > m_iMin) {
m_iPosition--;
return true;
}
@@ -87,8 +78,7 @@ bool CLCDBar::ScrollUp() //************************************************************************
bool CLCDBar::ScrollTo(int iPosition)
{
- if(iPosition >= m_iMin && iPosition <= m_iMax)
- {
+ if (iPosition >= m_iMin && iPosition <= m_iMax) {
m_iPosition = iPosition;
return true;
}
@@ -126,9 +116,9 @@ void CLCDBar::SetRange(int iMin, int iMax) {
m_iMin = iMin;
m_iMax = iMax;
- if(m_iPosition < m_iMin)
+ if (m_iPosition < m_iMin)
m_iPosition = m_iMin;
- else if(m_iPosition > m_iMax )
+ else if (m_iPosition > m_iMax)
m_iPosition = m_iMax;
}
@@ -137,56 +127,51 @@ void CLCDBar::SetRange(int iMin, int iMax) //************************************************************************
bool CLCDBar::Draw(CLCDGfx *pGfx)
{
- if((m_iMode != MODE_SCROLLBAR || m_iSliderSize > 0) && m_iMax >= m_iMin)
- {
+ if ((m_iMode != MODE_SCROLLBAR || m_iSliderSize > 0) && m_iMax >= m_iMin) {
// draw border
- pGfx->DrawRect(0,0,GetWidth(),GetHeight());
-
+ pGfx->DrawRect(0, 0, GetWidth(), GetHeight());
+
// initialize variables
- int iSize = (m_iMax - m_iMin)+1;
+ int iSize = (m_iMax - m_iMin) + 1;
int iPosition = m_iPosition - m_iMin;
- int iPixels = m_iOrientation == DIRECTION_VERTICAL?GetHeight():GetWidth();
- int iFirst=0,iLast=0;
+ int iPixels = m_iOrientation == DIRECTION_VERTICAL ? GetHeight() : GetWidth();
+ int iFirst = 0, iLast = 0;
// generate scrollbar offsets
- if(m_iMode == MODE_SCROLLBAR)
- {
+ if (m_iMode == MODE_SCROLLBAR) {
int iOffset = iPosition;
- if(m_iSliderSize >= 2)
- {
- switch(m_iAlignment)
- {
+ if (m_iSliderSize >= 2) {
+ switch (m_iAlignment) {
case CENTER:
- iOffset -= (m_iSliderSize-1)/2;
+ iOffset -= (m_iSliderSize - 1) / 2;
break;
case BOTTOM:
- iOffset -= (m_iSliderSize-1);
+ iOffset -= (m_iSliderSize - 1);
break;
case TOP:
break;
}
- if(iOffset < 0)
+ if (iOffset < 0)
iOffset = 0;
}
int iEnd = iOffset + m_iSliderSize;
- if(iEnd > iSize)
+ if (iEnd > iSize)
iEnd = iSize;
- iFirst = iPixels*((float)iOffset/(float)iSize);
- iLast = iPixels*((float)iEnd/(float)iSize);
+ iFirst = iPixels * ((float)iOffset / (float)iSize);
+ iLast = iPixels * ((float)iEnd / (float)iSize);
}
// generate progressbar offsets
- else if(m_iMode == MODE_PROGRESSBAR)
- {
+ else if (m_iMode == MODE_PROGRESSBAR) {
iFirst = 1;
- iLast = iPixels*((float)iPosition/(float)iSize);
+ iLast = iPixels * ((float)iPosition / (float)iSize);
}
// draw the bar
- if(m_iOrientation == DIRECTION_VERTICAL)
- pGfx->DrawFilledRect(1,iFirst,GetWidth()-1,iLast-iFirst);
+ if (m_iOrientation == DIRECTION_VERTICAL)
+ pGfx->DrawFilledRect(1, iFirst, GetWidth() - 1, iLast - iFirst);
else
- pGfx->DrawFilledRect(iFirst,1,iLast-iFirst,GetHeight()-1);
+ pGfx->DrawFilledRect(iFirst, 1, iLast - iFirst, GetHeight() - 1);
}
return true;
-}
\ No newline at end of file +}
diff --git a/plugins/MirandaG15/src/LCDFramework/CLCDBar.h b/plugins/MirandaG15/src/LCDFramework/CLCDBar.h index 1afb446132..29b358608e 100644 --- a/plugins/MirandaG15/src/LCDFramework/CLCDBar.h +++ b/plugins/MirandaG15/src/LCDFramework/CLCDBar.h @@ -18,7 +18,7 @@ public: CLCDBar();
// destructor
~CLCDBar();
-
+
// initializes the bar
bool Initialize();
// deintializes the bar
@@ -38,7 +38,7 @@ public: void SetAlignment(int iAlignment);
// sets the size of the slider
void SetSliderSize(int iSize);
-
+
// scrolls up/left
bool ScrollUp();
inline bool ScrollLeft() { return ScrollUp(); };
@@ -49,16 +49,16 @@ public: // scrolls to the specified position
bool ScrollTo(int iPosition);
// specifies the bar's range
- void SetRange(int iMin,int iMax);
+ void SetRange(int iMin, int iMax);
private:
- int m_iOrientation;
- int m_iMode;
- int m_iSliderSize;
- int m_iMax;
- int m_iMin;
- int m_iPosition;
- int m_iAlignment;
+ int m_iOrientation = DIRECTION_VERTICAL;
+ int m_iMode = MODE_SCROLLBAR;
+ int m_iSliderSize = 0;
+ int m_iMax = 0;
+ int m_iMin = 0;
+ int m_iPosition = 0;
+ int m_iAlignment = TOP;
};
-#endif
\ No newline at end of file +#endif
diff --git a/plugins/MirandaG15/src/LCDFramework/CLCDBitmap.cpp b/plugins/MirandaG15/src/LCDFramework/CLCDBitmap.cpp index b9aadd3bfc..7fdb18866a 100644 --- a/plugins/MirandaG15/src/LCDFramework/CLCDBitmap.cpp +++ b/plugins/MirandaG15/src/LCDFramework/CLCDBitmap.cpp @@ -3,7 +3,6 @@ CLCDBitmap::CLCDBitmap()
{
- m_hBitmap = nullptr;
}
CLCDBitmap::~CLCDBitmap()
@@ -27,22 +26,21 @@ bool CLCDBitmap::Update() bool CLCDBitmap::Draw(CLCDGfx *pGfx)
{
- if(m_hBitmap)
- {
- HDC hCompatibleDC = CreateCompatibleDC(pGfx->GetHDC());
- HBITMAP hOldBitmap = (HBITMAP)SelectObject(hCompatibleDC, m_hBitmap);
-
- BitBlt(pGfx->GetHDC(), 0, 0, GetWidth(), GetHeight(), hCompatibleDC, 0, 0, SRCCOPY);
-
- // restores
- SelectObject(hCompatibleDC, hOldBitmap);
- DeleteDC(hCompatibleDC);
- }
+ if (m_hBitmap) {
+ HDC hCompatibleDC = CreateCompatibleDC(pGfx->GetHDC());
+ HBITMAP hOldBitmap = (HBITMAP)SelectObject(hCompatibleDC, m_hBitmap);
+
+ BitBlt(pGfx->GetHDC(), 0, 0, GetWidth(), GetHeight(), hCompatibleDC, 0, 0, SRCCOPY);
+
+ // restores
+ SelectObject(hCompatibleDC, hOldBitmap);
+ DeleteDC(hCompatibleDC);
+ }
return true;
}
void CLCDBitmap::SetBitmap(HBITMAP hBitmap)
{
- ASSERT(nullptr != hBitmap);
- m_hBitmap = hBitmap;
-}
\ No newline at end of file + ASSERT(nullptr != hBitmap);
+ m_hBitmap = hBitmap;
+}
diff --git a/plugins/MirandaG15/src/LCDFramework/CLCDBitmap.h b/plugins/MirandaG15/src/LCDFramework/CLCDBitmap.h index d8c7813b81..4eaabe756d 100644 --- a/plugins/MirandaG15/src/LCDFramework/CLCDBitmap.h +++ b/plugins/MirandaG15/src/LCDFramework/CLCDBitmap.h @@ -6,6 +6,8 @@ class CLCDBitmap : public CLCDObject
{
+ HBITMAP m_hBitmap = nullptr;
+
public:
// constructor
CLCDBitmap();
@@ -24,8 +26,6 @@ public: // Sets the bitmap
void SetBitmap(HBITMAP hBitmap);
-private:
- HBITMAP m_hBitmap;
};
#endif
\ No newline at end of file diff --git a/plugins/MirandaG15/src/LCDFramework/CLCDConnection.cpp b/plugins/MirandaG15/src/LCDFramework/CLCDConnection.cpp index 929f801d8e..084722b8cf 100644 --- a/plugins/MirandaG15/src/LCDFramework/CLCDConnection.cpp +++ b/plugins/MirandaG15/src/LCDFramework/CLCDConnection.cpp @@ -6,7 +6,6 @@ //************************************************************************
CLCDConnection::CLCDConnection()
{
- m_bReconnect = true;
}
//************************************************************************
@@ -59,7 +58,8 @@ bool CLCDConnection::GetButtonState(int) //************************************************************************
// returns the id of the specified button
//************************************************************************
-int CLCDConnection::GetButtonId(int) {
+int CLCDConnection::GetButtonId(int)
+{
return 0;
}
@@ -147,7 +147,7 @@ CLCDDevice* CLCDConnection::GetAttachedDevice(int) //************************************************************************
// Connects to the specified LCD
//************************************************************************
-bool CLCDConnection::Connect(int )
+bool CLCDConnection::Connect(int)
{
return false;
}
@@ -174,4 +174,4 @@ void CLCDConnection::SetReconnect(bool bSet) CLCDDevice* CLCDConnection::GetConnectedDevice()
{
return nullptr;
-}
\ No newline at end of file +}
diff --git a/plugins/MirandaG15/src/LCDFramework/CLCDConnection.h b/plugins/MirandaG15/src/LCDFramework/CLCDConnection.h index 099f850ec9..9c17b81d75 100644 --- a/plugins/MirandaG15/src/LCDFramework/CLCDConnection.h +++ b/plugins/MirandaG15/src/LCDFramework/CLCDConnection.h @@ -11,19 +11,19 @@ class CLCDConnection
{
protected:
- bool m_bReconnect;
-
+ bool m_bReconnect = true;
+
public:
// returns the connection type
- virtual int GetConnectionType()=0;
-
+ virtual int GetConnectionType() = 0;
+
// returns a pointer to a vector of LCDDevices
virtual CLCDDevice* GetAttachedDevice(int iIndex);
// returns a pointer to the current device
virtual CLCDDevice* GetConnectedDevice();
// Initializes the connection to the LCD
- virtual bool Initialize(tstring strAppletName,bool bAutostart = false, bool bConfigDialog = false);
+ virtual bool Initialize(tstring strAppletName, bool bAutostart = false, bool bConfigDialog = false);
// Connects to the specified LCD
virtual bool Connect(int iIndex = 0);
@@ -41,7 +41,7 @@ public: virtual bool Draw();
// Hides the applet
virtual bool HideApplet();
-
+
// returns the connections state
virtual int GetConnectionState();
@@ -71,4 +71,4 @@ public: virtual ~CLCDConnection();
};
-#endif
\ No newline at end of file +#endif
diff --git a/plugins/MirandaG15/src/LCDFramework/CLCDConnectionLogitech.cpp b/plugins/MirandaG15/src/LCDFramework/CLCDConnectionLogitech.cpp index f704f1ee08..300bc365e2 100644 --- a/plugins/MirandaG15/src/LCDFramework/CLCDConnectionLogitech.cpp +++ b/plugins/MirandaG15/src/LCDFramework/CLCDConnectionLogitech.cpp @@ -2,9 +2,8 @@ #include "CLCDConnectionLogitech.h"
#include "CLCDOutputManager.h"
-DWORD WINAPI softButtonCallback(IN int,
- IN DWORD dwButtons,
- IN const PVOID pContext) {
+DWORD WINAPI softButtonCallback(IN int, IN DWORD dwButtons, IN const PVOID pContext)
+{
((CLCDConnectionLogitech*)pContext)->OnSoftButtonCB(dwButtons);
return 0;
}
@@ -15,7 +14,8 @@ DWORD WINAPI notificationCallback(IN int, IN DWORD notifyParm1,
IN DWORD notifyParm2,
IN DWORD notifyParm3,
- IN DWORD notifyParm4) {
+ IN DWORD notifyParm4)
+{
((CLCDConnectionLogitech*)pContext)->OnNotificationCB(notificationCode, notifyParm1, notifyParm2, notifyParm3, notifyParm4);
return 0;
}
@@ -26,14 +26,15 @@ void __cdecl initializeDrawingThread(CLCDConnectionLogitech *pParam) pParam->runDrawingThread();
}
-void CLCDConnectionLogitech::runDrawingThread() {
+void CLCDConnectionLogitech::runDrawingThread()
+{
m_hStopEvent = CreateEvent(nullptr, FALSE, FALSE, nullptr);
m_hDrawEvent = CreateEvent(nullptr, FALSE, FALSE, nullptr);
DWORD dwRes = 0;
while (1) {
- HANDLE hArray[2] = { m_hStopEvent, m_hDrawEvent };
+ HANDLE hArray[2] = {m_hStopEvent, m_hDrawEvent};
dwRes = WaitForMultipleObjects(2, hArray, FALSE, INFINITE);
if (dwRes == WAIT_OBJECT_0) {
break;
@@ -45,12 +46,10 @@ void CLCDConnectionLogitech::runDrawingThread() { }
// do a sync update if the applet is in the foreground, or every 500 ms
// the delay is there because sync updates can take up to 33ms to fail
- if (m_dwForegroundCheck < GetTickCount())
- {
+ if (m_dwForegroundCheck < GetTickCount()) {
m_dwForegroundCheck = GetTickCount() + 500;
rc = lgLcdUpdateBitmap(m_hDevice, &m_lcdBitmap.hdr, LGLCD_SYNC_COMPLETE_WITHIN_FRAME(m_iPriority));
- if (rc == ERROR_ACCESS_DENIED)
- {
+ if (rc == ERROR_ACCESS_DENIED) {
rc = ERROR_SUCCESS;
m_bIsForeground = false;
}
@@ -119,7 +118,8 @@ CLCDConnectionLogitech::~CLCDConnectionLogitech() {
do {
SetEvent(m_hStopEvent);
- } while (WaitForSingleObject(m_hDrawingThread, 500) == WAIT_TIMEOUT);
+ }
+ while (WaitForSingleObject(m_hDrawingThread, 500) == WAIT_TIMEOUT);
if (m_pDrawingBuffer != nullptr) {
free(m_pDrawingBuffer);
@@ -164,7 +164,8 @@ bool CLCDConnectionLogitech::Initialize(tstring strAppletName, bool bAutostart, //************************************************************************
// returns the name of the attached device
//************************************************************************
-tstring CLCDConnectionLogitech::GetDeviceName() {
+tstring CLCDConnectionLogitech::GetDeviceName()
+{
if (m_pConnectedDevice->GetIndex() == LGLCD_DEVICE_BW) {
return L"G15/Z10";
}
@@ -176,7 +177,8 @@ tstring CLCDConnectionLogitech::GetDeviceName() { //************************************************************************
// enumerates all attached devices
//************************************************************************
-CLgLCDDevice* CLCDConnectionLogitech::GetAttachedDevice(int iIndex) {
+CLgLCDDevice* CLCDConnectionLogitech::GetAttachedDevice(int iIndex)
+{
std::vector<CLgLCDDevice*>::iterator i = m_lcdDevices.begin();
for (; i != m_lcdDevices.end(); i++) {
if ((*i)->GetIndex() == iIndex) {
@@ -190,7 +192,8 @@ CLgLCDDevice* CLCDConnectionLogitech::GetAttachedDevice(int iIndex) { //************************************************************************
// disconnects the device
//************************************************************************
-bool CLCDConnectionLogitech::Disconnect() {
+bool CLCDConnectionLogitech::Disconnect()
+{
if (!m_bConnected)
return false;
@@ -214,7 +217,8 @@ bool CLCDConnectionLogitech::Disconnect() { //************************************************************************
// returns a pointer to the current device
//************************************************************************
-CLgLCDDevice* CLCDConnectionLogitech::GetConnectedDevice() {
+CLgLCDDevice* CLCDConnectionLogitech::GetConnectedDevice()
+{
return m_pConnectedDevice;
}
@@ -228,12 +232,10 @@ bool CLCDConnectionLogitech::Connect(int iIndex) if (m_bConnected && (iIndex == 0 || iIndex == GetConnectedDevice()->GetIndex()))
return true;
- if (m_hConnection == LGLCD_INVALID_CONNECTION)
- {
+ if (m_hConnection == LGLCD_INVALID_CONNECTION) {
rc = lgLcdConnectEx(&m_connectContext);
// establish the connection
- if (ERROR_SUCCESS == rc)
- {
+ if (ERROR_SUCCESS == rc) {
m_hConnection = m_connectContext.connection;
m_hDevice = LGLCD_INVALID_CONNECTION;
@@ -321,7 +323,8 @@ bool CLCDConnectionLogitech::Shutdown() //************************************************************************
// Reads data from the keyboard HID device
//************************************************************************
-bool CLCDConnectionLogitech::HIDReadData(BYTE* data) {
+bool CLCDConnectionLogitech::HIDReadData(BYTE* data)
+{
static OVERLAPPED olRead;
static HANDLE hReadEvent = CreateEvent(nullptr, false, true, L"ReadEvent");
static BYTE privateBuffer[9];
@@ -355,56 +358,60 @@ bool CLCDConnectionLogitech::HIDReadData(BYTE* data) { return false;
}
-void CLCDConnectionLogitech::OnSoftButtonCB(DWORD state) {
+void CLCDConnectionLogitech::OnSoftButtonCB(DWORD state)
+{
m_dwButtonState = state;
}
-void CLCDConnectionLogitech::OnNotificationCB(DWORD notificationCode, DWORD notifyParm1, DWORD, DWORD, DWORD) {
+void CLCDConnectionLogitech::OnNotificationCB(DWORD notificationCode, DWORD notifyParm1, DWORD, DWORD, DWORD)
+{
CLgLCDDevice *device;
switch (notificationCode) {
- case LGLCD_NOTIFICATION_DEVICE_ARRIVAL: {
- int *counter = notifyParm1 == LGLCD_DEVICE_QVGA ? &m_iNumQVGADevices : &m_iNumBWDevices;
- if (*counter == 0) {
- SIZE size;
- if (notifyParm1 == LGLCD_DEVICE_QVGA) {
- size.cx = 320;
- size.cy = 240;
- device = new CLgLCDDevice(notifyParm1, size, 7, 4);
- }
- else {
- size.cx = 160;
- size.cy = 43;
- device = new CLgLCDDevice(notifyParm1, size, 4, 1);
+ case LGLCD_NOTIFICATION_DEVICE_ARRIVAL:
+ {
+ int *counter = notifyParm1 == LGLCD_DEVICE_QVGA ? &m_iNumQVGADevices : &m_iNumBWDevices;
+ if (*counter == 0) {
+ SIZE size;
+ if (notifyParm1 == LGLCD_DEVICE_QVGA) {
+ size.cx = 320;
+ size.cy = 240;
+ device = new CLgLCDDevice(notifyParm1, size, 7, 4);
+ }
+ else {
+ size.cx = 160;
+ size.cy = 43;
+ device = new CLgLCDDevice(notifyParm1, size, 4, 1);
+ }
+ m_lcdDevices.push_back(device);
}
- m_lcdDevices.push_back(device);
- }
- (*counter)++;
- break;
- }
- case LGLCD_NOTIFICATION_DEVICE_REMOVAL: {
- int *counter = notifyParm1 == LGLCD_DEVICE_QVGA ? &m_iNumQVGADevices : &m_iNumBWDevices;
- (*counter)--;
- if (*counter == 0) {
- std::vector<CLgLCDDevice*>::iterator i = m_lcdDevices.begin();
- for (; i != m_lcdDevices.end(); i++) {
- if ((*i)->GetIndex() == notifyParm1) {
- device = *i;
-
- if (device == m_pConnectedDevice) {
- HandleErrorFromAPI(ERROR_DEVICE_NOT_CONNECTED);
+ (*counter)++;
+ break;
+ }
+ case LGLCD_NOTIFICATION_DEVICE_REMOVAL:
+ {
+ int *counter = notifyParm1 == LGLCD_DEVICE_QVGA ? &m_iNumQVGADevices : &m_iNumBWDevices;
+ (*counter)--;
+ if (*counter == 0) {
+ std::vector<CLgLCDDevice*>::iterator i = m_lcdDevices.begin();
+ for (; i != m_lcdDevices.end(); i++) {
+ if ((*i)->GetIndex() == notifyParm1) {
+ device = *i;
+
+ if (device == m_pConnectedDevice) {
+ HandleErrorFromAPI(ERROR_DEVICE_NOT_CONNECTED);
+ }
+
+ m_lcdDevices.erase(i);
+ delete device;
+
+ break;
}
-
- m_lcdDevices.erase(i);
- delete device;
-
- break;
}
}
+ break;
}
- break;
- }
}
}
@@ -414,8 +421,7 @@ void CLCDConnectionLogitech::OnNotificationCB(DWORD notificationCode, DWORD noti bool CLCDConnectionLogitech::Update()
{
// check for lcd devices
- if (LGLCD_INVALID_DEVICE == m_hDevice)
- {
+ if (LGLCD_INVALID_DEVICE == m_hDevice) {
if (m_bReconnect) {
Connect();
}
@@ -470,10 +476,10 @@ bool CLCDConnectionLogitech::Update() //************************************************************************
// returns the id of the specified button
//************************************************************************
-int CLCDConnectionLogitech::GetButtonId(int iButton) {
+int CLCDConnectionLogitech::GetButtonId(int iButton)
+{
if (m_pConnectedDevice->GetIndex() == LGLCD_DEVICE_BW) {
- switch (iButton)
- {
+ switch (iButton) {
case 0: return LGLCDBUTTON_BUTTON0; break;
case 1: return LGLCDBUTTON_BUTTON1; break;
case 2: return LGLCDBUTTON_BUTTON2; break;
@@ -485,8 +491,7 @@ int CLCDConnectionLogitech::GetButtonId(int iButton) { }
}
else {
- switch (iButton)
- {
+ switch (iButton) {
case 0: return LGLCDBUTTON_LEFT; break;
case 1: return LGLCDBUTTON_RIGHT; break;
case 2: return LGLCDBUTTON_OK; break;
@@ -577,7 +582,7 @@ bool CLCDConnectionLogitech::IsForeground() //************************************************************************
SIZE CLCDConnectionLogitech::GetDisplaySize()
{
- SIZE size = { 0, 0 };
+ SIZE size = {0, 0};
if (!GetConnectionState() == CONNECTED)
return size;
@@ -623,8 +628,7 @@ PBYTE CLCDConnectionLogitech::GetPixelBuffer() //************************************************************************
void CLCDConnectionLogitech::HandleErrorFromAPI(DWORD dwRes)
{
- switch (dwRes)
- {
+ switch (dwRes) {
// all is well
case ERROR_SUCCESS:
break;
@@ -698,7 +702,7 @@ bool CLCDConnectionLogitech::HIDInit() */
hDevInfo = SetupDiGetClassDevs
- (&HidGuid,
+ (&HidGuid,
nullptr,
nullptr,
DIGCF_PRESENT | DIGCF_INTERFACEDEVICE);
@@ -711,8 +715,7 @@ bool CLCDConnectionLogitech::HIDInit() MemberIndex = 0;
LastDevice = FALSE;
- do
- {
+ do {
/*
API function: SetupDiEnumDeviceInterfaces
On return, MyDeviceInterfaceData contains the handle to a
@@ -724,14 +727,13 @@ bool CLCDConnectionLogitech::HIDInit() */
Result = SetupDiEnumDeviceInterfaces
- (hDevInfo,
+ (hDevInfo,
nullptr,
&HidGuid,
MemberIndex,
&devInfoData);
- if (Result != 0)
- {
+ if (Result != 0) {
//A device has been detected, so get more information about it.
/*
@@ -756,7 +758,7 @@ bool CLCDConnectionLogitech::HIDInit() //The call will return with a "buffer too small" error which can be ignored.
Result = SetupDiGetDeviceInterfaceDetail
- (hDevInfo,
+ (hDevInfo,
&devInfoData,
nullptr,
0,
@@ -774,7 +776,7 @@ bool CLCDConnectionLogitech::HIDInit() //Call the function again, this time passing it the returned buffer size.
Result = SetupDiGetDeviceInterfaceDetail
- (hDevInfo,
+ (hDevInfo,
&devInfoData,
detailData,
Length,
@@ -794,7 +796,7 @@ bool CLCDConnectionLogitech::HIDInit() */
m_hHIDDeviceHandle = CreateFile
- (detailData->DevicePath,
+ (detailData->DevicePath,
FILE_GENERIC_READ | FILE_GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE,
nullptr,
@@ -817,16 +819,14 @@ bool CLCDConnectionLogitech::HIDInit() Attributes.Size = sizeof(Attributes);
Result = HidD_GetAttributes
- (m_hHIDDeviceHandle,
+ (m_hHIDDeviceHandle,
&Attributes);
//Is it the desired device?
MyDeviceDetected = FALSE;
- if (Attributes.VendorID == VendorID)
- {
- if (Attributes.ProductID == ProductID)
- {
+ if (Attributes.VendorID == VendorID) {
+ if (Attributes.ProductID == ProductID) {
//Both the Vendor ID and Product ID match.
MyDeviceDetected = TRUE;
}
@@ -848,16 +848,15 @@ bool CLCDConnectionLogitech::HIDInit() } //do
while ((LastDevice == FALSE) && (MyDeviceDetected == FALSE));
- if (MyDeviceDetected)
- {
+ if (MyDeviceDetected) {
PHIDP_PREPARSED_DATA PreparsedData;
HidD_GetPreparsedData
- (m_hHIDDeviceHandle,
+ (m_hHIDDeviceHandle,
&PreparsedData);
HidP_GetCaps
- (PreparsedData,
+ (PreparsedData,
&m_HIDCapabilities);
HidD_FreePreparsedData(PreparsedData);
@@ -907,8 +906,7 @@ SG15LightStatus CLCDConnectionLogitech::GetLightStatus() status.eKBDBrightness = (EKBDBrightness)data[1];
// data[2] = LCD
- switch (data[2])
- {
+ switch (data[2]) {
case 0x02:
status.eLCDBrightness = LCD_ON;
break;
@@ -1008,13 +1006,10 @@ void CLCDConnectionLogitech::SetVolumeWheelHook(bool bEnable) LRESULT CALLBACK CLCDConnectionLogitech::KeyboardHook(int Code, WPARAM wParam, LPARAM lParam)
{
- if (Code == HC_ACTION && wParam == WM_KEYDOWN)
- {
+ if (Code == HC_ACTION && wParam == WM_KEYDOWN) {
KBDLLHOOKSTRUCT *key = reinterpret_cast<KBDLLHOOKSTRUCT *>(lParam);
- if (key->vkCode == VK_VOLUME_UP || key->vkCode == VK_VOLUME_DOWN)
- {
- if (m_pInstance->IsForeground())
- {
+ if (key->vkCode == VK_VOLUME_UP || key->vkCode == VK_VOLUME_DOWN) {
+ if (m_pInstance->IsForeground()) {
if (key->vkCode == VK_VOLUME_UP)
CLCDOutputManager::GetInstance()->OnLCDButtonDown(LGLCDBUTTON_UP);
else if (key->vkCode == VK_VOLUME_DOWN)
@@ -1024,4 +1019,4 @@ LRESULT CALLBACK CLCDConnectionLogitech::KeyboardHook(int Code, WPARAM wParam, L }
}
return CallNextHookEx(m_pInstance->m_hKeyboardHook, Code, wParam, lParam);
-}
\ No newline at end of file +}
diff --git a/plugins/MirandaG15/src/LCDFramework/CLCDConnectionLogitech.h b/plugins/MirandaG15/src/LCDFramework/CLCDConnectionLogitech.h index 631c74121c..38d897e6d9 100644 --- a/plugins/MirandaG15/src/LCDFramework/CLCDConnectionLogitech.h +++ b/plugins/MirandaG15/src/LCDFramework/CLCDConnectionLogitech.h @@ -10,8 +10,8 @@ #define G15_M3_LIGHT 0x04
#define G15_MR_LIGHT 0x08
-enum ELCDBrightness {LCD_ON=0x20,LCD_MEDIUM=0x10,LCD_OFF=0x00};
-enum EKBDBrightness {KBD_ON=0x02,KBD_MEDIUM=0x01,KBD_OFF=0x00};
+enum ELCDBrightness { LCD_ON = 0x20, LCD_MEDIUM = 0x10, LCD_OFF = 0x00 };
+enum EKBDBrightness { KBD_ON = 0x02, KBD_MEDIUM = 0x01, KBD_OFF = 0x00 };
struct SG15LightStatus
@@ -31,10 +31,10 @@ public: // Constructor / Destructor
CLCDConnectionLogitech();
~CLCDConnectionLogitech();
-
+
// returns the name of the attached device
tstring GetDeviceName();
-
+
// returns a pointer to the device with that index
CLgLCDDevice* GetAttachedDevice(int iIndex);
// returns a pointer to the connected device
@@ -44,7 +44,7 @@ public: int GetConnectionState();
// Initializes the connection to the LCD
- bool Initialize(tstring strAppletName,bool bAutostart = false, bool bConfigDialog = false);
+ bool Initialize(tstring strAppletName, bool bAutostart = false, bool bConfigDialog = false);
// connects to the device
bool Connect(int iIndex = 0);
// disconnects to the device
@@ -82,22 +82,22 @@ public: //----------------------------------------------
// Special functions to control the lights
- SG15LightStatus GetLightStatus();
+ SG15LightStatus GetLightStatus();
- void SetMKeyLight(bool bM1,bool bM2,bool bM3,bool bMR);
- void SetLCDBacklight(ELCDBrightness eBrightness);
- void SetKBDBacklight(EKBDBrightness eBrightness);
+ void SetMKeyLight(bool bM1, bool bM2, bool bM3, bool bMR);
+ void SetLCDBacklight(ELCDBrightness eBrightness);
+ void SetKBDBacklight(EKBDBrightness eBrightness);
//----------------------------------------------
//----------------------------------------------
// Special functions for callbacks
- void OnSoftButtonCB(DWORD state);
- void OnNotificationCB( DWORD notificationCode, DWORD notifyParm1, DWORD notifyParm2, DWORD notifyParm3, DWORD notifyParm4);
+ void OnSoftButtonCB(DWORD state);
+ void OnNotificationCB(DWORD notificationCode, DWORD notifyParm1, DWORD notifyParm2, DWORD notifyParm3, DWORD notifyParm4);
//----------------------------------------------
// Special functions for the volume wheel hook
// Activates/Deactivates the volumewheel hook
- void SetVolumeWheelHook(bool bEnable);
- // the keyboard hook callback
- static LRESULT CALLBACK KeyboardHook(int Code, WPARAM wParam, LPARAM lParam);
+ void SetVolumeWheelHook(bool bEnable);
+ // the keyboard hook callback
+ static LRESULT CALLBACK KeyboardHook(int Code, WPARAM wParam, LPARAM lParam);
//----------------------------------------------
void runDrawingThread();
private:
@@ -106,23 +106,23 @@ private: CLgLCDDevice *m_pConnectedDevice;
// the connection instance
static CLCDConnectionLogitech *m_pInstance;
-
+
// HID variables
HANDLE m_hHIDDeviceHandle;
HIDP_CAPS m_HIDCapabilities;
-
+
// HID functions
bool HIDInit();
bool HIDDeInit();
bool HIDReadData(BYTE* data);
-
+
// Keyboard hook
HHOOK m_hKeyboardHook;
bool m_bVolumeWheelHook;
-
+
// handles API Errors
void HandleErrorFromAPI(DWORD dwRes);
-
+
int m_iNumQVGADevices;
int m_iNumBWDevices;
@@ -137,12 +137,13 @@ private: int m_hConnection;
DWORD m_dwButtonState;
int m_iPriority;
-
+
DWORD m_dwForegroundCheck;
bool m_bSetAsForeground;
std::vector<CLgLCDDevice*> m_lcdDevices;
HANDLE m_hDrawingThread;
- HANDLE m_hStopEvent,m_hDrawEvent;
+ HANDLE m_hStopEvent, m_hDrawEvent;
};
-#endif
\ No newline at end of file +
+#endif
diff --git a/plugins/MirandaG15/src/LCDFramework/CLCDDevice.h b/plugins/MirandaG15/src/LCDFramework/CLCDDevice.h index 5d4776e0f5..657b31e999 100644 --- a/plugins/MirandaG15/src/LCDFramework/CLCDDevice.h +++ b/plugins/MirandaG15/src/LCDFramework/CLCDDevice.h @@ -3,17 +3,20 @@ #include "g15sdk/lglcd.h"
-class CLCDDevice {
+class CLCDDevice
+{
private:
int m_iIndex;
protected:
- CLCDDevice(int iIndex) {
+ CLCDDevice(int iIndex)
+ {
m_iIndex = iIndex;
}
public:
- int GetIndex() {
+ int GetIndex()
+ {
return m_iIndex;
}
@@ -27,37 +30,43 @@ public: virtual int GetColorCount() = NULL;
};
-class CLgLCDDevice : public CLCDDevice {
+class CLgLCDDevice : public CLCDDevice
+{
private:
SIZE m_size;
int m_iButtons;
int m_iBPP;
public:
- CLgLCDDevice(DWORD type, SIZE size, int buttons, int BPP) : CLCDDevice(type) {
+ CLgLCDDevice(DWORD type, SIZE size, int buttons, int BPP) : CLCDDevice(type)
+ {
m_size = size;
m_iButtons = buttons;
m_iBPP = BPP;
}
-
+
// Returns the display name
- tstring GetDisplayName() {
- return m_iBPP == 1? L"G15" : L"G19";
+ tstring GetDisplayName()
+ {
+ return m_iBPP == 1 ? L"G15" : L"G19";
}
// Returns the display size
- SIZE GetDisplaySize() {
+ SIZE GetDisplaySize()
+ {
return m_size;
}
// Returns the number of buttons for the display
- int GetButtonCount() {
+ int GetButtonCount()
+ {
return m_iButtons;
}
// Returns the number of available colors
- int GetColorCount() {
+ int GetColorCount()
+ {
return m_iBPP;
}
};
-#endif
\ No newline at end of file +#endif
diff --git a/plugins/MirandaG15/src/LCDFramework/CLCDGfx.cpp b/plugins/MirandaG15/src/LCDFramework/CLCDGfx.cpp index 8dfc6c98e3..7712cf1d36 100644 --- a/plugins/MirandaG15/src/LCDFramework/CLCDGfx.cpp +++ b/plugins/MirandaG15/src/LCDFramework/CLCDGfx.cpp @@ -19,7 +19,7 @@ //************************************************************************
// CLCDGfx::CLCDGfx
//************************************************************************
-CLCDGfx::CLCDGfx(void)
+CLCDGfx::CLCDGfx(void)
{
m_nWidth = 0;
m_nHeight = 0;
@@ -53,22 +53,20 @@ bool CLCDGfx::Initialize(int nWidth, int nHeight, int nBPP, PBYTE pLcdBitmapBits {
m_pLcdBitmapBits = pLcdBitmapBits;
- m_nWidth = nWidth;
- m_nHeight = nHeight;
- m_nBPP = nBPP;
+ m_nWidth = nWidth;
+ m_nHeight = nHeight;
+ m_nBPP = nBPP;
m_hDC = CreateCompatibleDC(nullptr);
- if(nullptr == m_hDC)
- {
+ if (nullptr == m_hDC) {
TRACE(L"CLCDGfx::Initialize(): failed to create compatible DC.\n");
Shutdown();
return false;
}
int nBMISize = sizeof(BITMAPINFO) + 256 * sizeof(RGBQUAD);
- m_pBitmapInfo = (BITMAPINFO *) new BYTE [nBMISize];
- if(nullptr == m_pBitmapInfo)
- {
+ m_pBitmapInfo = (BITMAPINFO *) new BYTE[nBMISize];
+ if (nullptr == m_pBitmapInfo) {
TRACE(L"CLCDGfx::Initialize(): failed to allocate bitmap info.\n");
Shutdown();
return false;
@@ -79,7 +77,7 @@ bool CLCDGfx::Initialize(int nWidth, int nHeight, int nBPP, PBYTE pLcdBitmapBits m_pBitmapInfo->bmiHeader.biWidth = m_nWidth;
m_pBitmapInfo->bmiHeader.biHeight = -m_nHeight;
m_pBitmapInfo->bmiHeader.biPlanes = 1;
- m_pBitmapInfo->bmiHeader.biBitCount = 8*m_nBPP;
+ m_pBitmapInfo->bmiHeader.biBitCount = 8 * m_nBPP;
m_pBitmapInfo->bmiHeader.biCompression = BI_RGB;
m_pBitmapInfo->bmiHeader.biSizeImage = m_pBitmapInfo->bmiHeader.biWidth * m_pBitmapInfo->bmiHeader.biHeight * m_nBPP;
m_pBitmapInfo->bmiHeader.biXPelsPerMeter = 3200;
@@ -87,9 +85,8 @@ bool CLCDGfx::Initialize(int nWidth, int nHeight, int nBPP, PBYTE pLcdBitmapBits m_pBitmapInfo->bmiHeader.biClrUsed = 256;
m_pBitmapInfo->bmiHeader.biClrImportant = 256;
- if(m_nBPP == 1) {
- for(int nColor = 0; nColor < 256; ++nColor)
- {
+ if (m_nBPP == 1) {
+ for (int nColor = 0; nColor < 256; ++nColor) {
m_pBitmapInfo->bmiColors[nColor].rgbRed = (BYTE)((nColor > 128) ? 255 : 0);
m_pBitmapInfo->bmiColors[nColor].rgbGreen = (BYTE)((nColor > 128) ? 255 : 0);
m_pBitmapInfo->bmiColors[nColor].rgbBlue = (BYTE)((nColor > 128) ? 255 : 0);
@@ -97,9 +94,8 @@ bool CLCDGfx::Initialize(int nWidth, int nHeight, int nBPP, PBYTE pLcdBitmapBits }
}
- m_hBitmap = CreateDIBSection(m_hDC, m_pBitmapInfo, DIB_RGB_COLORS, (PVOID *) &m_pBitmapBits, nullptr, 0);
- if(nullptr == m_hBitmap)
- {
+ m_hBitmap = CreateDIBSection(m_hDC, m_pBitmapInfo, DIB_RGB_COLORS, (PVOID *)&m_pBitmapBits, nullptr, 0);
+ if (nullptr == m_hBitmap) {
TRACE(L"CLCDGfx::Initialize(): failed to create bitmap.\n");
Shutdown();
return false;
@@ -125,8 +121,7 @@ bool CLCDGfx::Shutdown(void) {
EndTransition();
- if(nullptr != m_hBitmap)
- {
+ if (nullptr != m_hBitmap) {
DeleteObject(m_hBitmap);
m_hBitmap = nullptr;
m_pBitmapBits = nullptr;
@@ -135,14 +130,12 @@ bool CLCDGfx::Shutdown(void) ASSERT(nullptr == m_hPrevBitmap);
m_hPrevBitmap = nullptr;
- if(nullptr != m_pBitmapInfo)
- {
- delete [] m_pBitmapInfo;
+ if (nullptr != m_pBitmapInfo) {
+ delete[] m_pBitmapInfo;
m_pBitmapInfo = nullptr;
}
- if(nullptr != m_hDC)
- {
+ if (nullptr != m_hDC) {
DeleteDC(m_hDC);
m_hDC = nullptr;
}
@@ -157,16 +150,16 @@ bool CLCDGfx::Shutdown(void) //************************************************************************
// CLCDGfx::SetClipRegion
//************************************************************************
-void CLCDGfx::SetClipRegion(int iX,int iY,int iWidth,int iHeight)
+void CLCDGfx::SetClipRegion(int iX, int iY, int iWidth, int iHeight)
{
ASSERT(nullptr != m_hPrevBitmap);
m_rClipRegion.left = iX;
- m_rClipRegion.right = iX+iWidth;
+ m_rClipRegion.right = iX + iWidth;
m_rClipRegion.top = iY;
- m_rClipRegion.bottom = iY+iHeight;
+ m_rClipRegion.bottom = iY + iHeight;
- HRGN hRgn = CreateRectRgn(iX,iY,iX+iWidth,iY+iHeight);
+ HRGN hRgn = CreateRectRgn(iX, iY, iX + iWidth, iY + iHeight);
SelectClipRgn(GetHDC(), hRgn);
DeleteObject(hRgn);
}
@@ -185,12 +178,11 @@ RECT CLCDGfx::GetClipRegion() void CLCDGfx::BeginDraw(void)
{
ASSERT(nullptr != m_hBitmap);
- if(m_hPrevBitmap != nullptr)
+ if (m_hPrevBitmap != nullptr)
Sleep(1);
ASSERT(nullptr == m_hPrevBitmap);
- if(nullptr == m_hPrevBitmap)
- {
- m_hPrevBitmap = (HBITMAP) SelectObject(m_hDC, m_hBitmap);
+ if (nullptr == m_hPrevBitmap) {
+ m_hPrevBitmap = (HBITMAP)SelectObject(m_hDC, m_hBitmap);
SetTextColor(m_hDC, RGB(255, 255, 255));
SetBkColor(m_hDC, RGB(0, 0, 0));
}
@@ -203,21 +195,23 @@ void CLCDGfx::ClearScreen(void) {
// this means, we're inside BeginDraw()/EndDraw()
ASSERT(nullptr != m_hPrevBitmap);
- RECT rc = { 0, 0, m_nWidth, m_nHeight };
- FillRect(m_hDC, &rc, (HBRUSH) GetStockObject(BLACK_BRUSH));
+ RECT rc = {0, 0, m_nWidth, m_nHeight};
+ FillRect(m_hDC, &rc, (HBRUSH)GetStockObject(BLACK_BRUSH));
}
//************************************************************************
// CLCDGfx::GetPixel
//************************************************************************
-COLORREF CLCDGfx::GetPixel(int nX, int nY) {
- return ::GetPixel(m_hDC,nX,nY);
+COLORREF CLCDGfx::GetPixel(int nX, int nY)
+{
+ return ::GetPixel(m_hDC, nX, nY);
}
//************************************************************************
// CLCDGfx::SetPixel
//************************************************************************
-void CLCDGfx::SetPixel(int nX, int nY, COLORREF color) {
+void CLCDGfx::SetPixel(int nX, int nY, COLORREF color)
+{
// this means, we're inside BeginDraw()/EndDraw()
ASSERT(nullptr != m_hPrevBitmap);
::SetPixel(m_hDC, nX, nY, color);
@@ -226,12 +220,13 @@ void CLCDGfx::SetPixel(int nX, int nY, COLORREF color) { void CLCDGfx::SetPixel(int nX, int nY, BYTE r, BYTE g, BYTE b)
{
COLORREF ref;
- if(m_nBPP==1) {
+ if (m_nBPP == 1) {
ref = (r || g || b) ? RGB(255, 255, 255) : RGB(0, 0, 0);
- } else {
- ref = RGB(r,g,b);
}
- SetPixel(nX,nY,ref);
+ else {
+ ref = RGB(r, g, b);
+ }
+ SetPixel(nX, nY, ref);
}
@@ -243,7 +238,7 @@ void CLCDGfx::DrawLine(int nX1, int nY1, int nX2, int nY2) // this means, we're inside BeginDraw()/EndDraw()
ASSERT(nullptr != m_hPrevBitmap);
- HPEN hPrevPen = (HPEN) SelectObject(m_hDC, GetStockObject(WHITE_PEN));
+ HPEN hPrevPen = (HPEN)SelectObject(m_hDC, GetStockObject(WHITE_PEN));
::MoveToEx(m_hDC, nX1, nY1, nullptr);
::LineTo(m_hDC, nX2, nY2);
SelectObject(m_hDC, hPrevPen);
@@ -260,8 +255,8 @@ void CLCDGfx::DrawFilledRect(int nX, int nY, int nWidth, int nHeight) // this means, we're inside BeginDraw()/EndDraw()
ASSERT(nullptr != m_hPrevBitmap);
- HBRUSH hPrevBrush = (HBRUSH) SelectObject(m_hDC, GetStockObject(WHITE_BRUSH));
- RECT r = { nX, nY, nX + nWidth, nY + nHeight };
+ HBRUSH hPrevBrush = (HBRUSH)SelectObject(m_hDC, GetStockObject(WHITE_BRUSH));
+ RECT r = {nX, nY, nX + nWidth, nY + nHeight};
::FillRect(m_hDC, &r, hPrevBrush);
SelectObject(m_hDC, hPrevBrush);
}
@@ -274,16 +269,16 @@ void CLCDGfx::DrawRect(int iX, int iY, int iWidth, int iHeight) // this means, we're inside BeginDraw()/EndDraw()
ASSERT(nullptr != m_hPrevBitmap);
- HBRUSH hPrevBrush = (HBRUSH) SelectObject(m_hDC, GetStockObject(WHITE_BRUSH));
+ HBRUSH hPrevBrush = (HBRUSH)SelectObject(m_hDC, GetStockObject(WHITE_BRUSH));
// top line
- DrawLine(iX+1,iY,iX+iWidth-1,iY);
+ DrawLine(iX + 1, iY, iX + iWidth - 1, iY);
// bottom line
- DrawLine(iX+1,iY+iHeight-1,iX+iWidth-1,iY+iHeight-1);
+ DrawLine(iX + 1, iY + iHeight - 1, iX + iWidth - 1, iY + iHeight - 1);
// left line
- DrawLine(iX,iY,iX,iY+iHeight);
+ DrawLine(iX, iY, iX, iY + iHeight);
// right line
- DrawLine(iX+iWidth-1,iY,iX+iWidth-1,iY+iHeight);
+ DrawLine(iX + iWidth - 1, iY, iX + iWidth - 1, iY + iHeight);
SelectObject(m_hDC, hPrevBrush);
}
@@ -295,7 +290,7 @@ void CLCDGfx::DrawText(int nX, int nY, LPCTSTR sText) {
// map mode text, with transparency
int nOldMapMode = SetMapMode(m_hDC, MM_TEXT);
- int nOldBkMode = SetBkMode(m_hDC, TRANSPARENT);
+ int nOldBkMode = SetBkMode(m_hDC, TRANSPARENT);
DRAWTEXTPARAMS dtp;
memset(&dtp, 0, sizeof(DRAWTEXTPARAMS));
@@ -312,33 +307,33 @@ void CLCDGfx::DrawText(int nX, int nY, LPCTSTR sText) //************************************************************************
// CLCDGfx::DrawText
//************************************************************************
-void CLCDGfx::DrawText(int nX,int nY,int nWidth,tstring strText)
+void CLCDGfx::DrawText(int nX, int nY, int nWidth, tstring strText)
{
- SIZE sizeLine = {0, 0};
+ SIZE sizeLine = {0, 0};
SIZE sizeCutOff = {0, 0};
- GetTextExtentPoint(GetHDC(),L"...",3,&sizeCutOff);
+ GetTextExtentPoint(GetHDC(), L"...", 3, &sizeCutOff);
int *piWidths = new int[strText.length()];
int iMaxChars = 0;
GetTextExtentExPoint(GetHDC(), strText.c_str(), (int)strText.length(), nWidth, &iMaxChars, piWidths, &sizeLine);
- if(iMaxChars < strText.length()) {
- for(iMaxChars--;iMaxChars>0;iMaxChars--)
- if(piWidths[iMaxChars] + sizeCutOff.cx <= nWidth)
+ if (iMaxChars < strText.length()) {
+ for (iMaxChars--; iMaxChars > 0; iMaxChars--)
+ if (piWidths[iMaxChars] + sizeCutOff.cx <= nWidth)
break;
- DrawText(nX,nY,(strText.substr(0,iMaxChars) + L"...").c_str());
+ DrawText(nX, nY, (strText.substr(0, iMaxChars) + L"...").c_str());
}
- else DrawText(nX,nY,strText.c_str());
+ else DrawText(nX, nY, strText.c_str());
delete[] piWidths;
}
//************************************************************************
// CLCDGfx::DrawBitmap
//************************************************************************
-void CLCDGfx::DrawBitmap(int nX, int nY,int nWidth, int nHeight, HBITMAP hBitmap)
+void CLCDGfx::DrawBitmap(int nX, int nY, int nWidth, int nHeight, HBITMAP hBitmap)
{
HDC hCompatibleDC = CreateCompatibleDC(GetHDC());
HBITMAP hOldBitmap = (HBITMAP)SelectObject(hCompatibleDC, hBitmap);
@@ -356,19 +351,17 @@ void CLCDGfx::DrawBitmap(int nX, int nY,int nWidth, int nHeight, HBITMAP hBitmap void CLCDGfx::EndDraw(void)
{
ASSERT(nullptr != m_hPrevBitmap);
- if(nullptr != m_hPrevBitmap)
- {
+ if (nullptr != m_hPrevBitmap) {
GdiFlush();
- m_hPrevBitmap = (HBITMAP) SelectObject(m_hDC, m_hPrevBitmap);
+ m_hPrevBitmap = (HBITMAP)SelectObject(m_hDC, m_hPrevBitmap);
ASSERT(m_hPrevBitmap == m_hBitmap);
m_hPrevBitmap = nullptr;
}
- if(m_nBPP != 1 || !m_bTransition)
+ if (m_nBPP != 1 || !m_bTransition)
memcpy(m_pLcdBitmapBits, m_pBitmapBits, m_nWidth * m_nHeight * m_nBPP);
- else
- {
- if(m_dwTransitionStart == 0) {
+ else {
+ if (m_dwTransitionStart == 0) {
Cache();
}
@@ -420,117 +413,109 @@ void CLCDGfx::EndDraw(void) memcpy(m_pLcdBitmapBits+(i*m_nWidth)+(m_nWidth-iCols),pScreen2+(i*m_nWidth),iCols);
}
}
- else*/ if(m_eTransition == TRANSITION_HLINES)
- {
- int iCols = ((float)dwTimeElapsed/(float)TRANSITION_DURATION)*m_nHeight;
- if(iCols%2 == 1)
+ else*/ if (m_eTransition == TRANSITION_HLINES) {
+ int iCols = ((float)dwTimeElapsed / (float)TRANSITION_DURATION)*m_nHeight;
+ if (iCols % 2 == 1)
iCols--;
- if(iCols > m_nHeight)
+ if (iCols > m_nHeight)
iCols = m_nHeight;
- if(iCols < 2)
+ if (iCols < 2)
iCols = 2;
- memcpy(m_pLcdBitmapBits,pScreen1,m_nHeight*m_nWidth);
- for(int i=0;i<m_nHeight;i += m_nHeight/iCols)
- memcpy(m_pLcdBitmapBits+(i*m_nWidth),pScreen2+(i*m_nWidth),m_nWidth);
+ memcpy(m_pLcdBitmapBits, pScreen1, m_nHeight*m_nWidth);
+ for (int i = 0; i < m_nHeight; i += m_nHeight / iCols)
+ memcpy(m_pLcdBitmapBits + (i*m_nWidth), pScreen2 + (i*m_nWidth), m_nWidth);
}
- else if(m_eTransition == TRANSITION_VLINES)
- {
- int iCols = ((float)dwTimeElapsed/(float)TRANSITION_DURATION)*m_nWidth;
- if(iCols%2 == 1)
+ else if (m_eTransition == TRANSITION_VLINES) {
+ int iCols = ((float)dwTimeElapsed / (float)TRANSITION_DURATION)*m_nWidth;
+ if (iCols % 2 == 1)
iCols--;
- if(iCols > m_nWidth)
+ if (iCols > m_nWidth)
iCols = m_nWidth;
- if(iCols < 2)
+ if (iCols < 2)
iCols = 2;
- memcpy(m_pLcdBitmapBits,pScreen1,m_nHeight*m_nWidth);
- for(int i=0;i<m_nHeight;i++)
- {
- for(int j=0;j<m_nWidth;j+=m_nWidth/iCols)
- memcpy(m_pLcdBitmapBits+(i*m_nWidth)+j,pScreen2+(i*m_nWidth)+j,1);
+ memcpy(m_pLcdBitmapBits, pScreen1, m_nHeight*m_nWidth);
+ for (int i = 0; i < m_nHeight; i++) {
+ for (int j = 0; j < m_nWidth; j += m_nWidth / iCols)
+ memcpy(m_pLcdBitmapBits + (i*m_nWidth) + j, pScreen2 + (i*m_nWidth) + j, 1);
}
}
- else if(m_eTransition == TRANSITION_FADE)
- {
- int iCols = ((float)dwTimeElapsed/(float)TRANSITION_DURATION)*m_nHeight;
- if(iCols%2 == 1)
+ else if (m_eTransition == TRANSITION_FADE) {
+ int iCols = ((float)dwTimeElapsed / (float)TRANSITION_DURATION)*m_nHeight;
+ if (iCols % 2 == 1)
iCols--;
- if(iCols > m_nHeight)
+ if (iCols > m_nHeight)
iCols = m_nHeight;
- if(iCols < 2)
+ if (iCols < 2)
iCols = 2;
- int iCols2 = ((float)dwTimeElapsed/(float)TRANSITION_DURATION)*m_nWidth;
- if(iCols2%2 == 1)
+ int iCols2 = ((float)dwTimeElapsed / (float)TRANSITION_DURATION)*m_nWidth;
+ if (iCols2 % 2 == 1)
iCols2--;
- if(iCols2 > m_nWidth)
+ if (iCols2 > m_nWidth)
iCols2 = m_nWidth;
- if(iCols2 < 2)
+ if (iCols2 < 2)
iCols2 = 2;
- memcpy(m_pLcdBitmapBits,pScreen1,m_nHeight*m_nWidth);
- for(int i=0;i<m_nHeight;i += m_nHeight/iCols)
- {
- for(int j=0;j<m_nWidth;j+=m_nWidth/iCols2)
- memcpy(m_pLcdBitmapBits+(i*m_nWidth)+j,pScreen2+(i*m_nWidth)+j,1);
+ memcpy(m_pLcdBitmapBits, pScreen1, m_nHeight*m_nWidth);
+ for (int i = 0; i < m_nHeight; i += m_nHeight / iCols) {
+ for (int j = 0; j < m_nWidth; j += m_nWidth / iCols2)
+ memcpy(m_pLcdBitmapBits + (i*m_nWidth) + j, pScreen2 + (i*m_nWidth) + j, 1);
}
}
- else if(m_eTransition == TRANSITION_MORPH)
- {
- double dPercent = ((float)dwTimeElapsed/(float)TRANSITION_DURATION);
+ else if (m_eTransition == TRANSITION_MORPH) {
+ double dPercent = ((float)dwTimeElapsed / (float)TRANSITION_DURATION);
double dPixelPercent = dPercent;
- memset(m_pLcdBitmapBits,0x00,m_nHeight * m_nWidth);
+ memset(m_pLcdBitmapBits, 0x00, m_nHeight * m_nWidth);
SLCDPixel *pPixel = nullptr;
vector<SLCDPixel*>::iterator iter = m_LMovingPixels.begin();
- int iIndex = 0,iMoved = 0;
+ int iIndex = 0, iMoved = 0;
- while(iter != m_LMovingPixels.end())
- {
+ while (iter != m_LMovingPixels.end()) {
pPixel = *iter;
- if(pPixel->Position.x != pPixel->Destination.x ||pPixel->Position.y != pPixel->Destination.y) {
+ if (pPixel->Position.x != pPixel->Destination.x || pPixel->Position.y != pPixel->Destination.y) {
iMoved++;
dPixelPercent = dPercent * pPixel->dSpeed;
- if(dPixelPercent > 1.0f)
+ if (dPixelPercent > 1.0f)
dPixelPercent = 1.0f;
- if(pPixel->Start.x < pPixel->Destination.x)
- pPixel->Position.x = pPixel->Start.x + dPixelPercent*(pPixel->Destination.x-pPixel->Start.x);
- else if(pPixel->Start.x > pPixel->Destination.x)
- pPixel->Position.x = pPixel->Start.x - dPixelPercent*(pPixel->Start.x-pPixel->Destination.x);
+ if (pPixel->Start.x < pPixel->Destination.x)
+ pPixel->Position.x = pPixel->Start.x + dPixelPercent * (pPixel->Destination.x - pPixel->Start.x);
+ else if (pPixel->Start.x > pPixel->Destination.x)
+ pPixel->Position.x = pPixel->Start.x - dPixelPercent * (pPixel->Start.x - pPixel->Destination.x);
- if(pPixel->Start.y < pPixel->Destination.y)
- pPixel->Position.y = pPixel->Start.y + dPixelPercent*(pPixel->Destination.y-pPixel->Start.y);
- else if(pPixel->Start.y > pPixel->Destination.y)
- pPixel->Position.y = pPixel->Start.y - dPixelPercent*(pPixel->Start.y-pPixel->Destination.y);
+ if (pPixel->Start.y < pPixel->Destination.y)
+ pPixel->Position.y = pPixel->Start.y + dPixelPercent * (pPixel->Destination.y - pPixel->Start.y);
+ else if (pPixel->Start.y > pPixel->Destination.y)
+ pPixel->Position.y = pPixel->Start.y - dPixelPercent * (pPixel->Start.y - pPixel->Destination.y);
}
iIndex = pPixel->Position.y*m_nWidth + pPixel->Position.x;
- if(iIndex >= 0 && iIndex < m_nHeight * m_nWidth)
+ if (iIndex >= 0 && iIndex < m_nHeight * m_nWidth)
m_pLcdBitmapBits[iIndex] = pPixel->cValue;
iter++;
}
iter = m_LStaticPixels.begin();
- while(iter != m_LStaticPixels.end())
- {
+ while (iter != m_LStaticPixels.end()) {
pPixel = *iter;
iIndex = pPixel->Position.y*m_nWidth + pPixel->Position.x;
m_pLcdBitmapBits[iIndex] = pPixel->cValue;
iter++;
}
- if(iMoved == 0)
+ if (iMoved == 0)
EndTransition();
}
- if(m_eTransition != TRANSITION_MORPH && dwTimeElapsed > TRANSITION_DURATION) {
+ if (m_eTransition != TRANSITION_MORPH && dwTimeElapsed > TRANSITION_DURATION) {
EndTransition();
}
}
@@ -565,36 +550,34 @@ HBITMAP CLCDGfx::GetHBITMAP(void) return m_hBitmap;
}
-int CLCDGfx::findNearestMatch(PBYTE targetArray,int iSourceIndex) {
- int startY = iSourceIndex/m_nWidth;
- int startX = iSourceIndex - (iSourceIndex/m_nWidth)*m_nWidth;
+int CLCDGfx::findNearestMatch(PBYTE targetArray, int iSourceIndex)
+{
+ int startY = iSourceIndex / m_nWidth;
+ int startX = iSourceIndex - (iSourceIndex / m_nWidth)*m_nWidth;
int iIndex;
- int iY=0,iX=0;
- for(int iPass=1;iPass<m_nWidth;iPass++)
- {
- for(iY = startY-iPass;iY<=startY+iPass;iY+=iPass*2)
- for(iX=startX-iPass;iX<startX+iPass;iX++)
- {
+ int iY = 0, iX = 0;
+ for (int iPass = 1; iPass < m_nWidth; iPass++) {
+ for (iY = startY - iPass; iY <= startY + iPass; iY += iPass * 2)
+ for (iX = startX - iPass; iX < startX + iPass; iX++) {
// skip illegal coordinates
- if(iY < 0 || iY >= m_nHeight || iX <0 || iX >= m_nWidth)
+ if (iY < 0 || iY >= m_nHeight || iX < 0 || iX >= m_nWidth)
continue;
- iIndex = iY*m_nWidth + iX;
- if(targetArray[iIndex] != 0)
+ iIndex = iY * m_nWidth + iX;
+ if (targetArray[iIndex] != 0)
+ return iIndex;
+ }
+ for (iX = startX - iPass; iX <= startX + iPass; iX += iPass * 2)
+ for (iY = startY - iPass; iY < startY + iPass; iY++) {
+ // skip illegal coordinates
+ if (iY < 0 || iY >= m_nHeight || iX < 0 || iX >= m_nWidth)
+ continue;
+
+ iIndex = iY * m_nWidth + iX;
+ if (targetArray[iIndex] != 0)
return iIndex;
}
- for(iX = startX-iPass;iX<=startX+iPass;iX+=iPass*2)
- for(iY=startY-iPass;iY<startY+iPass;iY++)
- {
- // skip illegal coordinates
- if(iY < 0 || iY >= m_nHeight || iX <0 || iX >= m_nWidth)
- continue;
-
- iIndex = iY*m_nWidth + iX;
- if(targetArray[iIndex] != 0)
- return iIndex;
- }
}
return -1;
}
@@ -607,8 +590,7 @@ void CLCDGfx::Cache() DWORD dwStart = GetTickCount();
// Initialize pixels
- if(m_eTransition == TRANSITION_MORPH)
- {
+ if (m_eTransition == TRANSITION_MORPH) {
SLCDPixel *pPixel = nullptr;
SLCDPixel *pSource = nullptr;
@@ -619,22 +601,20 @@ void CLCDGfx::Cache() int iTransitionPixels = 0;
POINT pt;
- for(int j=0;j<2;j++)
- {
+ for (int j = 0; j < 2; j++) {
iIndex = 0;
- for(int i=0;i<m_nHeight * m_nWidth;i++)
- {
- pt.y = i/m_nWidth;
- pt.x = i - (i/m_nWidth)*m_nWidth;
- if((j==0 && !PtInRect(&m_rTransitionRegion,pt)) || (m_pSavedBitmapBits[i] != 0x00 && (j==1 || m_pBitmapBits[i] != 0x00)))
- {
+ for (int i = 0; i < m_nHeight * m_nWidth; i++) {
+ pt.y = i / m_nWidth;
+ pt.x = i - (i / m_nWidth)*m_nWidth;
+ if ((j == 0 && !PtInRect(&m_rTransitionRegion, pt)) || (m_pSavedBitmapBits[i] != 0x00 && (j == 1 || m_pBitmapBits[i] != 0x00))) {
iIndex = i;
pPixel = new SLCDPixel();
pPixel->dSpeed = GetRandomDouble()*0.5 + 1;
- if(!PtInRect(&m_rTransitionRegion,pt)) {
+ if (!PtInRect(&m_rTransitionRegion, pt)) {
pPixel->cValue = m_pBitmapBits[i];
- } else {
+ }
+ else {
pPixel->cValue = m_pSavedBitmapBits[i];
}
pPixel->Start.y = pt.y;
@@ -642,78 +622,70 @@ void CLCDGfx::Cache() pPixel->Position = pPixel->Start;
bBreak = false;
- if(j==1 && bSearch)
- {
+ if (j == 1 && bSearch) {
// search for a pixel in circles with increasing radius around the location
- iIndex = findNearestMatch(m_pBitmapBits,i);
- if(iIndex < 0) {
+ iIndex = findNearestMatch(m_pBitmapBits, i);
+ if (iIndex < 0) {
iIndex = i;
- } else {
+ }
+ else {
bBreak = true;
}
}
- if(j==0 || bBreak)
- {
- pPixel->Destination.y = iIndex/m_nWidth;
- pPixel->Destination.x = iIndex - (iIndex/m_nWidth)*m_nWidth;
+ if (j == 0 || bBreak) {
+ pPixel->Destination.y = iIndex / m_nWidth;
+ pPixel->Destination.x = iIndex - (iIndex / m_nWidth)*m_nWidth;
m_pBitmapBits[iIndex] = 0;
m_pSavedBitmapBits[i] = 0;
- if(bBreak)
+ if (bBreak)
iTransitionPixels++;
}
- else
- {
- if(m_LMovingPixels.size() > 0 && iTransitionPixels > 0)
- {
- pSource = m_LMovingPixels[GetRandomInt(0, (int)m_LMovingPixels.size()-1)];
+ else {
+ if (m_LMovingPixels.size() > 0 && iTransitionPixels > 0) {
+ pSource = m_LMovingPixels[GetRandomInt(0, (int)m_LMovingPixels.size() - 1)];
pPixel->Destination = pSource->Destination;
}
- else
- {
- pPixel->Destination.x = GetRandomInt(0,m_nWidth-1);
- pPixel->Destination.y = GetRandomInt(0,1)==1?-1:m_nHeight+1;
+ else {
+ pPixel->Destination.x = GetRandomInt(0, m_nWidth - 1);
+ pPixel->Destination.y = GetRandomInt(0, 1) == 1 ? -1 : m_nHeight + 1;
}
bSearch = false;
}
- if(j == 0)
+ if (j == 0)
m_LStaticPixels.push_back(pPixel);
- else {
+ else
m_LMovingPixels.push_back(pPixel);
- }
}
}
}
+
bool bRandom = false;
- if(m_LMovingPixels.size() <= 0)
+ if (m_LMovingPixels.size() <= 0)
bRandom = true;
- for(iIndex=0;iIndex<m_nHeight * m_nWidth;iIndex++)
- {
- if(m_pBitmapBits[iIndex] == 0)
+ for (iIndex = 0; iIndex < m_nHeight * m_nWidth; iIndex++) {
+ if (m_pBitmapBits[iIndex] == 0)
continue;
pPixel = new SLCDPixel();
pPixel->dSpeed = GetRandomDouble()*0.5 + 1;
pPixel->cValue = m_pBitmapBits[iIndex];
- if(!bRandom)
- {
- pSource = m_LMovingPixels[GetRandomInt(0, (int)m_LMovingPixels.size()-1)];
+ if (!bRandom) {
+ pSource = m_LMovingPixels[GetRandomInt(0, (int)m_LMovingPixels.size() - 1)];
pPixel->Start = pSource->Start;
}
- else
- {
- pPixel->Start.x = GetRandomInt(0,m_nWidth-1);
- pPixel->Start.y = GetRandomInt(0,1)==1?-1:m_nHeight+1;
+ else {
+ pPixel->Start.x = GetRandomInt(0, m_nWidth - 1);
+ pPixel->Start.y = GetRandomInt(0, 1) == 1 ? -1 : m_nHeight + 1;
}
pPixel->Position = pPixel->Start;
-
- pPixel->Destination.y = iIndex/m_nWidth;
- pPixel->Destination.x = iIndex - (iIndex/m_nWidth)*m_nWidth;
+ pPixel->Destination.y = iIndex / m_nWidth;
+ pPixel->Destination.x = iIndex - (iIndex / m_nWidth)*m_nWidth;
m_LMovingPixels.push_back(pPixel);
}
@@ -721,66 +693,64 @@ void CLCDGfx::Cache() m_dwTransitionStart = GetTickCount();
- TRACE(L"Textmorphing: time consumed: %0.2f\n",(double)(m_dwTransitionStart-dwStart)/(double)1000);
+ TRACE(L"Textmorphing: time consumed: %0.2f\n", (double)(m_dwTransitionStart - dwStart) / (double)1000);
}
//************************************************************************
// CLCDGfx::StartTransition
//************************************************************************
-void CLCDGfx::StartTransition(ETransitionType eType,LPRECT rect)
+void CLCDGfx::StartTransition(ETransitionType eType, LPRECT rect)
{
- if(!m_bInitialized)
+ if (!m_bInitialized)
return;
- if(rect != nullptr) {
+ if (rect != nullptr) {
m_rTransitionRegion.left = rect->left;
m_rTransitionRegion.right = rect->right;
m_rTransitionRegion.top = rect->top;
m_rTransitionRegion.bottom = rect->bottom;
- } else {
- SetRect(&m_rTransitionRegion,0,0,m_nWidth,m_nHeight);
+ }
+ else {
+ SetRect(&m_rTransitionRegion, 0, 0, m_nWidth, m_nHeight);
}
- if(eType == TRANSITION_RANDOM)
- m_eTransition = static_cast<ETransitionType>(GetRandomInt(0,2));
+ if (eType == TRANSITION_RANDOM)
+ m_eTransition = static_cast<ETransitionType>(GetRandomInt(0, 2));
else
m_eTransition = eType;
- if(m_bTransition) {
+ if (m_bTransition) {
EndTransition();
- memcpy(m_pBitmapBits,m_pLcdBitmapBits,sizeof(BYTE)*m_nWidth*m_nHeight*m_nBPP);
+ memcpy(m_pBitmapBits, m_pLcdBitmapBits, sizeof(BYTE)*m_nWidth*m_nHeight*m_nBPP);
}
- if(m_pSavedBitmapBits == nullptr)
+ if (m_pSavedBitmapBits == nullptr)
m_pSavedBitmapBits = (BYTE*)malloc(sizeof(BYTE)*m_nWidth*m_nHeight*m_nBPP);
- memcpy(m_pSavedBitmapBits, m_pBitmapBits,sizeof(BYTE)* m_nWidth * m_nHeight * m_nBPP);
+ memcpy(m_pSavedBitmapBits, m_pBitmapBits, sizeof(BYTE)* m_nWidth * m_nHeight * m_nBPP);
m_dwTransitionStart = 0;
- m_bTransition = true;
+ m_bTransition = true;
}
void CLCDGfx::EndTransition()
{
- if(m_pSavedBitmapBits != nullptr)
+ if (m_pSavedBitmapBits != nullptr)
free(m_pSavedBitmapBits);
m_pSavedBitmapBits = nullptr;
- if(!m_LMovingPixels.empty())
- {
+ if (!m_LMovingPixels.empty()) {
vector<SLCDPixel*>::iterator iter = m_LMovingPixels.begin();
- while(iter != m_LMovingPixels.end())
- {
+ while (iter != m_LMovingPixels.end()) {
delete *iter;
iter++;
}
m_LMovingPixels.clear();
iter = m_LStaticPixels.begin();
- while(iter != m_LStaticPixels.end())
- {
+ while (iter != m_LStaticPixels.end()) {
delete *iter;
iter++;
}
@@ -788,4 +758,4 @@ void CLCDGfx::EndTransition() }
m_bTransition = false;
-}
\ No newline at end of file +}
diff --git a/plugins/MirandaG15/src/LCDFramework/CLCDGfx.h b/plugins/MirandaG15/src/LCDFramework/CLCDGfx.h index cc43966413..2cc940e23b 100644 --- a/plugins/MirandaG15/src/LCDFramework/CLCDGfx.h +++ b/plugins/MirandaG15/src/LCDFramework/CLCDGfx.h @@ -31,25 +31,25 @@ public: void DrawFilledRect(int nX, int nY, int nWidth, int nHeight);
void DrawRect(int iX, int iY, int iWidth, int iHeight);
void DrawText(int nX, int nY, LPCTSTR sText);
- void DrawText(int nX,int nY,int iWidth,tstring strText);
- void DrawBitmap(int nX,int nY,int nWidth, int nHeight,HBITMAP hBitmap);
+ void DrawText(int nX, int nY, int iWidth, tstring strText);
+ void DrawBitmap(int nX, int nY, int nWidth, int nHeight, HBITMAP hBitmap);
void EndDraw(void);
- void SetClipRegion(int iX,int iY,int iWidth,int iHeight);
+ void SetClipRegion(int iX, int iY, int iWidth, int iHeight);
RECT GetClipRegion();
- inline int GetClipWidth() { return m_rClipRegion.right-m_rClipRegion.left; };
- inline int GetClipHeight() { return m_rClipRegion.bottom-m_rClipRegion.top; };
+ inline int GetClipWidth() { return m_rClipRegion.right - m_rClipRegion.left; };
+ inline int GetClipHeight() { return m_rClipRegion.bottom - m_rClipRegion.top; };
HDC GetHDC(void);
BITMAPINFO *GetBitmapInfo(void);
HBITMAP GetHBITMAP(void);
- void StartTransition(ETransitionType eType = TRANSITION_RANDOM,LPRECT rect = nullptr);
+ void StartTransition(ETransitionType eType = TRANSITION_RANDOM, LPRECT rect = nullptr);
protected:
void Cache();
- int findNearestMatch(PBYTE targetArray,int iSourceIndex);
+ int findNearestMatch(PBYTE targetArray, int iSourceIndex);
void EndTransition();
@@ -63,7 +63,7 @@ protected: HDC m_hDC;
HBITMAP m_hBitmap;
HBITMAP m_hPrevBitmap;
- PBYTE m_pBitmapBits,m_pLcdBitmapBits,m_pSavedBitmapBits;
+ PBYTE m_pBitmapBits, m_pLcdBitmapBits, m_pSavedBitmapBits;
bool m_bInitialized;
diff --git a/plugins/MirandaG15/src/LCDFramework/CLCDInput.cpp b/plugins/MirandaG15/src/LCDFramework/CLCDInput.cpp index cce1f30125..c2dfdc04b6 100644 --- a/plugins/MirandaG15/src/LCDFramework/CLCDInput.cpp +++ b/plugins/MirandaG15/src/LCDFramework/CLCDInput.cpp @@ -5,13 +5,11 @@ //************************************************************************
// CLCDInput::CLCDInput
//************************************************************************
-CLCDInput::CLCDInput() : m_hKBHook(nullptr), m_bShowSymbols(true), m_bShowMarker(false),
- m_lInputTime(0), m_iLinePosition(0), m_iLineCount(0), m_iBreakKeys(KEYS_RETURN),
- m_lBlinkTimer(0), m_pScrollbar(nullptr)
+CLCDInput::CLCDInput()
{
memset(&m_Marker, 0, sizeof(m_Marker));
-// SetScrollbarAlignment(TOP);
+ // SetScrollbarAlignment(TOP);
Reset();
}
@@ -29,10 +27,10 @@ CLCDInput::~CLCDInput() //************************************************************************
bool CLCDInput::Initialize()
{
- if(!CLCDTextObject::Initialize())
+ if (!CLCDTextObject::Initialize())
return false;
-
-// m_pParent = pParent;
+
+ // m_pParent = pParent;
return true;
}
@@ -41,20 +39,19 @@ bool CLCDInput::Initialize() //************************************************************************
bool CLCDInput::Shutdown()
{
- if(!CLCDTextObject::Shutdown())
+ if (!CLCDTextObject::Shutdown())
return false;
-
-
+
return true;
}
+
//************************************************************************
// CLCDInput::Update
//************************************************************************
void CLCDInput::SetScrollbar(CLCDBar *pScrollbar)
{
m_pScrollbar = pScrollbar;
- if(m_pScrollbar)
- {
+ if (m_pScrollbar) {
m_pScrollbar->SetSliderSize(m_iLineCount);
m_pScrollbar->SetRange(0, (int)m_vLineOffsets.size());
m_pScrollbar->ScrollTo(m_iLinePosition);
@@ -74,11 +71,10 @@ long CLCDInput::GetLastInputTime() //************************************************************************
bool CLCDInput::Update()
{
- if(!CLCDTextObject::Update())
+ if (!CLCDTextObject::Update())
return false;
-
- if(m_lBlinkTimer + 500 <= (long)GetTickCount())
- {
+
+ if (m_lBlinkTimer + 500 <= (long)GetTickCount()) {
m_bShowMarker = !m_bShowMarker;
m_lBlinkTimer = GetTickCount();
}
@@ -91,57 +87,51 @@ bool CLCDInput::Update() //************************************************************************
bool CLCDInput::Draw(CLCDGfx *pGfx)
{
- if(!CLCDTextObject::Draw(pGfx))
+ if (!CLCDTextObject::Draw(pGfx))
return false;
-
-
- SelectObject(pGfx->GetHDC(),m_hFont);
-
- RECT rBoundary = { 0, 0,0 + GetWidth(), 0 + GetHeight() };
+
+ SelectObject(pGfx->GetHDC(), m_hFont);
+
+ RECT rBoundary = {0, 0,0 + GetWidth(), 0 + GetHeight()};
int iLine = m_iLinePosition;
int iEndLine = m_iLinePosition + m_iLineCount;
int iLen = 0;
wchar_t *pcOffset = nullptr;
- while(iLine < iEndLine && iLine < m_vLineOffsets.size())
- {
+ while (iLine < iEndLine && iLine < m_vLineOffsets.size()) {
// Calculate the text length
- if(iLine < m_vLineOffsets.size() -1)
- {
- iLen = m_vLineOffsets[iLine+1].iOffset - m_vLineOffsets[iLine].iOffset;
+ if (iLine < m_vLineOffsets.size() - 1) {
+ iLen = m_vLineOffsets[iLine + 1].iOffset - m_vLineOffsets[iLine].iOffset;
// Draw the linebreak marker
- if(m_bShowSymbols && m_vLineOffsets[iLine+1].bLineBreak)
- pGfx->DrawFilledRect(m_vLineOffsets[iLine].iWidth+1,rBoundary.top+m_iFontHeight/3,m_iFontHeight/3,m_iFontHeight/3);
+ if (m_bShowSymbols && m_vLineOffsets[iLine + 1].bLineBreak)
+ pGfx->DrawFilledRect(m_vLineOffsets[iLine].iWidth + 1, rBoundary.top + m_iFontHeight / 3, m_iFontHeight / 3, m_iFontHeight / 3);
}
else iLen = (int)m_strText.length() - m_vLineOffsets[iLine].iOffset;
-
+
// Draw the text
pcOffset = (wchar_t*)m_strText.c_str() + m_vLineOffsets[iLine].iOffset;
DrawTextEx(pGfx->GetHDC(),
- (LPTSTR)pcOffset,
- iLen,
- &rBoundary,
- m_iTextFormat,
- &m_dtp);
+ (LPTSTR)pcOffset,
+ iLen,
+ &rBoundary,
+ m_iTextFormat,
+ &m_dtp);
// Draw the input cursor
- if(m_pInput && m_bShowMarker && m_Marker[0].iLine == iLine)
- {
+ if (m_pInput && m_bShowMarker && m_Marker[0].iLine == iLine) {
// insert-mode cursor
- if(m_bInsert ||m_Marker[0].iXWidth == 1)
- {
+ if (m_bInsert || m_Marker[0].iXWidth == 1) {
pGfx->DrawFilledRect(m_Marker[0].iXLine,
- m_iFontHeight*(iLine-m_iLinePosition),
- 1,
- m_iFontHeight);
+ m_iFontHeight*(iLine - m_iLinePosition),
+ 1,
+ m_iFontHeight);
}
// replace-mode cursor
- else
- {
+ else {
RECT rMarker = {m_Marker[0].iXLine,
- m_iFontHeight*(iLine-m_iLinePosition),
- m_Marker[0].iXLine+m_Marker[0].iXWidth,
- m_iFontHeight*(iLine-m_iLinePosition+1)};
- InvertRect(pGfx->GetHDC(),&rMarker);
+ m_iFontHeight*(iLine - m_iLinePosition),
+ m_Marker[0].iXLine + m_Marker[0].iXWidth,
+ m_iFontHeight*(iLine - m_iLinePosition + 1)};
+ InvertRect(pGfx->GetHDC(), &rMarker);
}
}
@@ -184,11 +174,10 @@ bool CLCDInput::IsInputActive() void CLCDInput::OnSizeChanged(SIZE OldSize)
{
// if the width has changed, offsets need to be recalculated
- if(GetWidth() != OldSize.cx)
+ if (GetWidth() != OldSize.cx)
OnFontChanged();
// otherwise, just update scrollbar & linecount
- else if(m_pScrollbar)
- {
+ else if (m_pScrollbar) {
m_iLineCount = GetHeight() / m_iFontHeight;
m_pScrollbar->SetSliderSize(m_iLineCount);
}
@@ -199,21 +188,21 @@ void CLCDInput::OnSizeChanged(SIZE OldSize) //************************************************************************
void CLCDInput::OnFontChanged()
{
- if(m_iFontHeight == 0)
+ if (m_iFontHeight == 0)
return;
- if(m_pScrollbar)
+ if (m_pScrollbar)
m_pScrollbar->SetSliderSize(m_iLineCount);
m_iLinePosition = 0;
m_iLineCount = GetHeight() / m_iFontHeight;
- if(m_pScrollbar)
+ if (m_pScrollbar)
m_pScrollbar->SetSliderSize(m_iLineCount);
m_Marker[0].iLine = 0;
m_Marker[0].iPosition = (int)m_strText.length();
-
+
// Delete all offsets and recalculate them
m_vLineOffsets.clear();
// Create a new offset
@@ -223,9 +212,9 @@ void CLCDInput::OnFontChanged() m_vLineOffsets.push_back(offset);
UpdateOffsets(0);
-
+
UpdateMarker();
- if(m_iLineCount > 0)
+ if (m_iLineCount > 0)
ScrollToMarker();
}
@@ -234,14 +223,14 @@ void CLCDInput::OnFontChanged() //************************************************************************
void CLCDInput::ActivateInput()
{
- if(m_pInput)
+ if (m_pInput)
return;
- CLCDConnection *pLCDCon = CLCDOutputManager::GetInstance()->GetLCDConnection();
+ CLCDConnection *pLCDCon = CLCDOutputManager::GetInstance()->GetLCDConnection();
pLCDCon->SetAsForeground(1);
m_hKBHook = SetWindowsHookEx(WH_KEYBOARD_LL, CLCDInput::KeyboardHook, GetModuleHandle(nullptr), 0);
- if(!m_hKBHook)
+ if (!m_hKBHook)
return;
m_pInput = this;
GetKeyboardState(m_acKeyboardState);
@@ -252,14 +241,14 @@ void CLCDInput::ActivateInput() //************************************************************************
void CLCDInput::DeactivateInput()
{
- if(!m_pInput)
+ if (!m_pInput)
return;
UnhookWindowsHookEx(m_hKBHook);
m_hKBHook = nullptr;
m_pInput = nullptr;
-
- CLCDConnection *pLCDCon = CLCDOutputManager::GetInstance()->GetLCDConnection();
+
+ CLCDConnection *pLCDCon = CLCDOutputManager::GetInstance()->GetLCDConnection();
pLCDCon->SetAsForeground(0);
}
@@ -270,7 +259,7 @@ CLCDInput* CLCDInput::m_pInput = nullptr; LRESULT CALLBACK CLCDInput::KeyboardHook(int Code, WPARAM wParam, LPARAM lParam)
{
- return m_pInput->ProcessKeyEvent(Code,wParam,lParam);
+ return m_pInput->ProcessKeyEvent(Code, wParam, lParam);
}
//************************************************************************
@@ -279,22 +268,21 @@ LRESULT CALLBACK CLCDInput::KeyboardHook(int Code, WPARAM wParam, LPARAM lParam) LRESULT CLCDInput::ProcessKeyEvent(int Code, WPARAM wParam, LPARAM lParam)
{
// Event verarbeiten
- if(Code == HC_ACTION)
- {
+ if (Code == HC_ACTION) {
KBDLLHOOKSTRUCT *key = (KBDLLHOOKSTRUCT *)(lParam);
-
+
bool bKeyDown = !(key->flags & LLKHF_UP);
bool bToggled = (m_acKeyboardState[key->vkCode] & 0x0F) != 0;
- if(bKeyDown)
+ if (bKeyDown)
bToggled = !bToggled;
- m_acKeyboardState[key->vkCode] = (bKeyDown?0x80:0x00) | (bToggled?0x01:0x00);
- if(key->vkCode == VK_LSHIFT || key->vkCode == VK_RSHIFT)
+ m_acKeyboardState[key->vkCode] = (bKeyDown ? 0x80 : 0x00) | (bToggled ? 0x01 : 0x00);
+ if (key->vkCode == VK_LSHIFT || key->vkCode == VK_RSHIFT)
m_acKeyboardState[VK_SHIFT] = m_acKeyboardState[key->vkCode];
- else if(key->vkCode == VK_LCONTROL || key->vkCode == VK_RCONTROL)
+ else if (key->vkCode == VK_LCONTROL || key->vkCode == VK_RCONTROL)
m_acKeyboardState[VK_CONTROL] = m_acKeyboardState[key->vkCode];
- else if(key->vkCode == VK_LMENU || key->vkCode == VK_RMENU)
+ else if (key->vkCode == VK_LMENU || key->vkCode == VK_RMENU)
m_acKeyboardState[VK_MENU] = m_acKeyboardState[key->vkCode];
-
+
/*
if(bKeyDown)
TRACE(L"Key pressed: %i\n",key->vkCode);
@@ -302,132 +290,116 @@ LRESULT CLCDInput::ProcessKeyEvent(int Code, WPARAM wParam, LPARAM lParam) TRACE(L"Key released: %i\n",key->vkCode);
*/
// Only handle Keyup
- if(bKeyDown)
- {
+ if (bKeyDown) {
// Actions with Control/Menu keys
- if((m_acKeyboardState[VK_LMENU] & 0x80 || m_acKeyboardState[VK_CONTROL] & 0x80)
- && m_acKeyboardState[VK_SHIFT] & 0x80)
- {
- ActivateKeyboardLayout((HKL)HKL_NEXT,0);//KLF_SETFORPROCESS);
- TRACE(L"Keyboardlayout switched!\n");
- return 1;
- }
-
- int res = 0,size = 0,dir = MARKER_HORIZONTAL,scroll = 0;
-/*
- if(key->vkCode == VK_DELETE) {
- dir = MARKER_HOLD;
- res = -1;
- if(m_strText[m_Marker[0].iPosition] == '\r')
- res = -2;
- if(m_strText.length() >= m_Marker[0].iPosition + -res) {
- m_strText.erase(m_Marker[0].iPosition,-res);
- scroll = 1;
- size = 1;
- } else {
- res = 0;
- }
- }
- else */if(key->vkCode == VK_BACK )
- {
- if(m_Marker[0].iPosition != 0)
- {
- res = -1;
- if(m_strText[m_Marker[0].iPosition+res] == '\n')
- res = -2;
-
- m_strText.erase(m_Marker[0].iPosition+res,-res);
- scroll = 1;
- size = res;
- }
+ if ((m_acKeyboardState[VK_LMENU] & 0x80 || m_acKeyboardState[VK_CONTROL] & 0x80)
+ && m_acKeyboardState[VK_SHIFT] & 0x80) {
+ ActivateKeyboardLayout((HKL)HKL_NEXT, 0);//KLF_SETFORPROCESS);
+ TRACE(L"Keyboardlayout switched!\n");
+ return 1;
}
+
+ int res = 0, size = 0, dir = MARKER_HORIZONTAL, scroll = 0;
+ /*
+ if(key->vkCode == VK_DELETE) {
+ dir = MARKER_HOLD;
+ res = -1;
+ if(m_strText[m_Marker[0].iPosition] == '\r')
+ res = -2;
+ if(m_strText.length() >= m_Marker[0].iPosition + -res) {
+ m_strText.erase(m_Marker[0].iPosition,-res);
+ scroll = 1;
+ size = 1;
+ } else {
+ res = 0;
+ }
+ }
+ else */if (key->vkCode == VK_BACK) {
+ if (m_Marker[0].iPosition != 0) {
+ res = -1;
+ if (m_strText[m_Marker[0].iPosition + res] == '\n')
+ res = -2;
+
+ m_strText.erase(m_Marker[0].iPosition + res, -res);
+ scroll = 1;
+ size = res;
+ }
+ }
// Marker navigation
- else if (key->vkCode == VK_INSERT)
- {
- m_bInsert = !m_bInsert;
- }
- else if(key->vkCode == VK_HOME)
- {
- res = m_vLineOffsets[m_Marker[0].iLine].iOffset - m_Marker[0].iPosition;
- scroll = 1;
- }
- else if(key->vkCode == VK_END)
- {
- if(m_vLineOffsets.size()-1 == m_Marker[0].iLine)
- res = (int)m_strText.length() - m_Marker[0].iPosition;
- else
- res = (m_vLineOffsets[m_Marker[0].iLine+1].iOffset - 1 - m_vLineOffsets[m_Marker[0].iLine+1].bLineBreak) -m_Marker[0].iPosition;
+ else if (key->vkCode == VK_INSERT) {
+ m_bInsert = !m_bInsert;
+ }
+ else if (key->vkCode == VK_HOME) {
+ res = m_vLineOffsets[m_Marker[0].iLine].iOffset - m_Marker[0].iPosition;
+ scroll = 1;
+ }
+ else if (key->vkCode == VK_END) {
+ if (m_vLineOffsets.size() - 1 == m_Marker[0].iLine)
+ res = (int)m_strText.length() - m_Marker[0].iPosition;
+ else
+ res = (m_vLineOffsets[m_Marker[0].iLine + 1].iOffset - 1 - m_vLineOffsets[m_Marker[0].iLine + 1].bLineBreak) - m_Marker[0].iPosition;
- scroll = 1;
- }
- else if(key->vkCode == VK_UP)
- {
- res = -1;
- dir = MARKER_VERTICAL;
- }
- else if(key->vkCode == VK_DOWN)
- {
- res = 1;
- dir = MARKER_VERTICAL;
- }
- else if(key->vkCode == VK_LEFT)
- res = -1;
- else if(key->vkCode == VK_RIGHT)
- res = 1;
+ scroll = 1;
+ }
+ else if (key->vkCode == VK_UP) {
+ res = -1;
+ dir = MARKER_VERTICAL;
+ }
+ else if (key->vkCode == VK_DOWN) {
+ res = 1;
+ dir = MARKER_VERTICAL;
+ }
+ else if (key->vkCode == VK_LEFT)
+ res = -1;
+ else if (key->vkCode == VK_RIGHT)
+ res = 1;
+
+ else {
+
+ #ifdef _UNICODE
+ wchar_t output[4];
+ #else
+ unsigned char output[2];
+ #endif
+
+ if (key->vkCode == VK_RETURN) {
+ bool bCtrlDown = (m_acKeyboardState[VK_CONTROL] & 0x80) != 0;
+ if (bCtrlDown != (m_iBreakKeys == KEYS_RETURN)) {
+ DeactivateInput();
+ //m_pParent->OnInputFinished();
+ return 1;
+ }
+ else {
+ res = 2;
+ output[0] = '\r';
+ output[1] = '\n';
+ output[2] = 0;
+ }
+ }
+ else {
+ #ifdef _UNICODE
+ res = ToUnicode(key->vkCode, key->scanCode, m_acKeyboardState, output, 4, 0);
+ #else
+ res = ToAscii(key->vkCode, key->scanCode, m_acKeyboardState, (WORD*)output, 0);
+ #endif
+ }
- else
- {
-
-#ifdef _UNICODE
- wchar_t output[4];
-#else
- unsigned char output[2];
-#endif
-
- if(key->vkCode == VK_RETURN)
- {
- bool bCtrlDown = (m_acKeyboardState[VK_CONTROL] & 0x80) != 0;
- if( bCtrlDown != (m_iBreakKeys == KEYS_RETURN))
- {
- DeactivateInput();
- //m_pParent->OnInputFinished();
- return 1;
- }
- else
- {
- res = 2;
- output[0] = '\r';
- output[1] = '\n';
- output[2] = 0;
- }
- }
- else
- {
-#ifdef _UNICODE
- res = ToUnicode(key->vkCode,key->scanCode,m_acKeyboardState,output,4,0);
-#else
- res = ToAscii( key->vkCode,key->scanCode,m_acKeyboardState,(WORD*)output,0);
-#endif
- }
+ if (res <= 0)
+ res = 0;
+ else {
+ if (output[0] != '\r' && output[0] <= 0x001F)
+ return 1;
- if(res <= 0)
- res = 0;
- else
- {
- if(output[0] != '\r' && output[0] <= 0x001F)
- return 1;
+ if (m_bInsert || m_strText[m_Marker[0].iPosition] == '\r')
+ m_strText.insert(m_Marker[0].iPosition, (wchar_t*)output, res);
+ else
+ m_strText.replace(m_Marker[0].iPosition, res, (wchar_t*)output);
- if(m_bInsert || m_strText[m_Marker[0].iPosition] == '\r')
- m_strText.insert(m_Marker[0].iPosition,(wchar_t*)output,res);
- else
- m_strText.replace(m_Marker[0].iPosition,res,(wchar_t*)output);
-
- scroll = 1;
- size = res;
- }
- }
- if(res != 0)
- {
+ scroll = 1;
+ size = res;
+ }
+ }
+ if (res != 0) {
UpdateOffsets(size);
UpdateMarker();
ScrollToMarker();
@@ -435,12 +407,12 @@ LRESULT CLCDInput::ProcessKeyEvent(int Code, WPARAM wParam, LPARAM lParam) }
//WrapLine();
// ----
-
-
+
+
// Block this KeyEvent
}
- return 1;
+ return 1;
}
return CallNextHookEx(m_hKBHook, Code, wParam, lParam);
}
@@ -448,98 +420,88 @@ LRESULT CLCDInput::ProcessKeyEvent(int Code, WPARAM wParam, LPARAM lParam) //************************************************************************
// CLCDInput::MoveMarker
//************************************************************************
-void CLCDInput::MoveMarker(int iDir,int iMove,bool bShift)
+void CLCDInput::MoveMarker(int iDir, int iMove, bool bShift)
{
// Just cursor
- if(!bShift)
- {
+ if (!bShift) {
m_lBlinkTimer = GetTickCount();
m_bShowMarker = true;
- if(iDir == MARKER_HORIZONTAL)
- {
+ if (iDir == MARKER_HORIZONTAL) {
m_Marker[0].iPosition += iMove;
-
+
}
- if(iDir == MARKER_VERTICAL)
- {
- if(iMove < 0 && m_Marker[0].iLine == 0)
+ if (iDir == MARKER_VERTICAL) {
+ if (iMove < 0 && m_Marker[0].iLine == 0)
return;
- if(iMove > 0 && m_Marker[0].iLine == m_vLineOffsets.size()-1)
+ if (iMove > 0 && m_Marker[0].iLine == m_vLineOffsets.size() - 1)
return;
m_Marker[0].iLine += iMove;
- int iX = 0,iX2 = 0;
+ int iX = 0, iX2 = 0;
SIZE sizeChar = {0,0};
int iBegin = m_vLineOffsets[m_Marker[0].iLine].iOffset;
int iLen = 0;
- if(m_Marker[0].iLine < m_vLineOffsets.size() -1)
- iLen = m_vLineOffsets[m_Marker[0].iLine+1].iOffset - m_vLineOffsets[m_Marker[0].iLine].iOffset;
+ if (m_Marker[0].iLine < m_vLineOffsets.size() - 1)
+ iLen = m_vLineOffsets[m_Marker[0].iLine + 1].iOffset - m_vLineOffsets[m_Marker[0].iLine].iOffset;
else
iLen = (int)m_strText.length() - m_vLineOffsets[m_Marker[0].iLine].iOffset;
-
+
HDC hDC = CreateCompatibleDC(nullptr);
- if(nullptr == hDC)
+ if (nullptr == hDC)
return;
- SelectObject(hDC, m_hFont);
+ SelectObject(hDC, m_hFont);
m_Marker[0].iXWidth = 1;
m_Marker[0].iPosition = -1;
int *piWidths = new int[iLen];
int iMaxChars;
- int iChar=iBegin;
+ int iChar = iBegin;
- GetTextExtentExPoint(hDC,m_strText.c_str() + iBegin,iLen,GetWidth(),&iMaxChars,piWidths,&sizeChar);
- for(;iChar<iBegin+iMaxChars;iChar++)
- {
+ GetTextExtentExPoint(hDC, m_strText.c_str() + iBegin, iLen, GetWidth(), &iMaxChars, piWidths, &sizeChar);
+ for (; iChar < iBegin + iMaxChars; iChar++) {
iX2 = iX;
- iX = piWidths[iChar-iBegin];
+ iX = piWidths[iChar - iBegin];
- if(m_Marker[0].iPosition >= 0 &&
- iChar >= m_Marker[0].iPosition)
- {
+ if (m_Marker[0].iPosition >= 0 &&
+ iChar >= m_Marker[0].iPosition) {
m_Marker[0].iXWidth = sizeChar.cx;
break;
}
- if(iX >= m_Marker[0].iXLine || (iChar < iBegin+iLen -1 && m_strText[iChar+1] == 10))
- {
- if( m_Marker[0].iXLine - iX2 <= iX - m_Marker[0].iXLine)
- {
+ if (iX >= m_Marker[0].iXLine || (iChar < iBegin + iLen - 1 && m_strText[iChar + 1] == 10)) {
+ if (m_Marker[0].iXLine - iX2 <= iX - m_Marker[0].iXLine) {
m_Marker[0].iPosition = iChar;
m_Marker[0].iXLine = iX2;
m_Marker[0].iXWidth = sizeChar.cx;
break;
}
- else
- {
- m_Marker[0].iPosition = iChar+1;
+ else {
+ m_Marker[0].iPosition = iChar + 1;
m_Marker[0].iXLine = iX;
}
}
}
-
+
delete[] piWidths;
- if(m_Marker[0].iPosition == -1)
- {
+ if (m_Marker[0].iPosition == -1) {
m_Marker[0].iPosition = iChar;
m_Marker[0].iXLine = iX;
}
DeleteObject(hDC);
}
- for(int i=0;i<2;i++)
- {
- if(m_Marker[i].iPosition < 0)
+ for (int i = 0; i < 2; i++) {
+ if (m_Marker[i].iPosition < 0)
m_Marker[i].iPosition = 0;
- else if(m_Marker[i].iPosition > m_strText.length() )
+ else if (m_Marker[i].iPosition > m_strText.length())
m_Marker[i].iPosition = (int)m_strText.length();
}
- if(m_Marker[0].iPosition > 0 && m_strText[m_Marker[0].iPosition-1] == '\r')
- m_Marker[0].iPosition+= (iDir == MARKER_HORIZONTAL && iMove>0)?1:-1;
+ if (m_Marker[0].iPosition > 0 && m_strText[m_Marker[0].iPosition - 1] == '\r')
+ m_Marker[0].iPosition += (iDir == MARKER_HORIZONTAL && iMove > 0) ? 1 : -1;
}
}
@@ -569,11 +531,10 @@ void CLCDInput::Reset() offset.bLineBreak = false;
offset.iOffset = 0;
m_vLineOffsets.push_back(offset);
-
- if(m_pScrollbar)
- {
+
+ if (m_pScrollbar) {
m_pScrollbar->ScrollTo(0);
- m_pScrollbar->SetRange(0,0);
+ m_pScrollbar->SetRange(0, 0);
m_pScrollbar->SetSliderSize(m_iLineCount);
}
}
@@ -583,17 +544,17 @@ void CLCDInput::Reset() //************************************************************************
void CLCDInput::UpdateOffsets(int iModified)
{
- if(m_vLineOffsets.size() == 0 && m_strText.empty())
+ if (m_vLineOffsets.size() == 0 && m_strText.empty())
return;
HDC hDC = CreateCompatibleDC(nullptr);
- if(nullptr == hDC)
+ if (nullptr == hDC)
return;
-
+
// Reset the marker
m_Marker[0].iXLine = 0;
m_Marker[0].iXWidth = 1;
-
+
// Initialize variables
int iLen = (int)m_strText.length();
int *piWidths = new int[iLen];
@@ -602,142 +563,124 @@ void CLCDInput::UpdateOffsets(int iModified) int iMaxChars = 0;
SIZE sizeWord = {0, 0};
- SIZE sizeLine = {0, 0};
- SelectObject(hDC, m_hFont);
+ SIZE sizeLine = {0, 0};
+ SelectObject(hDC, m_hFont);
int iLine = -1;
// Find the first line to update
- for(int i = (int)m_vLineOffsets.size()-1; i >= 0; i--)
- if(m_vLineOffsets[i].iOffset <= m_Marker[0].iPosition)
- {
+ for (int i = (int)m_vLineOffsets.size() - 1; i >= 0; i--)
+ if (m_vLineOffsets[i].iOffset <= m_Marker[0].iPosition) {
iLine = i;
break;
}
- if(iModified < 0 && iLine-1 >= 0)
+ if (iModified < 0 && iLine - 1 >= 0)
iLine--;
bool bLineClosed = false;
-
+
// TRACE(L"InputText: Begin Update at #%i\n",iLine);
- for(;iLine<m_vLineOffsets.size();iLine++)
- {
+ for (; iLine < m_vLineOffsets.size(); iLine++) {
bLineClosed = false;
int iChar = m_vLineOffsets[iLine].iOffset;
int iWordOffset = iChar;
-
- if(!(iLen == 0) && iChar > iLen)
- {
+
+ if (!(iLen == 0) && iChar > iLen) {
// TRACE(L"InputText: Deleted offset #%i\n",iLine);
- m_vLineOffsets.erase(m_vLineOffsets.begin()+iLine);
+ m_vLineOffsets.erase(m_vLineOffsets.begin() + iLine);
continue;
}
-
+
sizeLine.cx = 0;
sizeWord.cx = 0;
- iWordOffset = iChar+1;
+ iWordOffset = iChar + 1;
- while(iChar<iLen)
- {
- iWordOffset= iChar;
+ while (iChar < iLen) {
+ iWordOffset = iChar;
- GetTextExtentExPoint(hDC,pszText+iChar,iLen-iChar,GetWidth(),&iMaxChars,piWidths,&sizeLine);
- pos = m_strText.find(L"\n",iChar);
+ GetTextExtentExPoint(hDC, pszText + iChar, iLen - iChar, GetWidth(), &iMaxChars, piWidths, &sizeLine);
+ pos = m_strText.find(L"\n", iChar);
// check for linebreaks
- if(pos != tstring::npos && pos >= iChar && pos <= iChar + iMaxChars)
- {
+ if (pos != tstring::npos && pos >= iChar && pos <= iChar + iMaxChars) {
iWordOffset = (int)pos + 1;
iMaxChars = (int)pos - iChar;
}
// if the string doesnt fit, try to wrap the last word to the next line
- else
- {
+ else {
// find the last space in the line
- pos = m_strText.rfind(L" ",iChar + iMaxChars);
- if(pos != tstring::npos && pos >= iChar)
- iWordOffset = (int)pos +1;
+ pos = m_strText.rfind(L" ", iChar + iMaxChars);
+ if (pos != tstring::npos && pos >= iChar)
+ iWordOffset = (int)pos + 1;
else
- iWordOffset = iChar+iMaxChars;
+ iWordOffset = iChar + iMaxChars;
}
- if(m_Marker[0].iPosition >= iChar && m_Marker[0].iPosition <= iChar + iMaxChars)
- {
- if(m_Marker[0].iPosition > iChar)
- {
- m_Marker[0].iXLine = piWidths[m_Marker[0].iPosition -1 - iChar];
- if(m_strText[m_Marker[0].iPosition -1] == '\n' )
- m_Marker[0].iXLine = 0;
+ if (m_Marker[0].iPosition >= iChar && m_Marker[0].iPosition <= iChar + iMaxChars) {
+ if (m_Marker[0].iPosition > iChar) {
+ m_Marker[0].iXLine = piWidths[m_Marker[0].iPosition - 1 - iChar];
+ if (m_strText[m_Marker[0].iPosition - 1] == '\n')
+ m_Marker[0].iXLine = 0;
}
- if(m_Marker[0].iPosition < iChar + iMaxChars)
- {
- if(m_strText[m_Marker[0].iPosition] > 0x001F)
- m_Marker[0].iXWidth = piWidths[m_Marker[0].iPosition - iChar]-m_Marker[0].iXLine;
+ if (m_Marker[0].iPosition < iChar + iMaxChars) {
+ if (m_strText[m_Marker[0].iPosition] > 0x001F)
+ m_Marker[0].iXWidth = piWidths[m_Marker[0].iPosition - iChar] - m_Marker[0].iXLine;
}
}
-
+
//iChar += iMaxChars;
- if(m_strText[iChar] == '\n' || sizeLine.cx > GetWidth())
- {
-
+ if (m_strText[iChar] == '\n' || sizeLine.cx > GetWidth()) {
+
bLineClosed = true;
int iDistance = INFINITE;
-
+
// Check if a matching offset already exists
- for(int iLine2 = iLine+1;iLine2<m_vLineOffsets.size();iLine2++)
- {
- if(m_vLineOffsets[iLine2].bLineBreak == (m_strText[iChar] == '\n'))
- {
- iDistance = iChar - (m_vLineOffsets[iLine2].iOffset-1);
- if(m_vLineOffsets[iLine2].iOffset == iWordOffset || iDistance == iModified)
- {
+ for (int iLine2 = iLine + 1; iLine2 < m_vLineOffsets.size(); iLine2++) {
+ if (m_vLineOffsets[iLine2].bLineBreak == (m_strText[iChar] == '\n')) {
+ iDistance = iChar - (m_vLineOffsets[iLine2].iOffset - 1);
+ if (m_vLineOffsets[iLine2].iOffset == iWordOffset || iDistance == iModified) {
// if there are other offsets in front of this one, delete them
- if(iLine2 != iLine + 1 )
- {
+ if (iLine2 != iLine + 1) {
// TRACE(L"InputText: Deleted offsets #%i to #%i\n",iLine+1,iLine2-1);
- m_vLineOffsets.erase(m_vLineOffsets.begin()+iLine+1,m_vLineOffsets.begin()+iLine2);
+ m_vLineOffsets.erase(m_vLineOffsets.begin() + iLine + 1, m_vLineOffsets.begin() + iLine2);
}
break;
}
}
}
// A matching offset was found
- if(iDistance == iModified)
- {
- if(iModified != 0)
- {
+ if (iDistance == iModified) {
+ if (iModified != 0) {
// Update line's width
- if(iMaxChars > 0)
- {
- if(m_strText[iChar] == '\n' && iMaxChars >= 2)
- m_vLineOffsets[iLine].iWidth = piWidths[iMaxChars-2];
+ if (iMaxChars > 0) {
+ if (m_strText[iChar] == '\n' && iMaxChars >= 2)
+ m_vLineOffsets[iLine].iWidth = piWidths[iMaxChars - 2];
else
- m_vLineOffsets[iLine].iWidth = piWidths[iMaxChars-1];
+ m_vLineOffsets[iLine].iWidth = piWidths[iMaxChars - 1];
}
else
m_vLineOffsets[iLine].iWidth = 0;
// TRACE(L"InputText: shifted offsets #%i to end %i position(s)\n",iLine+1,iDistance);
- for(iLine++;iLine<m_vLineOffsets.size();iLine++)
+ for (iLine++; iLine < m_vLineOffsets.size(); iLine++)
m_vLineOffsets[iLine].iOffset += iDistance;
-
+
goto finished;
}
}
// if no matching offset was found, a new one has to be created
- else if(iDistance != 0)
- {
+ else if (iDistance != 0) {
SLineEntry offset;
offset.bLineBreak = (m_strText[iChar] == '\n');
offset.iOffset = iWordOffset;
- if(iLine == m_vLineOffsets.size()-1)
+ if (iLine == m_vLineOffsets.size() - 1)
m_vLineOffsets.push_back(offset);
else
- m_vLineOffsets.insert(m_vLineOffsets.begin()+iLine+1,offset);
-
+ m_vLineOffsets.insert(m_vLineOffsets.begin() + iLine + 1, offset);
+
// TRACE(L"InputText: Inserted new %soffset at #%i\n",m_strText[iChar] == '\n'?L"linebreak ":L"",iLine+1);
}
break;
@@ -746,30 +689,28 @@ void CLCDInput::UpdateOffsets(int iModified) iChar += iMaxChars;
}
// Update line's width
- if(iMaxChars > 0)
- {
- if(m_strText[iChar-1] == '\n' && iMaxChars >= 2)
- m_vLineOffsets[iLine].iWidth = piWidths[iMaxChars-2];
+ if (iMaxChars > 0) {
+ if (m_strText[iChar - 1] == '\n' && iMaxChars >= 2)
+ m_vLineOffsets[iLine].iWidth = piWidths[iMaxChars - 2];
else
- m_vLineOffsets[iLine].iWidth = piWidths[iMaxChars-1];
+ m_vLineOffsets[iLine].iWidth = piWidths[iMaxChars - 1];
}
else
m_vLineOffsets[iLine].iWidth = 0;
- if(iLine != m_vLineOffsets.size() - 1 && !bLineClosed)
- {
+ if (iLine != m_vLineOffsets.size() - 1 && !bLineClosed) {
// TRACE(L"InputText: Deleted offsets #%i to #%i\n",iLine+1,m_vLineOffsets.size()-1);
- m_vLineOffsets.erase(m_vLineOffsets.begin()+iLine+1,m_vLineOffsets.end());
+ m_vLineOffsets.erase(m_vLineOffsets.begin() + iLine + 1, m_vLineOffsets.end());
}
-
+
}
finished:
delete[] piWidths;
DeleteObject(hDC);
-
- if(m_pScrollbar)
- m_pScrollbar->SetRange(0, (int)m_vLineOffsets.size()-1);
+
+ if (m_pScrollbar)
+ m_pScrollbar->SetRange(0, (int)m_vLineOffsets.size() - 1);
}
//************************************************************************
@@ -778,10 +719,9 @@ finished: void CLCDInput::UpdateMarker()
{
// Adjust the markers propertys
- for(int i = (int)m_vLineOffsets.size()-1;i>= 0;i--)
- if(m_Marker[0].iPosition >= m_vLineOffsets[i].iOffset)
- {
- if(m_Marker[0].iPosition == m_vLineOffsets[i].iOffset)
+ for (int i = (int)m_vLineOffsets.size() - 1; i >= 0; i--)
+ if (m_Marker[0].iPosition >= m_vLineOffsets[i].iOffset) {
+ if (m_Marker[0].iPosition == m_vLineOffsets[i].iOffset)
m_Marker[0].iXLine = 0;
m_Marker[0].iLine = i;
break;
@@ -793,14 +733,14 @@ void CLCDInput::UpdateMarker() //************************************************************************
bool CLCDInput::ScrollLine(bool bDown)
{
- if(bDown && m_iLinePosition + (m_iLineCount-1) < m_vLineOffsets.size() -1)
- m_iLinePosition++;
- else if(!bDown && m_iLinePosition > 0)
- m_iLinePosition--;
+ if (bDown && m_iLinePosition + (m_iLineCount - 1) < m_vLineOffsets.size() - 1)
+ m_iLinePosition++;
+ else if (!bDown && m_iLinePosition > 0)
+ m_iLinePosition--;
else
return false;
-
- if(m_pScrollbar)
+
+ if (m_pScrollbar)
m_pScrollbar->ScrollTo(m_iLinePosition);
return true;
}
@@ -811,21 +751,21 @@ bool CLCDInput::ScrollLine(bool bDown) //************************************************************************
void CLCDInput::ScrollToMarker()
{
- if(m_Marker[0].iLine < m_iLinePosition)
+ if (m_Marker[0].iLine < m_iLinePosition)
m_iLinePosition = m_Marker[0].iLine;
- if(m_Marker[0].iLine > m_iLinePosition + (m_iLineCount-1))
- {
+
+ if (m_Marker[0].iLine > m_iLinePosition + (m_iLineCount - 1)) {
ScrollLine();
- if(m_Marker[0].iLine > m_iLinePosition + (m_iLineCount-1))
- m_iLinePosition = (m_Marker[0].iLine / m_iLineCount )*m_iLineCount;
+ if (m_Marker[0].iLine > m_iLinePosition + (m_iLineCount - 1))
+ m_iLinePosition = (m_Marker[0].iLine / m_iLineCount)*m_iLineCount;
}
- if(m_iLinePosition > m_vLineOffsets.size()-1)
- m_iLinePosition = (int)m_vLineOffsets.size() -1;
- if(m_iLinePosition < 0)
+ if (m_iLinePosition > m_vLineOffsets.size() - 1)
+ m_iLinePosition = (int)m_vLineOffsets.size() - 1;
+ if (m_iLinePosition < 0)
m_iLinePosition = 0;
- if(m_pScrollbar)
+ if (m_pScrollbar)
m_pScrollbar->ScrollTo(m_iLinePosition);
}
@@ -843,4 +783,4 @@ int CLCDInput::GetLineCount() int CLCDInput::GetLine()
{
return m_iLinePosition;
-}
\ No newline at end of file +}
diff --git a/plugins/MirandaG15/src/LCDFramework/CLCDInput.h b/plugins/MirandaG15/src/LCDFramework/CLCDInput.h index ccf9def536..9fa746ff42 100644 --- a/plugins/MirandaG15/src/LCDFramework/CLCDInput.h +++ b/plugins/MirandaG15/src/LCDFramework/CLCDInput.h @@ -75,18 +75,19 @@ protected: void UpdateMarker();
void MoveMarker(int iDir,int iMove,bool bShift=false);
+
protected:
- bool m_bShowSymbols;
- bool m_iBreakKeys;
+ bool m_bShowSymbols = true;
+ bool m_iBreakKeys = KEYS_RETURN;
- int m_iLineCount;
- long m_lInputTime;
- bool m_bInsert;
+ int m_iLineCount = 0;
+ long m_lInputTime = 0;
+ bool m_bInsert = false;
- long m_lBlinkTimer;
- bool m_bShowMarker;
+ long m_lBlinkTimer = 0;
+ bool m_bShowMarker = false;
- int m_iLinePosition;
+ int m_iLinePosition = 0;
SMarker m_Marker[2];
// Text variables
@@ -95,11 +96,11 @@ protected: // Input variables
static CLCDInput* m_pInput;
- HHOOK m_hKBHook;
+ HHOOK m_hKBHook = nullptr;
BYTE m_acKeyboardState[256];
// Scrollbar
- CLCDBar *m_pScrollbar;
+ CLCDBar *m_pScrollbar = nullptr;
};
diff --git a/plugins/MirandaG15/src/LCDFramework/CLCDLabel.cpp b/plugins/MirandaG15/src/LCDFramework/CLCDLabel.cpp index 3a87774f97..aa21147214 100644 --- a/plugins/MirandaG15/src/LCDFramework/CLCDLabel.cpp +++ b/plugins/MirandaG15/src/LCDFramework/CLCDLabel.cpp @@ -8,8 +8,7 @@ //************************************************************************
// constructor
//************************************************************************
-CLCDLabel::CLCDLabel() : m_bCutOff(true), m_bWordWrap(false), m_iCutOffIndex(0),
- m_iLineCount(0)
+CLCDLabel::CLCDLabel()
{
m_strText = L"";
}
@@ -26,7 +25,7 @@ CLCDLabel::~CLCDLabel() //************************************************************************
bool CLCDLabel::Initialize()
{
- if(!CLCDTextObject::Initialize())
+ if (!CLCDTextObject::Initialize())
return false;
return true;
@@ -37,7 +36,7 @@ bool CLCDLabel::Initialize() //************************************************************************
bool CLCDLabel::Shutdown()
{
- if(!CLCDTextObject::Shutdown())
+ if (!CLCDTextObject::Shutdown())
return false;
return true;
@@ -48,7 +47,7 @@ bool CLCDLabel::Shutdown() //************************************************************************
bool CLCDLabel::Update()
{
- if(!CLCDTextObject::Update())
+ if (!CLCDTextObject::Update())
return false;
return true;
@@ -59,17 +58,16 @@ bool CLCDLabel::Update() //************************************************************************
bool CLCDLabel::Draw(CLCDGfx *pGfx)
{
- if(!CLCDTextObject::Draw(pGfx))
+ if (!CLCDTextObject::Draw(pGfx))
return false;
- SelectObject(pGfx->GetHDC(),m_hFont);
+ SelectObject(pGfx->GetHDC(), m_hFont);
- int iTop = (int)(GetHeight()-(m_vLines.size()*m_iFontHeight))/2;///2;//()/2;
- RECT rBoundary = {0,iTop,GetWidth(), GetHeight()-iTop};
+ int iTop = (int)(GetHeight() - (m_vLines.size()*m_iFontHeight)) / 2;///2;//()/2;
+ RECT rBoundary = {0,iTop,GetWidth(), GetHeight() - iTop};
vector<tstring>::iterator iter = m_vLines.begin();
- while(!m_vLines.empty() && iter != m_vLines.end())
- {
+ while (!m_vLines.empty() && iter != m_vLines.end()) {
DrawTextEx(pGfx->GetHDC(), (LPTSTR)(*iter).c_str(), (int)(*iter).length(), &rBoundary, m_iTextFormat, &m_dtp);
rBoundary.top += m_iFontHeight;
iter++;
@@ -100,7 +98,7 @@ void CLCDLabel::OnFontChanged() //************************************************************************
void CLCDLabel::OnSizeChanged(SIZE OldSize)
{
- if(GetWidth() == OldSize.cx && GetHeight() == OldSize.cy)
+ if (GetWidth() == OldSize.cx && GetHeight() == OldSize.cy)
return;
UpdateCutOffIndex();
}
@@ -119,102 +117,88 @@ void CLCDLabel::SetWordWrap(bool bEnable) void CLCDLabel::UpdateCutOffIndex()
{
int iLen = (int)m_strText.length();
-
+
m_vLines.clear();
- if(iLen <= 0)
- {
+ if (iLen <= 0) {
m_strCutOff = L"";
m_iCutOffIndex = 0;
return;
}
+
// variables
-
HDC hDC = CreateCompatibleDC(nullptr);
- SelectObject(hDC, m_hFont);
-
- if(nullptr == hDC)
+ SelectObject(hDC, m_hFont);
+
+ if (nullptr == hDC)
return;
int iWidth = GetWidth();
- SIZE sizeLine = {0, 0};
+ SIZE sizeLine = {0, 0};
SIZE sizeCutOff = {0, 0};
- int iAvailableLines = GetHeight()/m_iFontHeight;
+ int iAvailableLines = GetHeight() / m_iFontHeight;
// unitialized or too small labels need to be handled
- if(iAvailableLines <= 0)
+ if (iAvailableLines <= 0)
iAvailableLines = 1;
// process wordwrapping
int i = 0;
- if(m_bWordWrap && GetWidth() > 0)
- {
+ if (m_bWordWrap && GetWidth() > 0) {
int *piExtents = new int[m_strText.length()];
wchar_t *szString = (wchar_t*)m_strText.c_str();
int iMaxChars = 0;
tstring::size_type pos = 0;
- while(i<iLen && m_vLines.size() < iAvailableLines)
- {
- GetTextExtentExPoint(hDC, szString+i, (int)m_strText.length()-i, GetWidth(), &iMaxChars, piExtents, &sizeLine);
-
+ while (i < iLen && m_vLines.size() < iAvailableLines) {
+ GetTextExtentExPoint(hDC, szString + i, (int)m_strText.length() - i, GetWidth(), &iMaxChars, piExtents, &sizeLine);
+
// filter out spaces or line breaks at the beginning of a new line
- if(m_strText[i] == '\n' || m_strText[i] == ' ')
+ if (m_strText[i] == '\n' || m_strText[i] == ' ')
i++;
- pos = m_strText.find(L"\n",i);
+ pos = m_strText.find(L"\n", i);
// check for linebreaks
- if(pos != tstring::npos && pos != i && pos >= i && pos != i+iMaxChars)
+ if (pos != tstring::npos && pos != i && pos >= i && pos != i + iMaxChars)
iMaxChars = 1 + (int)pos - i;
// if the string doesnt fit, try to wrap the last word to the next line
- else if(iMaxChars < iLen - i || sizeLine.cx >= GetWidth())
- {
+ else if (iMaxChars < iLen - i || sizeLine.cx >= GetWidth()) {
// find the last space in the line ( substract -1 from offset to ignore spaces as last chars )
- pos = m_strText.rfind(L" ",i + iMaxChars -1 );
- if(pos != tstring::npos && pos != i && pos >= i && pos != i+iMaxChars)
+ pos = m_strText.rfind(L" ", i + iMaxChars - 1);
+ if (pos != tstring::npos && pos != i && pos >= i && pos != i + iMaxChars)
iMaxChars = 1 + (int)pos - i;
}
- if(m_vLines.size() == iAvailableLines-1)
+ if (m_vLines.size() == iAvailableLines - 1)
iMaxChars = iLen - i;
- m_vLines.push_back(m_strText.substr(i,iMaxChars));
+ m_vLines.push_back(m_strText.substr(i, iMaxChars));
i += iMaxChars;
}
delete[] piExtents;
}
- else
- m_vLines.push_back(m_strText);
+ else m_vLines.push_back(m_strText);
// calculate the cutoff position
-
- GetTextExtentPoint(hDC,L"...",3,&sizeCutOff);
+ GetTextExtentPoint(hDC, L"...", 3, &sizeCutOff);
int *piWidths = new int[(*--m_vLines.end()).length()];
int iMaxChars = 0;
- GetTextExtentExPoint(hDC,(*--m_vLines.end()).c_str(),(int)(*--m_vLines.end()).length(),iWidth,&iMaxChars,piWidths,&sizeLine);
-
- if(iMaxChars < (*--m_vLines.end()).length())
- {
- for(iMaxChars--;iMaxChars>0;iMaxChars--)
- {
- if(piWidths[iMaxChars] + sizeCutOff.cx <= iWidth)
+ GetTextExtentExPoint(hDC, (*--m_vLines.end()).c_str(), (int)(*--m_vLines.end()).length(), iWidth, &iMaxChars, piWidths, &sizeLine);
+
+ if (iMaxChars < (*--m_vLines.end()).length()) {
+ for (iMaxChars--; iMaxChars > 0; iMaxChars--) {
+ if (piWidths[iMaxChars] + sizeCutOff.cx <= iWidth)
break;
}
- (*--m_vLines.end()) = (*--m_vLines.end()).substr(0,iMaxChars) + L"...";
+ (*--m_vLines.end()) = (*--m_vLines.end()).substr(0, iMaxChars) + L"...";
}
delete[] piWidths;
DeleteObject(hDC);
- //if(GetWidth() == 0)
- m_iLineCount = 1;
- //else
- // m_iLineCount = ceil((double)(sizeLine.cx + sizeCutOff.cx)/GetWidth());
-
- //if(m_iLineCount > GetHeight()/m_iFontHeight)
- // m_iLineCount = GetHeight()/m_iFontHeight;
+ m_iLineCount = 1;
}
//************************************************************************
@@ -223,4 +207,4 @@ void CLCDLabel::UpdateCutOffIndex() void CLCDLabel::SetCutOff(bool bEnable)
{
m_bCutOff = bEnable;
-}
\ No newline at end of file +}
diff --git a/plugins/MirandaG15/src/LCDFramework/CLCDLabel.h b/plugins/MirandaG15/src/LCDFramework/CLCDLabel.h index b2bcc5bc3b..85bfe3d9c5 100644 --- a/plugins/MirandaG15/src/LCDFramework/CLCDLabel.h +++ b/plugins/MirandaG15/src/LCDFramework/CLCDLabel.h @@ -38,13 +38,13 @@ private: // called when the labels font has changed
void OnFontChanged();
- bool m_bWordWrap;
+ bool m_bWordWrap = false;
- bool m_bCutOff;
- int m_iCutOffIndex;
+ bool m_bCutOff = true;
+ int m_iCutOffIndex = 0;
tstring m_strText;
tstring m_strCutOff;
- int m_iLineCount;
+ int m_iLineCount = 0;
vector<tstring> m_vLines;
};
diff --git a/plugins/MirandaG15/src/LCDFramework/CLCDList.h b/plugins/MirandaG15/src/LCDFramework/CLCDList.h index 84be7da53a..52b623fecc 100644 --- a/plugins/MirandaG15/src/LCDFramework/CLCDList.h +++ b/plugins/MirandaG15/src/LCDFramework/CLCDList.h @@ -5,31 +5,29 @@ #include "CLCDBar.h" #include <math.h> - -enum EListEntryType { ROOT = 0,CONTAINER = 1,ITEM = 2}; +enum EListEntryType { ROOT = 0, CONTAINER = 1, ITEM = 2 }; template <class T, class G = tstring> class CListEntry { public: - CListEntry(CListEntry<T,G> *pParent) + CListEntry(CListEntry<T, G> *pParent) { m_iIndex = -1; m_iEntryCount = 0; m_Position = nullptr; m_pParent = pParent; - if(pParent == nullptr) - { + if (pParent == nullptr) { m_iLevel = 0; m_eType = ROOT; m_pRoot = this; } else - m_iLevel = m_pParent->GetLevel()+1; + m_iLevel = m_pParent->GetLevel() + 1; } - + virtual ~CListEntry() { - + } int GetLevel() @@ -37,37 +35,37 @@ public: return m_iLevel; } - virtual CListEntry<T,G> *GetNextEntry() + virtual CListEntry<T, G> *GetNextEntry() { - if(m_pParent == nullptr) + if (m_pParent == nullptr) return nullptr; return m_pParent->GetNextEntry(this); } - - virtual CListEntry<T,G> *GetPreviousEntry() + + virtual CListEntry<T, G> *GetPreviousEntry() { - if(m_pParent == nullptr) + if (m_pParent == nullptr) return nullptr; return m_pParent->GetPreviousEntry(this); } - virtual CListEntry<T,G> *GetNextEntry(CListEntry<T,G>*) + virtual CListEntry<T, G> *GetNextEntry(CListEntry<T, G>*) { return nullptr; } - virtual CListEntry<T,G> *GetPreviousEntry(CListEntry<T,G>*) + virtual CListEntry<T, G> *GetPreviousEntry(CListEntry<T, G>*) { return nullptr; } - + EListEntryType GetType() { return m_eType; } - + int GetEntryCount() { return m_iEntryCount; @@ -78,7 +76,7 @@ public: m_iEntryCount = 0; } - void SetRoot(CListEntry<T,G>* pRoot) + void SetRoot(CListEntry<T, G>* pRoot) { m_pRoot = pRoot; } @@ -91,21 +89,21 @@ public: { } - CListEntry<T,G> *GetPosition() + CListEntry<T, G> *GetPosition() { return m_Position; } - - virtual void SetPosition(CListEntry<T,G> *pPosition) + + virtual void SetPosition(CListEntry<T, G> *pPosition) { m_Position = pPosition; } - CListEntry<T,G> *GetParent() + CListEntry<T, G> *GetParent() { return m_pParent; } - + int GetIndex() { return m_iIndex; @@ -121,20 +119,20 @@ protected: int m_iEntryCount; int m_iLevel; EListEntryType m_eType; - CListEntry<T,G> *m_pParent; - CListEntry<T,G> *m_pRoot; - CListEntry<T,G> *m_Position; + CListEntry<T, G> *m_pParent; + CListEntry<T, G> *m_pRoot; + CListEntry<T, G> *m_Position; }; -template <class T, class G = tstring> class CListItem : public CListEntry<T,G> +template <class T, class G = tstring> class CListItem : public CListEntry<T, G> { public: - CListItem(CListEntry<T,G> *pParent,T Entry) : CListEntry<T,G>(pParent) + CListItem(CListEntry<T, G> *pParent, T Entry) : CListEntry<T, G>(pParent) { m_Item = Entry; m_eType = ITEM; } - + ~CListItem() { m_pRoot->DeleteItem(GetItemData()); @@ -148,22 +146,22 @@ private: T m_Item; }; -template <class T, class G = tstring> class CListContainer : public CListEntry<T,G> +template <class T, class G = tstring> class CListContainer : public CListEntry<T, G> { public: - typedef typename list<CListEntry<T,G>* >::iterator iterator; + typedef typename list<CListEntry<T, G>* >::iterator iterator; - typename list<CListEntry<T,G>* >::iterator end() + typename list<CListEntry<T, G>* >::iterator end() { return m_Entrys.end(); } - - typename list<CListEntry<T,G>* >::iterator begin() + + typename list<CListEntry<T, G>* >::iterator begin() { return m_Entrys.begin(); } - typename list<CListEntry<T,G>* >::size_type size() + typename list<CListEntry<T, G>* >::size_type size() { return m_Entrys.size(); } @@ -173,10 +171,9 @@ public: return m_Entrys.empty(); } - CListContainer(CListEntry<T,G> *pParent) : CListEntry<T,G>(pParent) + CListContainer(CListEntry<T, G> *pParent) : CListEntry<T, G>(pParent) { - if(m_pParent != nullptr) - { + if (m_pParent != nullptr) { m_eType = CONTAINER; m_bOpen = false; } @@ -186,7 +183,7 @@ public: ~CListContainer() { - if(m_pRoot != nullptr) { + if (m_pRoot != nullptr) { m_pRoot->DeleteGroup(GetGroupData()); } Clear(); @@ -194,19 +191,17 @@ public: void Clear() { - list< CListEntry<T,G>* >::iterator iter = m_Entrys.begin(); + list< CListEntry<T, G>* >::iterator iter = m_Entrys.begin(); - while(iter != m_Entrys.end()) - { + while (iter != m_Entrys.end()) { delete *iter; - if(m_pRoot && m_pRoot->GetPosition() == *iter) - { - if(GetType() == ROOT) + if (m_pRoot && m_pRoot->GetPosition() == *iter) { + if (GetType() == ROOT) m_pRoot->SetPosition(nullptr); else m_pRoot->SetPosition(this); } - + iter++; } m_Entrys.clear(); @@ -222,39 +217,37 @@ public: return m_Entrys.empty(); } - CListEntry<T,G> *GetLastOwnEntry() + CListEntry<T, G> *GetLastOwnEntry() { - if(m_Entrys.empty()) + if (m_Entrys.empty()) return nullptr; return *(--m_Entrys.end()); } - CListEntry<T,G> *GetLastEntry() + CListEntry<T, G> *GetLastEntry() { - if(!m_Entrys.empty()) - { + if (!m_Entrys.empty()) { - CListEntry<T,G> *pEntry = *(--m_Entrys.end()); - if(pEntry->GetType() == ITEM || !((CListContainer<T,G>*)pEntry)->IsOpen() || ((CListContainer<T,G>*)pEntry)->IsEmpty()) + CListEntry<T, G> *pEntry = *(--m_Entrys.end()); + if (pEntry->GetType() == ITEM || !((CListContainer<T, G>*)pEntry)->IsOpen() || ((CListContainer<T, G>*)pEntry)->IsEmpty()) return pEntry; - return ((CListContainer<T,G>*)pEntry)->GetLastEntry(); + return ((CListContainer<T, G>*)pEntry)->GetLastEntry(); } return nullptr; } - CListEntry<T,G> *GetFirstEntry() + CListEntry<T, G> *GetFirstEntry() { - if(!m_Entrys.empty()) + if (!m_Entrys.empty()) return *(m_Entrys.begin()); return nullptr; } - CListEntry<T,G> *GetNextEntry() + CListEntry<T, G> *GetNextEntry() { - if(!IsOpen() || m_Entrys.empty()) - { - if(!m_pParent) + if (!IsOpen() || m_Entrys.empty()) { + if (!m_pParent) return nullptr; return m_pParent->GetNextEntry(this); } @@ -262,16 +255,13 @@ public: return *m_Entrys.begin(); } - CListEntry<T,G> *GetNextEntry(CListEntry<T,G> *pEntry) + CListEntry<T, G> *GetNextEntry(CListEntry<T, G> *pEntry) { - list< CListEntry<T,G>* >::iterator iter = m_Entrys.begin(); - while(iter != m_Entrys.end()) - { - if((CListEntry<T,G>*)(*iter) == pEntry) - { - if(++iter == m_Entrys.end()) - { - if(m_pParent == nullptr) + list< CListEntry<T, G>* >::iterator iter = m_Entrys.begin(); + while (iter != m_Entrys.end()) { + if ((CListEntry<T, G>*)(*iter) == pEntry) { + if (++iter == m_Entrys.end()) { + if (m_pParent == nullptr) return nullptr; return m_pParent->GetNextEntry(this); } @@ -283,27 +273,22 @@ public: return nullptr; } - CListEntry<T,G> *GetPreviousEntry(CListEntry<T,G> *pEntry) + CListEntry<T, G> *GetPreviousEntry(CListEntry<T, G> *pEntry) { - list< CListEntry<T,G>* >::iterator iter = m_Entrys.begin(); + list< CListEntry<T, G>* >::iterator iter = m_Entrys.begin(); - while(iter != m_Entrys.end()) - { - if((CListEntry<T,G>*)(*iter) == pEntry) - { - if(iter == m_Entrys.begin()) - { - if(m_pParent == nullptr) + while (iter != m_Entrys.end()) { + if ((CListEntry<T, G>*)(*iter) == pEntry) { + if (iter == m_Entrys.begin()) { + if (m_pParent == nullptr) return nullptr; return this; } - else - { + else { iter--; - if((*iter)->GetType() == CONTAINER) - { - CListContainer<T,G>* pContainer = (CListContainer<T,G>*)*iter; - if(pContainer->IsOpen() && !pContainer->IsEmpty()) + if ((*iter)->GetType() == CONTAINER) { + CListContainer<T, G>* pContainer = (CListContainer<T, G>*)*iter; + if (pContainer->IsOpen() && !pContainer->IsEmpty()) return pContainer->GetLastEntry(); } return *iter; @@ -314,57 +299,53 @@ public: return nullptr; } - virtual CListItem<T,G> *InsertItem(iterator _Where,T Entry) + virtual CListItem<T, G> *InsertItem(iterator _Where, T Entry) { - CListItem<T,G> *pItem = new CListItem<T,G>(this,Entry); + CListItem<T, G> *pItem = new CListItem<T, G>(this, Entry); pItem->SetRoot(m_pRoot); - m_Entrys.insert(_Where,pItem); + m_Entrys.insert(_Where, pItem); m_pRoot->UpdateEntryCount(); return pItem; } - virtual CListContainer<T,G> *InsertGroup(iterator _Where,G Group) + virtual CListContainer<T, G> *InsertGroup(iterator _Where, G Group) { - CListContainer<T,G> *pGroup = new CListContainer<T,G>(this); + CListContainer<T, G> *pGroup = new CListContainer<T, G>(this); pGroup->SetGroupData(Group); pGroup->SetRoot(m_pRoot); - m_Entrys.insert(_Where,(CListEntry<T,G>*)pGroup); - + m_Entrys.insert(_Where, (CListEntry<T, G>*)pGroup); + m_pRoot->UpdateEntryCount(); return pGroup; } - virtual CListItem<T,G> * AddItem(T Entry) + virtual CListItem<T, G> * AddItem(T Entry) { - return InsertItem(end(),Entry); + return InsertItem(end(), Entry); } - virtual CListContainer<T,G> * AddGroup(G Group) + virtual CListContainer<T, G> * AddGroup(G Group) { - return InsertGroup(end(),Group); + return InsertGroup(end(), Group); } - - + + virtual void RemoveGroup(G Group) { - list< CListEntry<T,G>* >::iterator iter = m_Entrys.begin(); - CListContainer<T,G> *pContainer = nullptr; - while(iter != m_Entrys.end()) - { - if((*iter)->GetType() == CONTAINER) - { - pContainer = (CListContainer<T,G>*)(*iter); - if(pContainer->GetGroupData() == Group) - { + list< CListEntry<T, G>* >::iterator iter = m_Entrys.begin(); + CListContainer<T, G> *pContainer = nullptr; + while (iter != m_Entrys.end()) { + if ((*iter)->GetType() == CONTAINER) { + pContainer = (CListContainer<T, G>*)(*iter); + if (pContainer->GetGroupData() == Group) { pContainer->Clear(); - if(m_pRoot && m_pRoot->GetPosition() == *iter) - { - CListEntry<T,G> *pPosition = (*iter)->GetPreviousEntry(); - if(!pPosition) + if (m_pRoot && m_pRoot->GetPosition() == *iter) { + CListEntry<T, G> *pPosition = (*iter)->GetPreviousEntry(); + if (!pPosition) pPosition = (*iter)->GetNextEntry(); m_pRoot->SetPosition(pPosition); } @@ -381,24 +362,20 @@ public: virtual void RemoveItem(T Entry) { - list< CListEntry<T,G>* >::iterator iter = m_Entrys.begin(); - CListItem<T,G> *pItem = nullptr; - while(iter != m_Entrys.end()) - { - if((*iter)->GetType() == ITEM) - { - pItem = (CListItem<T,G>*)(*iter); - if(pItem->GetItemData() == Entry) - { - if(m_pRoot && m_pRoot->GetPosition() == *iter) - { - CListEntry<T,G> *pPosition = (*iter)->GetPreviousEntry(); - if(!pPosition) + list< CListEntry<T, G>* >::iterator iter = m_Entrys.begin(); + CListItem<T, G> *pItem = nullptr; + while (iter != m_Entrys.end()) { + if ((*iter)->GetType() == ITEM) { + pItem = (CListItem<T, G>*)(*iter); + if (pItem->GetItemData() == Entry) { + if (m_pRoot && m_pRoot->GetPosition() == *iter) { + CListEntry<T, G> *pPosition = (*iter)->GetPreviousEntry(); + if (!pPosition) pPosition = (*iter)->GetNextEntry(); m_pRoot->SetPosition(pPosition); } delete *iter; - + m_Entrys.erase(iter); if (m_pRoot) m_pRoot->UpdateEntryCount(); @@ -409,23 +386,21 @@ public: } } - CListContainer<T,G> *GetGroup(G Group) + CListContainer<T, G> *GetGroup(G Group) { - list< CListEntry<T,G>* >::iterator iter = m_Entrys.begin(); - CListContainer<T,G> *pContainer = nullptr; - while(iter != m_Entrys.end()) - { - if((*iter)->GetType() == CONTAINER) - { - pContainer = (CListContainer<T,G>*)(*iter); - if(pContainer->GetGroupData() == Group) + list< CListEntry<T, G>* >::iterator iter = m_Entrys.begin(); + CListContainer<T, G> *pContainer = nullptr; + while (iter != m_Entrys.end()) { + if ((*iter)->GetType() == CONTAINER) { + pContainer = (CListContainer<T, G>*)(*iter); + if (pContainer->GetGroupData() == Group) return pContainer; } iter++; } return nullptr; } - + G GetGroupData() { return m_GroupData; @@ -435,20 +410,20 @@ public: { return m_bOpen; } - + void ToggleOpen() { m_bOpen = !m_bOpen; - + if (m_pRoot) { m_pRoot->UpdateEntryCount(); m_pRoot->SetPosition(this); } } - + void SetOpen(bool bOpen = true) { - if(bOpen == m_bOpen) + if (bOpen == m_bOpen) return; m_bOpen = bOpen; @@ -458,32 +433,28 @@ public: m_pRoot->SetPosition(this); } } - + void CollapseAll() { - list< CListEntry<T,G>* >::iterator iter = m_Entrys.begin(); - CListContainer<T,G>* pContainer = nullptr; - while(iter != m_Entrys.end()) - { - if((*iter)->GetType() == CONTAINER) - { - pContainer = (CListContainer<T,G>*)(*iter); + list< CListEntry<T, G>* >::iterator iter = m_Entrys.begin(); + CListContainer<T, G>* pContainer = nullptr; + while (iter != m_Entrys.end()) { + if ((*iter)->GetType() == CONTAINER) { + pContainer = (CListContainer<T, G>*)(*iter); pContainer->CollapseAll(); pContainer->SetOpen(false); } iter++; } } - + void ExpandAll() { - list< CListEntry<T,G>* >::iterator iter = m_Entrys.begin(); - CListContainer<T,G>* pContainer = nullptr; - while(iter != m_Entrys.end()) - { - if((*iter)->GetType() == CONTAINER) - { - pContainer = (CListContainer<T,G>*)(*iter); + list< CListEntry<T, G>* >::iterator iter = m_Entrys.begin(); + CListContainer<T, G>* pContainer = nullptr; + while (iter != m_Entrys.end()) { + if ((*iter)->GetType() == CONTAINER) { + pContainer = (CListContainer<T, G>*)(*iter); pContainer->ExpandAll(); pContainer->SetOpen(true); } @@ -495,53 +466,53 @@ public: { m_iEntryCount = 0; - int iIndex = GetIndex()+1; - - if(!IsOpen()) + int iIndex = GetIndex() + 1; + + if (!IsOpen()) return; - list< CListEntry<T,G>* >::iterator iter = m_Entrys.begin(); - while(iter != m_Entrys.end()) - { - (*iter)->SetIndex(iIndex+m_iEntryCount); + list< CListEntry<T, G>* >::iterator iter = m_Entrys.begin(); + while (iter != m_Entrys.end()) { + (*iter)->SetIndex(iIndex + m_iEntryCount); (*iter)->UpdateEntryCount(); - m_iEntryCount += 1+(*iter)->GetEntryCount(); + m_iEntryCount += 1 + (*iter)->GetEntryCount(); iter++; } - if(GetType() == ROOT) - { - if(GetPosition() == nullptr && !m_Entrys.empty()) + if (GetType() == ROOT) { + if (GetPosition() == nullptr && !m_Entrys.empty()) SetPosition(*m_Entrys.begin()); else SetPosition(GetPosition()); } } - + template<class _Pr3> - void sort(_Pr3 _Pred) { + void sort(_Pr3 _Pred) + { m_Entrys.sort(_Pred); UpdateEntryCount(); m_pRoot->SetPosition(m_pRoot->GetPosition()); } private: - typename list< CListEntry<T,G>* > m_Entrys; + typename list< CListEntry<T, G>* > m_Entrys; G m_GroupData; bool m_bOpen; }; -template <class T, class G = tstring> class CLCDList : public CLCDTextObject, public CListContainer<T,G> +template <class T, class G = tstring> class CLCDList : public CLCDTextObject, public CListContainer<T, G> { -friend CListContainer<T,G>; -friend CListItem<T,G>; + friend CListContainer<T, G>; + friend CListItem<T, G>; + public: //************************************************************************ // Constructor //************************************************************************ - CLCDList() : CListContainer<T,G>(nullptr) + CLCDList() : CListContainer<T, G>(nullptr) { m_pScrollbar = nullptr; m_iIndention = 10; @@ -562,7 +533,7 @@ public: //************************************************************************ bool Initialize() { - if(!CLCDTextObject::Initialize()) + if (!CLCDTextObject::Initialize()) return false; return true; @@ -573,11 +544,10 @@ public: //************************************************************************ bool Shutdown() { - if(!CLCDTextObject::Shutdown()) + if (!CLCDTextObject::Shutdown()) return false; - - Clear(); + Clear(); return true; } @@ -586,7 +556,7 @@ public: //************************************************************************ bool Update() { - if(!CLCDTextObject::Update()) + if (!CLCDTextObject::Update()) return false; return true; @@ -597,174 +567,164 @@ public: //************************************************************************ bool Draw(CLCDGfx *pGfx) { - if(!CLCDTextObject::Draw(pGfx)) + if (!CLCDTextObject::Draw(pGfx)) return false; - - SelectObject(pGfx->GetHDC(),m_hFont); - POINT ptPrevViewportOrg = { 0, 0 }; + SelectObject(pGfx->GetHDC(), m_hFont); + + POINT ptPrevViewportOrg = {0, 0}; int iHeight = 0; - int iYOffset = 0, iXOffset=0; - int iColWidth = (GetWidth()- (m_iColumns-1)*3)/m_iColumns; - int iSpace = GetHeight() - (GetHeight()/m_iEntryHeight)*m_iEntryHeight; - int iPerPage = (GetHeight()/m_iEntryHeight)*m_iColumns; - + int iYOffset = 0, iXOffset = 0; + int iColWidth = (GetWidth() - (m_iColumns - 1) * 3) / m_iColumns; + int iSpace = GetHeight() - (GetHeight() / m_iEntryHeight)*m_iEntryHeight; + int iPerPage = (GetHeight() / m_iEntryHeight)*m_iColumns; + int iEntriesDrawn = 0; - CListEntry<T,G> *pPosition = m_Position; - + CListEntry<T, G> *pPosition = m_Position; + // if nothing is selected, skip drawing - if(pPosition == nullptr) + if (pPosition == nullptr) return true; bool bDrawGroup = false; bool bSelected = false; // calculate the start offset - - if(m_iStartIndex < pPosition->GetIndex()) - { - while(pPosition && pPosition->GetIndex() != m_iStartIndex) + + if (m_iStartIndex < pPosition->GetIndex()) { + while (pPosition && pPosition->GetIndex() != m_iStartIndex) pPosition = pPosition->GetPreviousEntry(); } - - if(m_iStartIndex > 0 && pPosition->GetIndex() > 0) + + if (m_iStartIndex > 0 && pPosition->GetIndex() > 0) pPosition = pPosition->GetPreviousEntry(); - for(int iCol = 0;iCol<m_iColumns;iCol++) - { + for (int iCol = 0; iCol < m_iColumns; iCol++) { iHeight = 0; - if(iCol == 0) - { - if(pPosition->GetIndex() < m_iStartIndex) - iHeight -= m_iEntryHeight-iSpace; - else if(GetEntryCount() >= (iPerPage/m_iColumns) +1) + if (iCol == 0) { + if (pPosition->GetIndex() < m_iStartIndex) + iHeight -= m_iEntryHeight - iSpace; + else if (GetEntryCount() >= (iPerPage / m_iColumns) + 1) iHeight = iSpace; } // bottom selection - while(pPosition != nullptr) - { + while (pPosition != nullptr) { iYOffset = iHeight; bSelected = m_Position == pPosition; bDrawGroup = pPosition->GetType() == CONTAINER; - + // ~~~~~~~~~~~~~~~~~~~~~~ // Draw tree lines // ~~~~~~~~~~~~~~~~~~~~~~ // set the clip region for the entry int iClipHeight = m_iEntryHeight; - if(GetOrigin().y+iYOffset+iClipHeight > GetOrigin().y + GetHeight()) + if (GetOrigin().y + iYOffset + iClipHeight > GetOrigin().y + GetHeight()) iClipHeight = GetHeight() - iYOffset; - pGfx->SetClipRegion(GetOrigin().x+iXOffset,GetOrigin().y+iYOffset, - iColWidth, iClipHeight); - + pGfx->SetClipRegion(GetOrigin().x + iXOffset, GetOrigin().y + iYOffset, + iColWidth, iClipHeight); + // offset the control at its origin so entry use (0,0) SetViewportOrgEx(pGfx->GetHDC(), - GetOrigin().x+iXOffset, - GetOrigin().y+iYOffset, - &ptPrevViewportOrg); - - if(m_bDrawTreeLines) - { - for(int i=1;i<pPosition->GetLevel();i++) - { - if(i == pPosition->GetLevel()-1) - { + GetOrigin().x + iXOffset, + GetOrigin().y + iYOffset, + &ptPrevViewportOrg); + + if (m_bDrawTreeLines) { + for (int i = 1; i < pPosition->GetLevel(); i++) { + if (i == pPosition->GetLevel() - 1) { // - - pGfx->DrawLine((i-1)*m_iIndention+m_iIndention/2,m_iEntryHeight/2,i*m_iIndention,m_iEntryHeight/2); + pGfx->DrawLine((i - 1)*m_iIndention + m_iIndention / 2, m_iEntryHeight / 2, i*m_iIndention, m_iEntryHeight / 2); // | - if(pPosition == ((CListContainer<T,G>*)pPosition->GetParent())->GetLastOwnEntry()) - pGfx->DrawLine((i-1)*m_iIndention+m_iIndention/2,0,(i-1)*m_iIndention+m_iIndention/2,m_iEntryHeight/2); + if (pPosition == ((CListContainer<T, G>*)pPosition->GetParent())->GetLastOwnEntry()) + pGfx->DrawLine((i - 1)*m_iIndention + m_iIndention / 2, 0, (i - 1)*m_iIndention + m_iIndention / 2, m_iEntryHeight / 2); // | // | else - pGfx->DrawLine((i-1)*m_iIndention+m_iIndention/2,0,(i-1)*m_iIndention+m_iIndention/2,m_iEntryHeight); + pGfx->DrawLine((i - 1)*m_iIndention + m_iIndention / 2, 0, (i - 1)*m_iIndention + m_iIndention / 2, m_iEntryHeight); } - else - { - CListEntry<T,G> *pPosition2 = pPosition; - for(int j = pPosition->GetLevel();j>i+1;j--) + else { + CListEntry<T, G> *pPosition2 = pPosition; + for (int j = pPosition->GetLevel(); j > i + 1; j--) pPosition2 = pPosition2->GetParent(); // | // | - if(pPosition2 != ((CListContainer<T,G>*)pPosition2->GetParent())->GetLastOwnEntry()) - pGfx->DrawLine((i-1)*m_iIndention+m_iIndention/2,0,(i-1)*m_iIndention+m_iIndention/2,m_iEntryHeight); - } + if (pPosition2 != ((CListContainer<T, G>*)pPosition2->GetParent())->GetLastOwnEntry()) + pGfx->DrawLine((i - 1)*m_iIndention + m_iIndention / 2, 0, (i - 1)*m_iIndention + m_iIndention / 2, m_iEntryHeight); + } } } // ~~~~~~~~~~~~~~~~~~~~~~ // Draw the entry // ~~~~~~~~~~~~~~~~~~~~~~ - pGfx->SetClipRegion(GetOrigin().x+(pPosition->GetLevel()-1)*m_iIndention+iXOffset, - GetOrigin().y+iYOffset, - iColWidth-(pPosition->GetLevel()-1)*m_iIndention, - iClipHeight); + pGfx->SetClipRegion(GetOrigin().x + (pPosition->GetLevel() - 1)*m_iIndention + iXOffset, + GetOrigin().y + iYOffset, + iColWidth - (pPosition->GetLevel() - 1)*m_iIndention, + iClipHeight); // set the offset SetViewportOrgEx(pGfx->GetHDC(), - GetOrigin().x+(pPosition->GetLevel()-1)*m_iIndention+iXOffset, - GetOrigin().y+iYOffset, - &ptPrevViewportOrg); + GetOrigin().x + (pPosition->GetLevel() - 1)*m_iIndention + iXOffset, + GetOrigin().y + iYOffset, + &ptPrevViewportOrg); // draw the entry - if(!bDrawGroup) - DrawEntry(pGfx,((CListItem<T,G>*)pPosition)->GetItemData(),bSelected); + if (!bDrawGroup) + DrawEntry(pGfx, ((CListItem<T, G>*)pPosition)->GetItemData(), bSelected); else - // draw the group - DrawGroup(pGfx,((CListContainer<T,G>*)pPosition)->GetGroupData(),((CListContainer<T,G>*)pPosition)->IsOpen(),bSelected); - + // draw the group + DrawGroup(pGfx, ((CListContainer<T, G>*)pPosition)->GetGroupData(), ((CListContainer<T, G>*)pPosition)->IsOpen(), bSelected); + // ~~~~~~~~~~~~~~~~~~~~~~ - if(pPosition->GetIndex() >= m_iStartIndex && iHeight + m_iEntryHeight <= GetHeight()) + if (pPosition->GetIndex() >= m_iStartIndex && iHeight + m_iEntryHeight <= GetHeight()) iEntriesDrawn++; - + iHeight += m_iEntryHeight; pPosition = pPosition->GetNextEntry(); - - if(iHeight >= GetHeight()) + + if (iHeight >= GetHeight()) break; } - if(iCol != m_iColumns-1) - { + if (iCol != m_iColumns - 1) { pGfx->SetClipRegion(GetOrigin().x, - GetOrigin().y, - GetWidth(), - GetHeight()); + GetOrigin().y, + GetWidth(), + GetHeight()); // set the offset SetViewportOrgEx(pGfx->GetHDC(), - GetOrigin().x, - GetOrigin().y, - &ptPrevViewportOrg); + GetOrigin().x, + GetOrigin().y, + &ptPrevViewportOrg); - pGfx->DrawLine(iCol*3 + iColWidth + 1,0,iCol*3 + iColWidth + 1,GetHeight()); + pGfx->DrawLine(iCol * 3 + iColWidth + 1, 0, iCol * 3 + iColWidth + 1, GetHeight()); } iXOffset += 3 + iColWidth; } - if(m_pScrollbar) - { - m_pScrollbar->ScrollTo(m_iStartIndex); + if (m_pScrollbar) { + m_pScrollbar->ScrollTo(m_iStartIndex); m_pScrollbar->SetSliderSize(iEntriesDrawn); - } + } return true; } - void SetPosition(CListEntry<T,G> *pEntry) + void SetPosition(CListEntry<T, G> *pEntry) { - CListContainer<T,G>::SetPosition(pEntry); + CListContainer<T, G>::SetPosition(pEntry); - if(pEntry == nullptr) + if (pEntry == nullptr) return; - int iPerPage = (GetHeight()/m_iEntryHeight)*m_iColumns; + int iPerPage = (GetHeight() / m_iEntryHeight)*m_iColumns; m_iStartIndex = pEntry->GetIndex(); - if(m_iStartIndex + (iPerPage-1) > GetEntryCount()-1) - m_iStartIndex = (GetEntryCount()-1)-(iPerPage-1); - if(m_iStartIndex < 0) + if (m_iStartIndex + (iPerPage - 1) > GetEntryCount() - 1) + m_iStartIndex = (GetEntryCount() - 1) - (iPerPage - 1); + if (m_iStartIndex < 0) m_iStartIndex = 0; } @@ -773,14 +733,12 @@ public: //************************************************************************ bool ScrollUp() { - if(m_Position != nullptr) - { - CListEntry<T,G> *pEntry = m_Position->GetPreviousEntry(); - if(pEntry != nullptr) - { + if (m_Position != nullptr) { + CListEntry<T, G> *pEntry = m_Position->GetPreviousEntry(); + if (pEntry != nullptr) { m_Position = pEntry; - - if(m_Position->GetIndex() < m_iStartIndex) + + if (m_Position->GetIndex() < m_iStartIndex) m_iStartIndex--; return true; } @@ -792,19 +750,17 @@ public: // scrolls down //************************************************************************ bool ScrollDown() - { - if(m_Position != nullptr) - { - CListEntry<T,G> *pEntry = m_Position->GetNextEntry(); - if(pEntry != nullptr) - { + { + if (m_Position != nullptr) { + CListEntry<T, G> *pEntry = m_Position->GetNextEntry(); + if (pEntry != nullptr) { m_Position = pEntry; - int iPerPage = (GetHeight()/m_iEntryHeight)*m_iColumns; - if(m_Position->GetIndex() >= m_iStartIndex + iPerPage) + int iPerPage = (GetHeight() / m_iEntryHeight)*m_iColumns; + if (m_Position->GetIndex() >= m_iStartIndex + iPerPage) m_iStartIndex++; return true; - } + } } return false; } @@ -812,7 +768,7 @@ public: //************************************************************************ // returns the selected list entry //************************************************************************ - CListEntry<T,G> *GetSelectedEntry() + CListEntry<T, G> *GetSelectedEntry() { return m_Position; } @@ -823,11 +779,10 @@ public: void SetScrollbar(CLCDBar *pScrollbar) { m_pScrollbar = pScrollbar; - if(m_pScrollbar) - { + if (m_pScrollbar) { m_pScrollbar->SetRange(0, m_iEntryCount - 1); m_pScrollbar->ScrollTo(m_Position != nullptr ? m_Position->GetIndex() : 0); - + m_pScrollbar->SetAlignment(TOP); } } @@ -839,7 +794,7 @@ public: { m_iIndention = iIndention; } - + //************************************************************************ // sets the lists entry height //************************************************************************ @@ -869,11 +824,12 @@ public: //************************************************************************ void SetColumns(int iColumns) { - if(m_iColumns == iColumns) + if (m_iColumns == iColumns) return; m_iColumns = iColumns; SetPosition(GetPosition()); } + protected: //************************************************************************ // called when the lists size has changed @@ -888,11 +844,10 @@ protected: //************************************************************************ void UpdateEntryCount() { - CListContainer<T,G>::UpdateEntryCount(); - if(m_pScrollbar) - { - m_pScrollbar->SetRange(0,m_iEntryCount-1); - if(GetPosition() != nullptr) + CListContainer<T, G>::UpdateEntryCount(); + if (m_pScrollbar) { + m_pScrollbar->SetRange(0, m_iEntryCount - 1); + if (GetPosition() != nullptr) m_pScrollbar->ScrollTo(GetPosition()->GetIndex()); } } @@ -902,7 +857,6 @@ protected: //************************************************************************ virtual void DeleteEntry(T) { - } //************************************************************************ @@ -910,7 +864,6 @@ protected: //************************************************************************ virtual void DeleteGroup(G) { - } //************************************************************************ @@ -919,7 +872,7 @@ protected: virtual void DrawEntry(CLCDGfx*, T, bool) { } - + //************************************************************************ // Called to draw the specified entry //************************************************************************ @@ -927,8 +880,6 @@ protected: { } - - protected: int m_iStartIndex; int m_iColumns; @@ -939,4 +890,4 @@ protected: CLCDBar *m_pScrollbar; }; -#endif
\ No newline at end of file +#endif diff --git a/plugins/MirandaG15/src/LCDFramework/CLCDObject.h b/plugins/MirandaG15/src/LCDFramework/CLCDObject.h index 13dbb5a101..83f71c071f 100644 --- a/plugins/MirandaG15/src/LCDFramework/CLCDObject.h +++ b/plugins/MirandaG15/src/LCDFramework/CLCDObject.h @@ -10,19 +10,19 @@ public: CLCDObject();
// Destructor
~CLCDObject();
-
+
// Initialize the object
virtual bool Initialize();
// Shutdown the object
virtual bool Shutdown();
// Set the origin of the object
- void SetOrigin(int iX,int iY);
+ void SetOrigin(int iX, int iY);
void SetOrigin(POINT p);
// Get the origin of the object
POINT GetOrigin();
// Set the size of the object
- void SetSize(int iWidth,int iHeight);
+ void SetSize(int iWidth, int iHeight);
void SetSize(SIZE s);
// Get the size of the object
SIZE GetSize();
diff --git a/plugins/MirandaG15/src/LCDFramework/CLCDOutputManager.cpp b/plugins/MirandaG15/src/LCDFramework/CLCDOutputManager.cpp index 53cd59b701..1694707897 100644 --- a/plugins/MirandaG15/src/LCDFramework/CLCDOutputManager.cpp +++ b/plugins/MirandaG15/src/LCDFramework/CLCDOutputManager.cpp @@ -14,9 +14,7 @@ CLCDOutputManager *CLCDOutputManager::m_pInstance = nullptr; //************************************************************************ // Constructor //************************************************************************ -CLCDOutputManager::CLCDOutputManager() : m_dwButtonRepeatDelay(300), m_pGfx(nullptr), - m_pdwButtonRepeatTimers(nullptr), m_pdwButtonRepeatStarts(nullptr), m_pbButtonStates(nullptr), - m_pLcdConnection(nullptr), m_bInitialized(false), m_dwLastUpdate(0), m_pActiveScreen(nullptr) +CLCDOutputManager::CLCDOutputManager() { ASSERT(m_pInstance == nullptr); @@ -62,21 +60,21 @@ CLCDScreen *CLCDOutputManager::GetActiveScreen() //************************************************************************ // Initializes the OutputManager //************************************************************************ -bool CLCDOutputManager::Initialize(tstring strAppletName,bool bAutostart, bool bConfigDialog) +bool CLCDOutputManager::Initialize(tstring strAppletName, bool bAutostart, bool bConfigDialog) { - srand ( time(0) ); + srand(time(0)); InitDebug(); m_strAppletName = strAppletName; - + m_pGfx = new CLCDGfx(); m_pLcdConnection = new CLCDConnectionLogitech(); - if(!m_pLcdConnection->Initialize(m_strAppletName,bAutostart,bConfigDialog)) + if (!m_pLcdConnection->Initialize(m_strAppletName, bAutostart, bConfigDialog)) return false; - - + + m_bInitialized = true; m_dwLastUpdate = GetTickCount(); @@ -101,15 +99,14 @@ bool CLCDOutputManager::Shutdown() // Shutdown all screens vector<CLCDScreen*>::iterator iter = m_Screens.begin(); - while(iter != m_Screens.end()) - { + while (iter != m_Screens.end()) { (*(iter))->Shutdown(); iter++; } m_pLcdConnection->Shutdown(); - - + + delete m_pLcdConnection; UnInitDebug(); @@ -120,7 +117,8 @@ bool CLCDOutputManager::Shutdown() //************************************************************************ // called by CLCDConnection when connected to a device //************************************************************************ -void CLCDOutputManager::OnDeviceConnected() { +void CLCDOutputManager::OnDeviceConnected() +{ InitializeGfxObject(); OnConnectionChanged(CONNECTED); } @@ -128,7 +126,8 @@ void CLCDOutputManager::OnDeviceConnected() { //************************************************************************ // called by CLCDConnection when disconnected from a device //************************************************************************ -void CLCDOutputManager::OnDeviceDisconnected() { +void CLCDOutputManager::OnDeviceDisconnected() +{ DeinitializeGfxObject(); OnConnectionChanged(DISCONNECTED); } @@ -136,23 +135,23 @@ void CLCDOutputManager::OnDeviceDisconnected() { //************************************************************************ // Initializes the CGfx Object //************************************************************************ -void CLCDOutputManager::InitializeGfxObject() { - if(m_pGfx->IsInitialized()) +void CLCDOutputManager::InitializeGfxObject() +{ + if (m_pGfx->IsInitialized()) return; TRACE(L"CLCDOutputManager::UpdateGfxObject(): initializing CLCDGfx\n"); SIZE size; size = m_pLcdConnection->GetDisplaySize(); - - m_pGfx->Initialize(size.cx,size.cy,m_pLcdConnection->GetColorCount(), m_pLcdConnection->GetPixelBuffer()); + + m_pGfx->Initialize(size.cx, size.cy, m_pLcdConnection->GetColorCount(), m_pLcdConnection->GetPixelBuffer()); int iButtonCount = m_pLcdConnection->GetButtonCount(); m_pbButtonStates = (bool*)malloc(sizeof(bool)*iButtonCount); m_pdwButtonRepeatTimers = (DWORD*)malloc(sizeof(DWORD)*iButtonCount); m_pdwButtonRepeatStarts = (DWORD*)malloc(sizeof(DWORD)*iButtonCount); - for(int i=0;i<iButtonCount;i++) - { + for (int i = 0; i < iButtonCount; i++) { m_pbButtonStates[i] = false; m_pdwButtonRepeatTimers[i] = 0; m_pdwButtonRepeatStarts[i] = 0; @@ -160,8 +159,7 @@ void CLCDOutputManager::InitializeGfxObject() { // Update all screens sizes vector<CLCDScreen*>::iterator iter = m_Screens.begin(); - while(iter != m_Screens.end()) - { + while (iter != m_Screens.end()) { (*(iter))->OnSizeChanged(); iter++; } @@ -172,10 +170,11 @@ void CLCDOutputManager::InitializeGfxObject() { //************************************************************************ // Deinitializes the CGfx Object //************************************************************************ -void CLCDOutputManager::DeinitializeGfxObject() { - if(!m_pGfx->IsInitialized()) +void CLCDOutputManager::DeinitializeGfxObject() +{ + if (!m_pGfx->IsInitialized()) return; - + TRACE(L"CLCDOutputManager::UpdateGfxObject(): shutting down CLCDGfx\n"); m_pGfx->Shutdown(); @@ -194,56 +193,52 @@ bool CLCDOutputManager::Update() ASSERT(m_bInitialized); // Update the active screen - if(m_pActiveScreen != nullptr) - { + if (m_pActiveScreen != nullptr) { m_pActiveScreen->Update(); // Check if the active screen has expired - if(m_pActiveScreen->HasExpired()) - { + if (m_pActiveScreen->HasExpired()) { // Call event handlers DeactivateScreen(); return true; } } - if(!m_pLcdConnection) + if (!m_pLcdConnection) return true; // Update m_pLcdConnection->Update(); - + // skip button checking and drawing if there is no connection to a device - if(m_pLcdConnection->GetConnectionState() != CONNECTED) + if (m_pLcdConnection->GetConnectionState() != CONNECTED) return true; - + // Handle buttons bool bState = false; int iId = 0; - for(int i = 0; i < m_pLcdConnection->GetButtonCount(); i ++) - { + for (int i = 0; i < m_pLcdConnection->GetButtonCount(); i++) { // get current state bState = m_pLcdConnection->GetButtonState(i); // handle input event - if(bState != m_pbButtonStates[i]) - { + if (bState != m_pbButtonStates[i]) { iId = m_pLcdConnection->GetButtonId(i); - if(bState) { + if (bState) { OnLCDButtonDown(iId); - } else { + } + else { OnLCDButtonUp(iId); } m_pdwButtonRepeatStarts[i] = GetTickCount(); m_pdwButtonRepeatTimers[i] = m_pdwButtonRepeatStarts[i] + m_dwButtonRepeatDelay; } // check if repeat event should be sent - else if(bState && m_pdwButtonRepeatTimers[i] <= GetTickCount()) - { + else if (bState && m_pdwButtonRepeatTimers[i] <= GetTickCount()) { iId = m_pLcdConnection->GetButtonId(i); - + // reduce the delay by 5% per second DWORD dwNewDelay = m_dwButtonRepeatDelay - ((float)m_dwButtonRepeatDelay * 0.05 * (GetTickCount() - m_pdwButtonRepeatStarts[i]) / 250); // delay may not be less than 25% of the original value - if(dwNewDelay < m_dwButtonRepeatDelay * 0.25) + if (dwNewDelay < m_dwButtonRepeatDelay * 0.25) dwNewDelay = m_dwButtonRepeatDelay * 0.25; m_pdwButtonRepeatTimers[i] = GetTickCount() + dwNewDelay; @@ -253,11 +248,10 @@ bool CLCDOutputManager::Update() // save the current state m_pbButtonStates[i] = bState; } - + // Draw - - if(m_pActiveScreen != nullptr && m_pGfx->IsInitialized()) - { + + if (m_pActiveScreen != nullptr && m_pGfx->IsInitialized()) { m_pGfx->BeginDraw(); m_pGfx->ClearScreen(); m_pActiveScreen->Draw(m_pGfx); @@ -278,22 +272,20 @@ bool CLCDOutputManager::Update() //************************************************************************ bool CLCDOutputManager::DeactivateScreen() { - if(m_pActiveScreen == nullptr) + if (m_pActiveScreen == nullptr) return false; CLCDScreen *pActiveScreen = m_pActiveScreen; m_pActiveScreen = nullptr; - if(pActiveScreen->HasExpired()) - { + if (pActiveScreen->HasExpired()) { pActiveScreen->OnExpiration(); OnScreenExpired(pActiveScreen); } - else - { + else { OnScreenDeactivated(pActiveScreen); pActiveScreen->OnDeactivation(); - } + } return true; } @@ -301,12 +293,12 @@ bool CLCDOutputManager::DeactivateScreen() // Activates the specified screen //************************************************************************ bool CLCDOutputManager::ActivateScreen(CLCDScreen *pScreen) -{ - if(m_pActiveScreen == pScreen) +{ + if (m_pActiveScreen == pScreen) return false; - + // If another screen is currently active, deactivate it - if(m_pActiveScreen != nullptr) + if (m_pActiveScreen != nullptr) DeactivateScreen(); m_pActiveScreen = pScreen; @@ -321,13 +313,12 @@ bool CLCDOutputManager::AddScreen(CLCDScreen *pScreen) { // Check if the screen is already managed vector<CLCDScreen*>::iterator iter = m_Screens.begin(); - while(iter != m_Screens.end()) - { - if(*(iter) == pScreen) + while (iter != m_Screens.end()) { + if (*(iter) == pScreen) return false; iter++; } - + m_Screens.push_back(pScreen); return true; } @@ -337,15 +328,13 @@ bool CLCDOutputManager::AddScreen(CLCDScreen *pScreen) //************************************************************************ bool CLCDOutputManager::RemoveScreen(CLCDScreen *pScreen) { - if(m_Screens.empty()) + if (m_Screens.empty()) return false; // Find the screen and remove it from the list of managed screens vector<CLCDScreen*>::iterator iter = m_Screens.begin(); - while(iter != m_Screens.end()) - { - if(*(iter) == pScreen) - { + while (iter != m_Screens.end()) { + if (*(iter) == pScreen) { m_Screens.erase(iter); return true; } @@ -357,9 +346,9 @@ bool CLCDOutputManager::RemoveScreen(CLCDScreen *pScreen) //************************************************************************ // starts a screen transition //************************************************************************ -void CLCDOutputManager::StartTransition(ETransitionType eTransition,LPRECT rect) +void CLCDOutputManager::StartTransition(ETransitionType eTransition, LPRECT rect) { - m_pGfx->StartTransition(eTransition,rect); + m_pGfx->StartTransition(eTransition, rect); } //************************************************************************ @@ -374,14 +363,14 @@ void CLCDOutputManager::SetButtonRepeatDelay(DWORD dwDelay) // Called when a screen has been deactivated //************************************************************************ void CLCDOutputManager::OnScreenDeactivated(CLCDScreen*) -{ +{ } //************************************************************************ // Called when a screen has expired //************************************************************************ void CLCDOutputManager::OnScreenExpired(CLCDScreen*) -{ +{ } //************************************************************************ @@ -389,7 +378,7 @@ void CLCDOutputManager::OnScreenExpired(CLCDScreen*) //************************************************************************ void CLCDOutputManager::OnLCDButtonRepeated(int iButton) { - if(m_pActiveScreen) { + if (m_pActiveScreen) { m_pActiveScreen->OnLCDButtonRepeated(iButton); } } @@ -399,7 +388,7 @@ void CLCDOutputManager::OnLCDButtonRepeated(int iButton) //************************************************************************ void CLCDOutputManager::OnLCDButtonDown(int iButton) { - if(m_pActiveScreen) + if (m_pActiveScreen) m_pActiveScreen->OnLCDButtonDown(iButton); } @@ -408,7 +397,7 @@ void CLCDOutputManager::OnLCDButtonDown(int iButton) //************************************************************************ void CLCDOutputManager::OnLCDButtonUp(int iButton) { - if(m_pActiveScreen) + if (m_pActiveScreen) m_pActiveScreen->OnLCDButtonUp(iButton); } @@ -436,7 +425,7 @@ void CLCDOutputManager::OnLCDDisconnected() //************************************************************************ // Called by the LCDManager to open a config dialog //************************************************************************ -DWORD WINAPI CLCDOutputManager::configDialogCallback(IN int connection,IN const PVOID pContext) +DWORD WINAPI CLCDOutputManager::configDialogCallback(IN int connection, IN const PVOID pContext) { return CLCDOutputManager::GetInstance()->OnConfigDialogRequest(connection, pContext); } @@ -447,4 +436,4 @@ DWORD WINAPI CLCDOutputManager::configDialogCallback(IN int connection,IN const DWORD CLCDOutputManager::OnConfigDialogRequest(int, const PVOID) { return 0; -}
\ No newline at end of file +} diff --git a/plugins/MirandaG15/src/LCDFramework/CLCDOutputManager.h b/plugins/MirandaG15/src/LCDFramework/CLCDOutputManager.h index adb338c7c6..076f41a570 100644 --- a/plugins/MirandaG15/src/LCDFramework/CLCDOutputManager.h +++ b/plugins/MirandaG15/src/LCDFramework/CLCDOutputManager.h @@ -8,8 +8,8 @@ class CLCDOutputManager
{
-friend CLCDConnection;
-friend class CLCDConnectionLogitech;
+ friend CLCDConnection;
+ friend class CLCDConnectionLogitech;
public:
// constructor
@@ -21,7 +21,7 @@ public: static CLCDOutputManager *GetInstance();
// Initializes the Outputmanager
- virtual bool Initialize(tstring strAppletName,bool bAutostart=false, bool bConfigDialog=false);
+ virtual bool Initialize(tstring strAppletName, bool bAutostart = false, bool bConfigDialog = false);
// return wether the Outputmanager is initialized
virtual bool IsInitialized();
@@ -29,12 +29,12 @@ public: virtual bool Shutdown();
// Updates the Outputmanager
virtual bool Update();
-
+
// Add a screen to the managers list
bool AddScreen(CLCDScreen *pScreen);
// Removes a screen from the managers list
bool RemoveScreen(CLCDScreen *pScreen);
-
+
// Activates the specified screen
bool ActivateScreen(CLCDScreen *pScreen);
// Deactivates the active screen
@@ -49,15 +49,15 @@ public: void SetButtonRepeatDelay(DWORD dwDelay);
// starts a screen transition
- void StartTransition(ETransitionType eTransition = TRANSITION_RANDOM,LPRECT rect = nullptr);
-
+ void StartTransition(ETransitionType eTransition = TRANSITION_RANDOM, LPRECT rect = nullptr);
+
// called by CLCDConnection when connected to a device
void OnDeviceConnected();
// called by CLCDConnection when disconnected from a device
void OnDeviceDisconnected();
// Called by the LCDManager to open a config dialog
- static DWORD WINAPI configDialogCallback(IN int connection,IN const PVOID pContext);
+ static DWORD WINAPI configDialogCallback(IN int connection, IN const PVOID pContext);
protected:
void InitializeGfxObject();
void DeinitializeGfxObject();
@@ -76,27 +76,29 @@ protected: virtual void OnLCDButtonUp(int iButton);
// Called when an LCD button is repeated
virtual void OnLCDButtonRepeated(int iButton);
-
+
virtual void OnScreenExpired(CLCDScreen *pScreen);
virtual void OnScreenDeactivated(CLCDScreen *pScreen);
-
+
// Called when a config dialog is requested
virtual DWORD OnConfigDialogRequest(int connection, const PVOID pContext);
- CLCDGfx *m_pGfx;
+
+ CLCDGfx *m_pGfx = nullptr;
+
private:
- DWORD m_dwLastUpdate;
- DWORD m_dwButtonRepeatDelay;
- bool m_bInitialized;
- static CLCDOutputManager* m_pInstance;
- bool *m_pbButtonStates;
- DWORD *m_pdwButtonRepeatTimers;
- DWORD *m_pdwButtonRepeatStarts;
- tstring m_strAppletName;
- CLCDConnection *m_pLcdConnection;
-
-
- vector<CLCDScreen*> m_Screens;
- CLCDScreen *m_pActiveScreen;
+ static CLCDOutputManager *m_pInstance;
+
+ DWORD m_dwLastUpdate = 0;
+ DWORD m_dwButtonRepeatDelay = 300;
+ bool m_bInitialized = false;
+ bool *m_pbButtonStates = nullptr;
+ DWORD *m_pdwButtonRepeatTimers = nullptr;
+ DWORD *m_pdwButtonRepeatStarts = nullptr;
+ tstring m_strAppletName;
+ CLCDConnection *m_pLcdConnection = nullptr;
+
+ vector<CLCDScreen*> m_Screens;
+ CLCDScreen *m_pActiveScreen = nullptr;
};
-#endif
\ No newline at end of file +#endif
diff --git a/plugins/MirandaG15/src/LCDFramework/CLCDScreen.cpp b/plugins/MirandaG15/src/LCDFramework/CLCDScreen.cpp index 9373977239..e2d878db2f 100644 --- a/plugins/MirandaG15/src/LCDFramework/CLCDScreen.cpp +++ b/plugins/MirandaG15/src/LCDFramework/CLCDScreen.cpp @@ -9,9 +9,6 @@ //************************************************************************
CLCDScreen::CLCDScreen()
{
- m_dwExpiration = INFINITE;
- m_bAlert = false;
-
// Set a default screen size to use if no device is plugged in
m_Size.cx = 160;
m_Size.cy = 43;
@@ -22,7 +19,6 @@ CLCDScreen::CLCDScreen() //************************************************************************
CLCDScreen::~CLCDScreen()
{
-
}
//************************************************************************
@@ -31,7 +27,7 @@ CLCDScreen::~CLCDScreen() bool CLCDScreen::Initialize()
{
CLCDConnection *pConnection = CLCDOutputManager::GetInstance()->GetLCDConnection();
- if(pConnection->GetConnectionState() == CONNECTED) {
+ if (pConnection->GetConnectionState() == CONNECTED) {
m_Size = pConnection->GetDisplaySize();
}
@@ -45,8 +41,7 @@ bool CLCDScreen::Shutdown() {
// Shutdown all Objects
vector<CLCDObject*>::iterator iter = m_Objects.begin();
- while(iter != m_Objects.end())
- {
+ while (iter != m_Objects.end()) {
(*(iter))->Shutdown();
iter++;
}
@@ -59,7 +54,7 @@ bool CLCDScreen::Shutdown() void CLCDScreen::OnSizeChanged()
{
CLCDConnection *pConnection = CLCDOutputManager::GetInstance()->GetLCDConnection();
- if(!pConnection)
+ if (!pConnection)
return;
m_Size = pConnection->GetDisplaySize();
@@ -73,11 +68,10 @@ bool CLCDScreen::Update() // Loop through all objects and call their update function
vector<CLCDObject*>::iterator iter = m_Objects.begin();
CLCDObject *pObject = nullptr;
- while(iter != m_Objects.end())
- {
+ while (iter != m_Objects.end()) {
pObject = *(iter);
pObject->Update();
-
+
iter++;
}
return true;
@@ -88,41 +82,31 @@ bool CLCDScreen::Update() //************************************************************************
bool CLCDScreen::Draw(CLCDGfx *pGfx)
{
- POINT ptPrevViewportOrg = { 0, 0 };
+ POINT ptPrevViewportOrg = {0, 0};
// Loop through all objects and call their draw function
vector<CLCDObject*>::iterator iter = m_Objects.begin();
CLCDObject *pObject = nullptr;
- while(iter != m_Objects.end())
- {
+ while (iter != m_Objects.end()) {
pObject = *(iter);
// Only draw visible objects
- if(!pObject->IsVisible())
- {
+ if (!pObject->IsVisible()) {
iter++;
continue;
}
-
+
// create the clip region
pGfx->SetClipRegion(pObject->GetOrigin().x, pObject->GetOrigin().y,
- pObject->GetWidth(),
- pObject->GetHeight());
-
- // offset the control at its origin so controls use (0,0)
- SetViewportOrgEx(pGfx->GetHDC(),
- pObject->GetOrigin().x,
- pObject->GetOrigin().y,
- &ptPrevViewportOrg);
-
- /*
-// allow controls to supply additional translation
- // this allows controls to move freely within the confined viewport
- OffsetViewportOrgEx(pGfx->GetHDC(),
- 0,
- 0,
- NULL);
-*/
+ pObject->GetWidth(),
+ pObject->GetHeight());
+
+ // offset the control at its origin so controls use (0,0)
+ SetViewportOrgEx(pGfx->GetHDC(),
+ pObject->GetOrigin().x,
+ pObject->GetOrigin().y,
+ &ptPrevViewportOrg);
+
pObject->Draw(pGfx);
-
+
iter++;
}
// set the clipping region to nothing
@@ -142,7 +126,7 @@ bool CLCDScreen::Draw(CLCDGfx *pGfx) //************************************************************************
void CLCDScreen::SetExpiration(DWORD dwTime)
{
- if(dwTime == INFINITE)
+ if (dwTime == INFINITE)
m_dwExpiration = INFINITE;
else
m_dwExpiration = GetTickCount() + dwTime;
@@ -153,10 +137,10 @@ void CLCDScreen::SetExpiration(DWORD dwTime) //************************************************************************
bool CLCDScreen::HasExpired()
{
- if(m_dwExpiration == INFINITE)
+ if (m_dwExpiration == INFINITE)
return false;
- if(m_dwExpiration <= GetTickCount())
+ if (m_dwExpiration <= GetTickCount())
return true;
return false;
}
@@ -184,9 +168,8 @@ bool CLCDScreen::AddObject(CLCDObject *pObject) {
// Check if the object is already managed
vector<CLCDObject*>::iterator iter = m_Objects.begin();
- while(iter != m_Objects.end())
- {
- if(*(iter) == pObject)
+ while (iter != m_Objects.end()) {
+ if (*(iter) == pObject)
return false;
iter++;
}
@@ -199,15 +182,13 @@ bool CLCDScreen::AddObject(CLCDObject *pObject) //************************************************************************
bool CLCDScreen::RemoveObject(CLCDObject *pObject)
{
- if(m_Objects.empty())
+ if (m_Objects.empty())
return false;
// Find and remove the specified object
vector<CLCDObject*>::iterator iter = m_Objects.begin();
- while(iter != m_Objects.end())
- {
- if(*(iter) == pObject)
- {
+ while (iter != m_Objects.end()) {
+ if (*(iter) == pObject) {
m_Objects.erase(iter);
return true;
}
@@ -232,13 +213,11 @@ int CLCDScreen::GetWidth() return m_Size.cx;
}
-
//************************************************************************
// Called when the screen is activated
//************************************************************************
void CLCDScreen::OnActivation()
{
-
}
//************************************************************************
@@ -246,7 +225,6 @@ void CLCDScreen::OnActivation() //************************************************************************
void CLCDScreen::OnDeactivation()
{
-
}
//************************************************************************
@@ -254,7 +232,6 @@ void CLCDScreen::OnDeactivation() //************************************************************************
void CLCDScreen::OnExpiration()
{
-
}
//************************************************************************
@@ -262,7 +239,6 @@ void CLCDScreen::OnExpiration() //************************************************************************
void CLCDScreen::OnLCDButtonDown(int)
{
-
}
//************************************************************************
@@ -270,7 +246,6 @@ void CLCDScreen::OnLCDButtonDown(int) //************************************************************************
void CLCDScreen::OnLCDButtonRepeated(int)
{
-
}
//************************************************************************
@@ -278,5 +253,4 @@ void CLCDScreen::OnLCDButtonRepeated(int) //************************************************************************
void CLCDScreen::OnLCDButtonUp(int)
{
-
-}
\ No newline at end of file +}
diff --git a/plugins/MirandaG15/src/LCDFramework/CLCDScreen.h b/plugins/MirandaG15/src/LCDFramework/CLCDScreen.h index 1f8b431a73..f8b6c432e1 100644 --- a/plugins/MirandaG15/src/LCDFramework/CLCDScreen.h +++ b/plugins/MirandaG15/src/LCDFramework/CLCDScreen.h @@ -58,10 +58,10 @@ public: virtual void OnExpiration();
private:
- SIZE m_Size;
- vector<CLCDObject*> m_Objects;
- bool m_bAlert;
- DWORD m_dwExpiration;
+ SIZE m_Size;
+ bool m_bAlert = false;
+ DWORD m_dwExpiration = INFINITE;
+ vector<CLCDObject*> m_Objects;
};
-#endif
\ No newline at end of file +#endif
diff --git a/plugins/MirandaG15/src/LCDFramework/CLCDTextLog.cpp b/plugins/MirandaG15/src/LCDFramework/CLCDTextLog.cpp index 7c8ec5ca69..4c56482cd1 100644 --- a/plugins/MirandaG15/src/LCDFramework/CLCDTextLog.cpp +++ b/plugins/MirandaG15/src/LCDFramework/CLCDTextLog.cpp @@ -1,21 +1,11 @@ #include "StdAfx.h"
#include "CLCDTextLog.h"
-
//************************************************************************
// Constructor
//************************************************************************
CLCDTextLog::CLCDTextLog()
{
- m_dwLastScroll = 0;
-
- m_iLogSize = 10;
- m_iPosition = 0;
- m_iTextLines = 0;
- m_pScrollbar = nullptr;
- m_eExpandMode = EXPAND_SCROLL;
- m_eAutoScroll = SCROLL_MESSAGE;
- m_iLastScrollDirection = 0;
}
//************************************************************************
@@ -31,9 +21,8 @@ CLCDTextLog::~CLCDTextLog() //************************************************************************
bool CLCDTextLog::Initialize()
{
- if(!CLCDTextObject::Initialize())
+ if (!CLCDTextObject::Initialize())
return false;
-
return true;
}
@@ -43,9 +32,9 @@ bool CLCDTextLog::Initialize() //************************************************************************
bool CLCDTextLog::Shutdown()
{
- if(!CLCDTextObject::Shutdown())
+ if (!CLCDTextObject::Shutdown())
return false;
-
+
return true;
}
@@ -54,9 +43,9 @@ bool CLCDTextLog::Shutdown() //************************************************************************
bool CLCDTextLog::Update()
{
- if(!CLCDTextObject::Update())
+ if (!CLCDTextObject::Update())
return false;
-
+
return true;
}
@@ -65,32 +54,29 @@ bool CLCDTextLog::Update() //************************************************************************
bool CLCDTextLog::Draw(CLCDGfx *pGfx)
{
- if(!CLCDTextObject::Draw(pGfx))
+ if (!CLCDTextObject::Draw(pGfx))
return false;
-
+
if (m_Entrys.empty())
return true;
- // select current font
- SelectObject(pGfx->GetHDC(), m_hFont);
+ // select current font
+ SelectObject(pGfx->GetHDC(), m_hFont);
- int iLineCount = (GetHeight()/m_iFontHeight);
- int iSpacing = (GetHeight() - iLineCount*m_iFontHeight)/2;
+ int iLineCount = (GetHeight() / m_iFontHeight);
+ int iSpacing = (GetHeight() - iLineCount * m_iFontHeight) / 2;
list<CLogEntry*>::iterator iter = m_Entrys.begin();
CLogEntry *pEntry = nullptr;
- RECT rBoundary = { 0, iSpacing,GetWidth() , GetHeight()-iSpacing};
+ RECT rBoundary = {0, iSpacing,GetWidth() , GetHeight() - iSpacing};
int iPosition = 0;
int iLinesDrawn = 0;
- while(iLinesDrawn < iLineCount && iter != m_Entrys.end())
- {
+ while (iLinesDrawn < iLineCount && iter != m_Entrys.end()) {
pEntry = *(iter++);
// This Message has something to draw
- if(iPosition + pEntry->iLines > m_iPosition )
- {
- int iLine = (m_iPosition + iLinesDrawn) - iPosition;
- for(;iLinesDrawn < iLineCount && iLine < pEntry->iLines;iLine++)
- {
+ if (iPosition + pEntry->iLines > m_iPosition) {
+ int iLine = (m_iPosition + iLinesDrawn) - iPosition;
+ for (; iLinesDrawn < iLineCount && iLine < pEntry->iLines; iLine++) {
DrawTextEx(pGfx->GetHDC(), (LPTSTR)pEntry->vLines[iLine].c_str(), (int)pEntry->vLines[iLine].size(), &rBoundary, m_iTextFormat, &m_dtp);
rBoundary.top += m_iFontHeight;
rBoundary.bottom += m_iFontHeight;
@@ -108,10 +94,9 @@ bool CLCDTextLog::Draw(CLCDGfx *pGfx) void CLCDTextLog::SetScrollbar(CLCDBar *pScrollbar)
{
m_pScrollbar = pScrollbar;
- if(m_pScrollbar)
- {
- m_pScrollbar->SetSliderSize(GetHeight()/m_iFontHeight);
- m_pScrollbar->SetRange(0,m_iTextLines-1);
+ if (m_pScrollbar) {
+ m_pScrollbar->SetSliderSize(GetHeight() / m_iFontHeight);
+ m_pScrollbar->SetRange(0, m_iTextLines - 1);
m_pScrollbar->ScrollTo(m_iPosition);
m_pScrollbar->SetAlignment(TOP);
}
@@ -145,7 +130,7 @@ void CLCDTextLog::SetText(tstring strText) //************************************************************************
// adds some text to the log
//************************************************************************
-void CLCDTextLog::AddText(tstring strText,bool bForceAutoscroll)
+void CLCDTextLog::AddText(tstring strText, bool bForceAutoscroll)
{
CLogEntry *pEntry = new CLogEntry();
pEntry->strString = strText;
@@ -153,16 +138,15 @@ void CLCDTextLog::AddText(tstring strText,bool bForceAutoscroll) WrapMessage(pEntry);
m_Entrys.push_back(pEntry);
- if(m_Entrys.size() > m_iLogSize)
- {
+ if (m_Entrys.size() > m_iLogSize) {
CLogEntry *pOldestEntry = *(m_Entrys.begin());
m_Entrys.pop_front();
- if(m_iPosition >= pOldestEntry->iLines)
+ if (m_iPosition >= pOldestEntry->iLines)
m_iPosition -= pOldestEntry->iLines;
else
m_iPosition = 0;
-
+
m_iTextLines -= pOldestEntry->iLines;
delete pOldestEntry;
@@ -170,21 +154,19 @@ void CLCDTextLog::AddText(tstring strText,bool bForceAutoscroll) m_iTextLines += pEntry->iLines;
// Autoscrolling
- if(m_dwLastScroll + 10000 < GetTickCount() || bForceAutoscroll)
- {
- int iLineCount = (GetHeight()/m_iFontHeight);
- if(m_eAutoScroll == SCROLL_LINE)
+ if (m_dwLastScroll + 10000 < GetTickCount() || bForceAutoscroll) {
+ int iLineCount = (GetHeight() / m_iFontHeight);
+ if (m_eAutoScroll == SCROLL_LINE)
ScrollTo(m_iTextLines - iLineCount);
- else if(m_eAutoScroll == SCROLL_MESSAGE)
+ else if (m_eAutoScroll == SCROLL_MESSAGE)
ScrollTo(m_iTextLines - pEntry->iLines);
- if(m_eAutoScroll != SCROLL_NONE)
+ if (m_eAutoScroll != SCROLL_NONE)
m_iLastScrollDirection = 1;
}
- if(m_pScrollbar)
- {
- m_pScrollbar->SetRange(0,m_iTextLines-1);
+ if (m_pScrollbar) {
+ m_pScrollbar->SetRange(0, m_iTextLines - 1);
m_pScrollbar->ScrollTo(m_iPosition);
}
}
@@ -207,16 +189,14 @@ void CLCDTextLog::ClearLog() m_iTextLines = 0;
m_iPosition = 0;
CLogEntry *pEvent;
- while(!m_Entrys.empty())
- {
+ while (!m_Entrys.empty()) {
pEvent = *(m_Entrys.begin());
m_Entrys.pop_front();
delete pEvent;
}
- if(m_pScrollbar)
- {
- m_pScrollbar->SetRange(0,0);
+ if (m_pScrollbar) {
+ m_pScrollbar->SetRange(0, 0);
m_pScrollbar->ScrollTo(0);
}
}
@@ -226,10 +206,9 @@ void CLCDTextLog::ClearLog() //************************************************************************
bool CLCDTextLog::ScrollUp()
{
- if(m_iPosition > 0)
- {
+ if (m_iPosition > 0) {
m_iPosition--;
- if(m_pScrollbar)
+ if (m_pScrollbar)
m_pScrollbar->ScrollUp();
m_dwLastScroll = GetTickCount();
@@ -244,12 +223,11 @@ bool CLCDTextLog::ScrollUp() //************************************************************************
bool CLCDTextLog::ScrollDown()
{
- int iLineCount = (GetHeight()/m_iFontHeight);
-
- if(m_iPosition < m_iTextLines - iLineCount)
- {
+ int iLineCount = (GetHeight() / m_iFontHeight);
+
+ if (m_iPosition < m_iTextLines - iLineCount) {
m_iPosition++;
- if(m_pScrollbar)
+ if (m_pScrollbar)
m_pScrollbar->ScrollDown();
m_iLastScrollDirection = 1;
@@ -268,14 +246,14 @@ bool CLCDTextLog::ScrollTo(int iIndex) m_iPosition = iIndex;
- int iLineCount = (GetHeight()/m_iFontHeight);
+ int iLineCount = (GetHeight() / m_iFontHeight);
- if(m_iPosition > m_iTextLines - iLineCount)
+ if (m_iPosition > m_iTextLines - iLineCount)
m_iPosition = m_iTextLines - iLineCount;
- if( m_iPosition < 0)
+ if (m_iPosition < 0)
m_iPosition = 0;
-
- if(m_pScrollbar)
+
+ if (m_pScrollbar)
m_pScrollbar->ScrollTo(m_iPosition);
bool bRes = m_iOldPosition != m_iPosition;
@@ -292,89 +270,52 @@ void CLCDTextLog::WrapMessage(CLogEntry *pEntry) tstring strString = pEntry->strString;
HDC hDC = CreateCompatibleDC(nullptr);
- SelectObject(hDC, m_hFont);
-
- if(nullptr == hDC)
+ SelectObject(hDC, m_hFont);
+
+ if (nullptr == hDC)
return;
int iLen = (int)strString.size();
int i = 0;
tstring strLine = L"";
tstring strWord = L"";
- SIZE sizeLine = {0, 0};
+ SIZE sizeLine = {0, 0};
int *piExtents = new int[strString.length()];
wchar_t *szString = (wchar_t*)strString.c_str();
int iMaxChars = 0;
tstring::size_type pos = 0;
- if(GetWidth() == 0)
+ if (GetWidth() == 0)
pEntry->vLines.push_back(strString);
- else
- {
- while(i<iLen)
- {
- GetTextExtentExPoint(hDC, szString+i, (int)strString.length()-i, GetWidth(), &iMaxChars, piExtents, &sizeLine);
-
+ else {
+ while (i < iLen) {
+ GetTextExtentExPoint(hDC, szString + i, (int)strString.length() - i, GetWidth(), &iMaxChars, piExtents, &sizeLine);
+
// filter out spaces or line breaks at the beginning of a new line
- if(strString[i] == '\n' || strString[i] == ' ')
+ if (strString[i] == '\n' || strString[i] == ' ')
i++;
- pos = strString.rfind(L"\n",i+iMaxChars);
+ pos = strString.rfind(L"\n", i + iMaxChars);
// check for linebreaks
- if(pos != tstring::npos && pos != i && pos >= i && pos != i+iMaxChars)
+ if (pos != tstring::npos && pos != i && pos >= i && pos != i + iMaxChars)
iMaxChars = 1 + (int)pos - i;
// if the string doesnt fit, try to wrap the last word to the next line
- else if(iMaxChars < iLen - i || sizeLine.cx >= GetWidth())
- {
+ else if (iMaxChars < iLen - i || sizeLine.cx >= GetWidth()) {
// find the last space in the line ( substract -1 from offset to ignore spaces as last chars )
- pos = strString.rfind(L" ",i + iMaxChars -1 );
- if(pos != tstring::npos && pos != i && pos >= i && pos != i+iMaxChars)
+ pos = strString.rfind(L" ", i + iMaxChars - 1);
+ if (pos != tstring::npos && pos != i && pos >= i && pos != i + iMaxChars)
iMaxChars = 1 + (int)pos - i;
}
- pEntry->vLines.push_back(strString.substr(i,iMaxChars));
+ pEntry->vLines.push_back(strString.substr(i, iMaxChars));
i += iMaxChars;
}
}
delete[] piExtents;
- /*
- while(i<=iLen)
- {
- if(i != iLen && strString[i] != 13 && strString[i] != 10)
- strWord += strString[i];
-
- GetTextExtentPoint(hDC,&(strString[i]),1,&sizeChar);
- sizeWord.cx += sizeChar.cx;
-
- if(i == iLen || strString[i] == ' ' || strString[i] == 10)
- {
- sizeLine.cx += sizeWord.cx;
-
- strLine += strWord;
- strWord = L"";
- sizeWord.cx = 0;
- }
-
- if(i == iLen || strString[i] == '\n' || sizeLine.cx + sizeWord.cx >= GetWidth())
- {
- if(sizeWord.cx >= GetWidth())
- {
- strLine += strWord.substr(0,strWord.length()-1);
- strWord = strString[i];
- sizeWord.cx = sizeChar.cx;
- }
- pEntry->vLines.push_back(strLine);
-
- strLine = L"";
- sizeLine.cx = 0;
- }
- i++;
- }
- */
DeleteObject(hDC);
pEntry->iLines = (int)pEntry->vLines.size();
-}
+}
//************************************************************************
// called when the logs font has changed
@@ -390,23 +331,23 @@ void CLCDTextLog::OnFontChanged() void CLCDTextLog::OnSizeChanged(SIZE OldSize)
{
// check in which direction the log should expand on height changes
- int iLines = GetHeight()/m_iFontHeight;
- int iOldLines = OldSize.cy/m_iFontHeight;
+ int iLines = GetHeight() / m_iFontHeight;
+ int iOldLines = OldSize.cy / m_iFontHeight;
- int iPosition =m_iPosition;
+ int iPosition = m_iPosition;
- if(m_eExpandMode == EXPAND_UP || (m_eExpandMode == EXPAND_SCROLL && m_iLastScrollDirection == 1))
+ if (m_eExpandMode == EXPAND_UP || (m_eExpandMode == EXPAND_SCROLL && m_iLastScrollDirection == 1))
iPosition = (m_iPosition + iOldLines) - iLines;
// revalidate position
ScrollTo(iPosition);
-
+
// update the scrollbar
- if(m_pScrollbar)
- m_pScrollbar->SetSliderSize(GetHeight()/m_iFontHeight);
-
+ if (m_pScrollbar)
+ m_pScrollbar->SetSliderSize(GetHeight() / m_iFontHeight);
+
// if the width hasn't changed, return
- if(GetWidth() == OldSize.cx)
+ if (GetWidth() == OldSize.cx)
return;
RefreshLines();
@@ -417,15 +358,14 @@ void CLCDTextLog::OnSizeChanged(SIZE OldSize) //************************************************************************
void CLCDTextLog::RefreshLines()
{
- if(m_Entrys.empty())
+ if (m_Entrys.empty())
return;
m_iTextLines = 0;
CLogEntry *pEntry = nullptr;
list<CLogEntry*>::iterator iter = m_Entrys.begin();
- while(iter != m_Entrys.end())
- {
+ while (iter != m_Entrys.end()) {
pEntry = *(iter);
WrapMessage(pEntry);
m_iTextLines += pEntry->iLines;
@@ -433,6 +373,5 @@ void CLCDTextLog::RefreshLines() }
ScrollTo(m_iPosition);
-
SetScrollbar(m_pScrollbar);
}
diff --git a/plugins/MirandaG15/src/LCDFramework/CLCDTextLog.h b/plugins/MirandaG15/src/LCDFramework/CLCDTextLog.h index 312ec8a992..3f9f2bbc3c 100644 --- a/plugins/MirandaG15/src/LCDFramework/CLCDTextLog.h +++ b/plugins/MirandaG15/src/LCDFramework/CLCDTextLog.h @@ -4,15 +4,12 @@ #include "CLCDTextObject.h"
#include "CLCDBar.h"
-
-enum EScrollMode {SCROLL_NONE, SCROLL_MESSAGE,SCROLL_LINE };
-enum EExpandMode { EXPAND_SCROLL, EXPAND_UP,EXPAND_DOWN };
+enum EScrollMode { SCROLL_NONE, SCROLL_MESSAGE, SCROLL_LINE };
+enum EExpandMode { EXPAND_SCROLL, EXPAND_UP, EXPAND_DOWN };
class CLCDTextLog : public CLCDTextObject
{
public:
-
-
// Constructor
CLCDTextLog();
// Destructor
@@ -31,7 +28,7 @@ public: // sets the logs text
void SetText(tstring strText);
// adds some text to the log
- void AddText(tstring strText,bool bForceAutoscroll=false);
+ void AddText(tstring strText, bool bForceAutoscroll = false);
// sets the maximum number of log entrys
void SetLogSize(int iSize);
// clears the log
@@ -60,6 +57,7 @@ protected: // rewraps all textlines
void RefreshLines();
+
private:
// the log entry class
class CLogEntry
@@ -73,18 +71,18 @@ private: // wraps the specified log entry
void WrapMessage(CLogEntry *pEntry);
- EScrollMode m_eAutoScroll;
- EExpandMode m_eExpandMode;
+ EScrollMode m_eAutoScroll = SCROLL_MESSAGE;
+ EExpandMode m_eExpandMode = EXPAND_SCROLL;
+
+ int m_iLogSize = 10;
+ int m_iPosition = 0;
+ int m_iTextLines = 0;
+ int m_iLastScrollDirection = 0;
- int m_iLogSize;
- int m_iPosition;
- int m_iTextLines;
- int m_iLastScrollDirection;
-
- DWORD m_dwLastScroll;
+ DWORD m_dwLastScroll = 0;
list<CLogEntry*> m_Entrys;
CLCDBar *m_pScrollbar;
};
-#endif
\ No newline at end of file +#endif
diff --git a/plugins/MirandaG15/src/LCDFramework/CLCDTextObject.cpp b/plugins/MirandaG15/src/LCDFramework/CLCDTextObject.cpp index 01026cf43d..a07aa1d667 100644 --- a/plugins/MirandaG15/src/LCDFramework/CLCDTextObject.cpp +++ b/plugins/MirandaG15/src/LCDFramework/CLCDTextObject.cpp @@ -6,13 +6,14 @@ //************************************************************************
// constructor
//************************************************************************
-CLCDTextObject::CLCDTextObject() : m_bWordWrap(false), m_hFont(nullptr), m_iFontHeight(0)
+CLCDTextObject::CLCDTextObject()
{
// Initialize DRAWTEXTPARAMS
memset(&m_dtp, 0, sizeof(DRAWTEXTPARAMS));
- m_dtp.cbSize = sizeof(DRAWTEXTPARAMS);
+ m_dtp.cbSize = sizeof(DRAWTEXTPARAMS);
+
// Initialize alignment
- m_iTextFormat = m_iTextAlignment = (DT_LEFT | DT_NOPREFIX);
+ m_iTextFormat = m_iTextAlignment = (DT_LEFT | DT_NOPREFIX);
}
//************************************************************************
@@ -20,10 +21,8 @@ CLCDTextObject::CLCDTextObject() : m_bWordWrap(false), m_hFont(nullptr), m_iFont //************************************************************************
CLCDTextObject::~CLCDTextObject()
{
- if(m_hFont)
- {
+ if (m_hFont)
DeleteObject(m_hFont);
- }
}
//************************************************************************
@@ -31,9 +30,8 @@ CLCDTextObject::~CLCDTextObject() //************************************************************************
bool CLCDTextObject::Initialize()
{
- m_hFont = (HFONT) GetStockObject(DEFAULT_GUI_FONT);
- if(nullptr != m_hFont)
- {
+ m_hFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
+ if (nullptr != m_hFont) {
SetFontFaceName(L"Small Fonts");
SetFontPointSize(6);
}
@@ -69,29 +67,28 @@ bool CLCDTextObject::Update() //************************************************************************
bool CLCDTextObject::SetFont(LOGFONT& lf)
{
- if (m_hFont)
- {
- DeleteObject(m_hFont);
- m_hFont = nullptr;
- }
+ if (m_hFont) {
+ DeleteObject(m_hFont);
+ m_hFont = nullptr;
+ }
- m_hFont = CreateFontIndirect(&lf);
-
- if(!m_hFont)
+ m_hFont = CreateFontIndirect(&lf);
+
+ if (!m_hFont)
return false;
// Calculate the font's height
HDC hDC = CreateCompatibleDC(nullptr);
- SelectObject(hDC, m_hFont);
+ SelectObject(hDC, m_hFont);
TEXTMETRIC tmFontInfo;
- GetTextMetrics(hDC,&tmFontInfo);
+ GetTextMetrics(hDC, &tmFontInfo);
m_iFontHeight = tmFontInfo.tmHeight;
DeleteObject(hDC);
-
+
OnFontChanged();
-
+
return true;
}
@@ -101,16 +98,16 @@ bool CLCDTextObject::SetFont(LOGFONT& lf) void CLCDTextObject::SetFontFaceName(tstring strFontName)
{
// if NULL, uses the default gui font
- if (strFontName.empty())
- return;
+ if (strFontName.empty())
+ return;
- LOGFONT lf;
- memset(&lf, 0, sizeof(lf));
- GetObject(m_hFont, sizeof(LOGFONT), &lf);
+ LOGFONT lf;
+ memset(&lf, 0, sizeof(lf));
+ GetObject(m_hFont, sizeof(LOGFONT), &lf);
- wcsncpy(lf.lfFaceName, strFontName.c_str(), LF_FACESIZE);
+ wcsncpy(lf.lfFaceName, strFontName.c_str(), LF_FACESIZE);
- SetFont(lf);
+ SetFont(lf);
}
//************************************************************************
@@ -119,25 +116,26 @@ void CLCDTextObject::SetFontFaceName(tstring strFontName) void CLCDTextObject::SetFontPointSize(int nPointSize)
{
LOGFONT lf;
- memset(&lf, 0, sizeof(lf));
- GetObject(m_hFont, sizeof(LOGFONT), &lf);
+ memset(&lf, 0, sizeof(lf));
+ GetObject(m_hFont, sizeof(LOGFONT), &lf);
- lf.lfHeight = -MulDiv(nPointSize, 96, 72);
+ lf.lfHeight = -MulDiv(nPointSize, 96, 72);
- SetFont(lf);
+ SetFont(lf);
}
//************************************************************************
// sets the textobject's font to italic
//************************************************************************
-void CLCDTextObject::SetFontItalic(bool flag) {
+void CLCDTextObject::SetFontItalic(bool flag)
+{
LOGFONT lf;
- memset(&lf, 0, sizeof(lf));
- GetObject(m_hFont, sizeof(LOGFONT), &lf);
+ memset(&lf, 0, sizeof(lf));
+ GetObject(m_hFont, sizeof(LOGFONT), &lf);
- lf.lfItalic = flag;
+ lf.lfItalic = flag;
- SetFont(lf);
+ SetFont(lf);
}
//************************************************************************
@@ -146,12 +144,12 @@ void CLCDTextObject::SetFontItalic(bool flag) { void CLCDTextObject::SetFontWeight(int nWeight)
{
LOGFONT lf;
- memset(&lf, 0, sizeof(lf));
- GetObject(m_hFont, sizeof(LOGFONT), &lf);
+ memset(&lf, 0, sizeof(lf));
+ GetObject(m_hFont, sizeof(LOGFONT), &lf);
- lf.lfWeight = nWeight;
+ lf.lfWeight = nWeight;
- SetFont(lf);
+ SetFont(lf);
}
//************************************************************************
@@ -171,9 +169,9 @@ void CLCDTextObject::SetWordWrap(bool bWrap) {
m_bWordWrap = bWrap;
if (bWrap)
- m_iTextFormat |= DT_WORDBREAK;
- else
- m_iTextFormat &= ~DT_WORDBREAK;
+ m_iTextFormat |= DT_WORDBREAK;
+ else
+ m_iTextFormat &= ~DT_WORDBREAK;
}
//************************************************************************
@@ -181,5 +179,4 @@ void CLCDTextObject::SetWordWrap(bool bWrap) //************************************************************************
void CLCDTextObject::OnFontChanged()
{
-
}
diff --git a/plugins/MirandaG15/src/LCDFramework/CLCDTextObject.h b/plugins/MirandaG15/src/LCDFramework/CLCDTextObject.h index ddc32c5eac..88765c7d04 100644 --- a/plugins/MirandaG15/src/LCDFramework/CLCDTextObject.h +++ b/plugins/MirandaG15/src/LCDFramework/CLCDTextObject.h @@ -10,7 +10,7 @@ public: CLCDTextObject();
// destructor
~CLCDTextObject();
-
+
// initializes the textobject
bool Initialize();
// deinitializes the textobject
@@ -21,9 +21,9 @@ public: // sets the textobject's font's facename
void SetFontFaceName(tstring strFontName);
// sets the textobject's font's pointsize
- void SetFontPointSize(int nPointSize);
+ void SetFontPointSize(int nPointSize);
// sets the textobject's font's weight
- void SetFontWeight(int nWeight);
+ void SetFontWeight(int nWeight);
// sets the textobject's font's italic flag
void SetFontItalic(bool flag);
@@ -41,13 +41,14 @@ protected: virtual void OnFontChanged();
protected:
- bool m_bWordWrap;
+ bool m_bWordWrap = false;
+
+ HFONT m_hFont = nullptr;
+ int m_iFontHeight = 0;
+ UINT m_iTextFormat;
+ UINT m_iTextAlignment;
- HFONT m_hFont;
- int m_iFontHeight;
DRAWTEXTPARAMS m_dtp;
- UINT m_iTextFormat;
- UINT m_iTextAlignment;
};
-#endif
\ No newline at end of file +#endif
diff --git a/plugins/MirandaG15/src/LCDFramework/ConStream.cpp b/plugins/MirandaG15/src/LCDFramework/ConStream.cpp index 4c09b830ac..a201883269 100644 --- a/plugins/MirandaG15/src/LCDFramework/ConStream.cpp +++ b/plugins/MirandaG15/src/LCDFramework/ConStream.cpp @@ -33,15 +33,15 @@ // an ofstream object. This sets up ConStream so that it will direct
// its output to the given file.
//
-ConStream::ConStream() : m_Nul( m_fNul = fopen( "nul", "w" ) ), m_fConsole(nullptr),
+ConStream::ConStream() : m_Nul(m_fNul = fopen("nul", "w")), m_fConsole(nullptr),
#ifdef _UNICODE
- basic_ostream<wchar_t>( &m_Nul )
+basic_ostream<wchar_t>(&m_Nul)
#else
- basic_ostream<char>( &m_Nul )
+basic_ostream<char>(&m_Nul)
#endif
{
- m_FileBuf = nullptr;
- m_hConsole = INVALID_HANDLE_VALUE;
+ m_FileBuf = nullptr;
+ m_hConsole = INVALID_HANDLE_VALUE;
}
//
@@ -57,12 +57,12 @@ ConStream::ConStream() : m_Nul( m_fNul = fopen( "nul", "w" ) ), m_fConsole(nullp //
ConStream::~ConStream()
{
- delete m_FileBuf;
- if ( m_hConsole != INVALID_HANDLE_VALUE ) {
- FreeConsole();
- fclose( m_fConsole );
- }
- fclose( m_fNul );
+ delete m_FileBuf;
+ if (m_hConsole != INVALID_HANDLE_VALUE) {
+ FreeConsole();
+ fclose(m_fConsole);
+ }
+ fclose(m_fNul);
}
//
@@ -77,17 +77,17 @@ ConStream::~ConStream() //
void ConStream::Open()
{
- if ( m_hConsole == INVALID_HANDLE_VALUE ) {
+ if (m_hConsole == INVALID_HANDLE_VALUE) {
AllocConsole();
- m_hConsole = GetStdHandle( STD_OUTPUT_HANDLE );
- int handle = _open_osfhandle((INT_PTR)m_hConsole, _O_TEXT );
- m_fConsole = _fdopen( handle, "w" );
-#ifdef _UNICODE
- m_FileBuf = new basic_filebuf<wchar_t>( m_fConsole );
-#else
- m_FileBuf = new basic_filebuf<char>( m_fConsole );
-#endif
- init( m_FileBuf );
+ m_hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
+ int handle = _open_osfhandle((INT_PTR)m_hConsole, _O_TEXT);
+ m_fConsole = _fdopen(handle, "w");
+ #ifdef _UNICODE
+ m_FileBuf = new basic_filebuf<wchar_t>(m_fConsole);
+ #else
+ m_FileBuf = new basic_filebuf<char>(m_fConsole);
+ #endif
+ init(m_FileBuf);
setf(ios::unitbuf);
}
};
@@ -99,11 +99,10 @@ void ConStream::Open() //
void ConStream::Close()
{
- if ( m_hConsole != INVALID_HANDLE_VALUE ) {
- init( &m_Nul );
- FreeConsole();
- fclose( m_fConsole );
- m_hConsole = INVALID_HANDLE_VALUE;
- }
+ if (m_hConsole != INVALID_HANDLE_VALUE) {
+ init(&m_Nul);
+ FreeConsole();
+ fclose(m_fConsole);
+ m_hConsole = INVALID_HANDLE_VALUE;
+ }
};
-
\ No newline at end of file diff --git a/plugins/MirandaG15/src/LCDFramework/LCDObject.cpp b/plugins/MirandaG15/src/LCDFramework/LCDObject.cpp index 72971bc738..2374390d69 100644 --- a/plugins/MirandaG15/src/LCDFramework/LCDObject.cpp +++ b/plugins/MirandaG15/src/LCDFramework/LCDObject.cpp @@ -40,7 +40,7 @@ bool CLCDObject::Shutdown() //************************************************************************
// Set the origin of the object
//************************************************************************
-void CLCDObject::SetOrigin(int iX,int iY)
+void CLCDObject::SetOrigin(int iX, int iY)
{
m_Origin.x = iX;
m_Origin.y = iY;
@@ -62,7 +62,7 @@ POINT CLCDObject::GetOrigin() //************************************************************************
// Set the size of the object
//************************************************************************
-void CLCDObject::SetSize(int iWidth,int iHeight)
+void CLCDObject::SetSize(int iWidth, int iHeight)
{
SIZE OldSize = m_Size;
m_Size.cx = iWidth;
@@ -133,4 +133,4 @@ bool CLCDObject::Draw(CLCDGfx*) //************************************************************************
void CLCDObject::OnSizeChanged(SIZE)
{
-}
\ No newline at end of file +}
diff --git a/plugins/MirandaG15/src/LCDFramework/misc.cpp b/plugins/MirandaG15/src/LCDFramework/misc.cpp index f3397cd7ee..deb4430545 100644 --- a/plugins/MirandaG15/src/LCDFramework/misc.cpp +++ b/plugins/MirandaG15/src/LCDFramework/misc.cpp @@ -1,22 +1,6 @@ /* -------------------------------------------------------------------- */
#include "StdAfx.h"
-tstring tstringprintf(tstring strFormat,...) {
- va_list vlist;
-
- va_start(vlist, strFormat);
-
- int mlen = (int)strFormat.length()+128;
- wchar_t *text = (wchar_t*)malloc(mlen*sizeof(wchar_t));
- _vsnwprintf(text,mlen,strFormat.c_str(),vlist);
- va_end(vlist);
-
- strFormat = text;
- free(text);
-
- return strFormat;
-}
-
// Returns true if the unicode buffer only contains 7-bit characters.
BOOL IsUnicodeAscii(const wchar_t* pBuffer, int nSize)
{
@@ -32,69 +16,66 @@ BOOL IsUnicodeAscii(const wchar_t* pBuffer, int nSize) return bResult;
}
-
-wstring
-toWideString( const char* pStr , int len )
+wstring toWideString(const char* pStr, int len)
{
- if ( pStr == nullptr )
- return L"" ;
-
- //ASSERT_PTR( pStr ) ;
- ASSERT( len >= 0 || len == -1);
-
- // figure out how many wide characters we are going to get
- int nChars = MultiByteToWideChar( CP_ACP , 0 , pStr , len , nullptr , 0 ) ;
- if ( len == -1 )
- -- nChars ;
- if ( nChars == 0 )
- return L"" ;
-
- // convert the narrow string to a wide string
- // nb: slightly naughty to write directly into the string like this
- wstring buf ;
- buf.resize( nChars ) ;
- MultiByteToWideChar( CP_ACP , 0 , pStr , len ,
- const_cast<wchar_t*>(buf.c_str()) , nChars ) ;
-
- return buf ;
+ if (pStr == nullptr)
+ return L"";
+
+ //ASSERT_PTR( pStr ) ;
+ ASSERT(len >= 0 || len == -1);
+
+ // figure out how many wide characters we are going to get
+ int nChars = MultiByteToWideChar(CP_ACP, 0, pStr, len, nullptr, 0);
+ if (len == -1)
+ --nChars;
+ if (nChars == 0)
+ return L"";
+
+ // convert the narrow string to a wide string
+ // nb: slightly naughty to write directly into the string like this
+ wstring buf;
+ buf.resize(nChars);
+ MultiByteToWideChar(CP_ACP, 0, pStr, len,
+ const_cast<wchar_t*>(buf.c_str()), nChars);
+
+ return buf;
}
-/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
+/* ---------------------------------- */
-string
-toNarrowString( const wchar_t* pStr , int len )
+string
+toNarrowString(const wchar_t* pStr, int len)
{
- //ASSERT_PTR( pStr ) ;
- ASSERT( len >= 0 || len == -1) ;
-
- // figure out how many narrow characters we are going to get
- int nChars = WideCharToMultiByte( CP_ACP , 0 ,
- pStr , len , nullptr , 0 , nullptr , nullptr ) ;
- if ( len == -1 )
- -- nChars ;
- if ( nChars == 0 )
- return "" ;
-
- // convert the wide string to a narrow string
- // nb: slightly naughty to write directly into the string like this
- string buf ;
- buf.resize( nChars ) ;
+ //ASSERT_PTR( pStr ) ;
+ ASSERT(len >= 0 || len == -1);
+
+ // figure out how many narrow characters we are going to get
+ int nChars = WideCharToMultiByte(CP_ACP, 0,
+ pStr, len, nullptr, 0, nullptr, nullptr);
+ if (len == -1)
+ --nChars;
+ if (nChars == 0)
+ return "";
+
+ // convert the wide string to a narrow string
+ // nb: slightly naughty to write directly into the string like this
+ string buf;
+ buf.resize(nChars);
//char *test = (char*)malloc((nChars+1)*sizeof(char));
- WideCharToMultiByte( CP_ACP , 0 , pStr , len ,
- const_cast<char*>(buf.c_str()), nChars , nullptr , nullptr ) ;
+ WideCharToMultiByte(CP_ACP, 0, pStr, len,
+ const_cast<char*>(buf.c_str()), nChars, nullptr, nullptr);
- return buf ;
+ return buf;
}
/// get lower string
tstring toLower(const tstring &i_str)
{
- tstring str(i_str);
- for (size_t i = 0; i < str.size(); ++ i)
- {
- str[i] = tolower(str[i]);
- }
- return str;
+ tstring str(i_str);
+ for (size_t i = 0; i < str.size(); ++i) {
+ str[i] = tolower(str[i]);
+ }
+ return str;
}
/*
@@ -119,10 +100,10 @@ tstring Utf8_Decode(const char *str) size_t len = mir_strlen(str);
- if ((wszTemp = (WCHAR *) malloc(sizeof(wchar_t) * (len + 2))) == nullptr)
+ if ((wszTemp = (WCHAR *)malloc(sizeof(wchar_t) * (len + 2))) == nullptr)
return strRes;
-
- p = (char *) str;
+
+ p = (char *)str;
i = 0;
while (*p) {
if ((*p & 0x80) == 0)
@@ -157,27 +138,27 @@ string Utf8_Encode(const WCHAR *str) unsigned char *szOut = nullptr;
int len, i;
const WCHAR *wszTemp, *w;
-
- if (str == nullptr)
- return strRes;
- wszTemp = str;
+ if (str == nullptr)
+ return strRes;
+
+ wszTemp = str;
// Convert unicode to utf8
len = 0;
- for (w=wszTemp; *w; w++) {
+ for (w = wszTemp; *w; w++) {
if (*w < 0x0080) len++;
else if (*w < 0x0800) len += 2;
else len += 3;
}
- if ((szOut = (unsigned char *) malloc(len + 2)) == nullptr)
+ if ((szOut = (unsigned char *)malloc(len + 2)) == nullptr)
return strRes;
i = 0;
- for (w=wszTemp; *w; w++) {
+ for (w = wszTemp; *w; w++) {
if (*w < 0x0080)
- szOut[i++] = (unsigned char) *w;
+ szOut[i++] = (unsigned char)*w;
else if (*w < 0x0800) {
szOut[i++] = 0xc0 | ((*w) >> 6);
szOut[i++] = 0x80 | ((*w) & 0x3f);
@@ -189,26 +170,25 @@ string Utf8_Encode(const WCHAR *str) }
}
szOut[i] = '\0';
- strRes = (char *) szOut;
+ strRes = (char *)szOut;
free(szOut);
return strRes;
}
#endif
-
// Zufallszahlen
int GetRandomInt(int iMin, int iMax)
{
- double r = ((double)rand() / (RAND_MAX +1));
+ double r = ((double)rand() / (RAND_MAX + 1));
- int iRes = r*(iMax + 1- iMin) + iMin;
- if(iRes > iMax)
+ int iRes = r * (iMax + 1 - iMin) + iMin;
+ if (iRes > iMax)
Sleep(1);
return iRes;
}
double GetRandomDouble()
{
- return ((double)rand() / (RAND_MAX +1));
-}
\ No newline at end of file + return ((double)rand() / (RAND_MAX + 1));
+}
diff --git a/plugins/MirandaG15/src/LCDFramework/misc.h b/plugins/MirandaG15/src/LCDFramework/misc.h index 0ff1a01668..3707ef3a34 100644 --- a/plugins/MirandaG15/src/LCDFramework/misc.h +++ b/plugins/MirandaG15/src/LCDFramework/misc.h @@ -93,5 +93,3 @@ inline std::string toNarrowString( const std::string& str ) extern int GetRandomInt(int iMin, int iMax);
extern double GetRandomDouble();
-
-extern tstring tstringprintf(tstring strFormat,...);
\ No newline at end of file diff --git a/plugins/MirandaG15/src/LCDFramework/stdafx.h b/plugins/MirandaG15/src/LCDFramework/stdafx.h index 2ae74c24b1..e49059651f 100644 --- a/plugins/MirandaG15/src/LCDFramework/stdafx.h +++ b/plugins/MirandaG15/src/LCDFramework/stdafx.h @@ -13,9 +13,9 @@ using namespace std;
#ifdef _UNICODE
- #define tstring wstring
+#define tstring wstring
#else
- #define tstring string
+#define tstring string
#endif
#include <m_core.h>
diff --git a/plugins/MirandaG15/src/Miranda.cpp b/plugins/MirandaG15/src/Miranda.cpp index cf3a273e92..7118682634 100644 --- a/plugins/MirandaG15/src/Miranda.cpp +++ b/plugins/MirandaG15/src/Miranda.cpp @@ -29,8 +29,8 @@ #include "StdAfx.h"
#ifdef _DEBUG
- #include <crtdbg.h>
- #define _CRTDBG_MAP_ALLOC
+#include <crtdbg.h>
+#define _CRTDBG_MAP_ALLOC
#endif
#include "CAppletManager.h"
@@ -38,15 +38,15 @@ #include "m_system.h"
-// SETTINGS
+ // SETTINGS
#define LCD_FPS 10
#ifdef _WIN64
- #pragma comment(lib, "src\\LCDFramework\\hid\\x64\\hid.lib")
- #pragma comment(lib, "src\\LCDFramework\\g15sdk\\lib\\x64\\lgLcd.lib")
+#pragma comment(lib, "src\\LCDFramework\\hid\\x64\\hid.lib")
+#pragma comment(lib, "src\\LCDFramework\\g15sdk\\lib\\x64\\lgLcd.lib")
#else
- #pragma comment(lib, "src\\LCDFramework\\hid\\hid.lib")
- #pragma comment(lib, "src\\LCDFramework\\g15sdk\\lib\\x86\\lgLcd.lib")
+#pragma comment(lib, "src\\LCDFramework\\hid\\hid.lib")
+#pragma comment(lib, "src\\LCDFramework\\g15sdk\\lib\\x86\\lgLcd.lib")
#endif
//************************************************************************
@@ -54,7 +54,7 @@ //************************************************************************
bool g_bInitialized;
// AppletManager object
- CAppletManager* g_AppletManager;
+CAppletManager* g_AppletManager;
// Plugin Information
@@ -82,7 +82,8 @@ PLUGININFOEX pluginInfoEx = CMPlugin::CMPlugin() :
PLUGIN<CMPlugin>(nullptr, pluginInfoEx)
-{}
+{
+}
/////////////////////////////////////////////////////////////////////////////////////////
// Called by Miranda to load the plugin.
@@ -92,7 +93,7 @@ CMPlugin::CMPlugin() : int CMPlugin::Load()
{
g_bInitialized = false;
-
+
InitDebug();
TRACE(L"Plugin loaded\n");
// Schedule actual initialization for later
@@ -105,8 +106,8 @@ int CMPlugin::Load() int CMPlugin::Unload(void)
{
- if(!g_bInitialized) {
- TRACE(L"ERROR: Unload requested, but plugin is not initialized?!\n");
+ if (!g_bInitialized) {
+ TRACE(L"ERROR: Unload requested, but plugin is not initialized?!\n");
return 0;
}
TRACE(L"-------------------------------------------\nUnloading started\n");
@@ -129,18 +130,17 @@ int Init(WPARAM, LPARAM) {
g_AppletManager = new CAppletManager();
// Memoryleak Detection
- #ifdef _DEBUG
- _CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
-
- #endif
-
- // set up the LCD context as non-autostart, non-persist, callbacked
+#ifdef _DEBUG
+ _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
+
+#endif
+
+ // set up the LCD context as non-autostart, non-persist, callbacked
CConfig::Initialize();
// Initialize the output object
- if(!g_AppletManager->Initialize(toTstring(APP_SHORTNAME)))
- {
- if(CConfig::GetBoolSetting(SKIP_DRIVER_ERROR)) {
+ if (!g_AppletManager->Initialize(toTstring(APP_SHORTNAME))) {
+ if (CConfig::GetBoolSetting(SKIP_DRIVER_ERROR)) {
tstring text = L"Failed to initialize the LCD connection\n Make sure you have the newest Logitech drivers installed (>=1.03).\n";
tstring title = _A2W(APP_SHORTNAME);
MessageBox(nullptr, text.c_str(), title.c_str(), MB_OK | MB_ICONEXCLAMATION);
@@ -149,11 +149,12 @@ int Init(WPARAM, LPARAM) TRACE(L"Initialization failed!.\n");
return 0;
}
-
+
g_bInitialized = true;
TRACE(L"Initialization completed successfully.\n-------------------------------------------\n");
return 0;
}
+
//************************************************************************
// UnInit
//
@@ -161,10 +162,6 @@ int Init(WPARAM, LPARAM) //************************************************************************
void UnInit(void)
{
- g_AppletManager->Shutdown();
+ g_AppletManager->Shutdown();
delete g_AppletManager;
-
-//#ifdef _DEBUG
-// _CrtDumpMemoryLeaks();
-//#endif
}
diff --git a/plugins/MirandaG15/src/version.h b/plugins/MirandaG15/src/version.h index fb41a9e806..44d9c3f949 100644 --- a/plugins/MirandaG15/src/version.h +++ b/plugins/MirandaG15/src/version.h @@ -1,13 +1,13 @@ -#define __MAJOR_VERSION 0 -#define __MINOR_VERSION 1 +#define __MAJOR_VERSION 0 +#define __MINOR_VERSION 1 #define __RELEASE_NUM 2 -#define __BUILD_NUM 0 +#define __BUILD_NUM 1 #include <stdver.h> #define __PLUGIN_NAME "MirandaG15" #define __FILENAME "MirandaG15.dll" -#define __DESCRIPTION "Provides an interface to use Miranda from the LCD of various Logitech devices." -#define __AUTHOR "Martin Kleinhans" -#define __AUTHORWEB "https://miranda-ng.org/p/MirandaG15/" -#define __COPYRIGHT "© 2009 Martin Kleinhans" +#define __DESCRIPTION "Provides an interface to use Miranda from the LCD of various Logitech devices." +#define __AUTHOR "Martin Kleinhans" +#define __AUTHORWEB "https://miranda-ng.org/p/MirandaG15/" +#define __COPYRIGHT "© 2009 Martin Kleinhans" |