diff options
author | Vadim Dashevskiy <watcherhd@gmail.com> | 2013-11-04 08:59:15 +0000 |
---|---|---|
committer | Vadim Dashevskiy <watcherhd@gmail.com> | 2013-11-04 08:59:15 +0000 |
commit | c77821d0b4b3ae09e47ce6d6ca9d6b21dbb56d30 (patch) | |
tree | 4063ea096104679033e757b724b22da17534da21 /plugins/MirandaG15/src/LCDFramework/CLCDScreen.cpp | |
parent | 9d51dbf389539696b5d5e3417683c1709d957b6b (diff) |
LCDFramework project removed, integrated to MirandaG15 project
git-svn-id: http://svn.miranda-ng.org/main/trunk@6767 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/MirandaG15/src/LCDFramework/CLCDScreen.cpp')
-rw-r--r-- | plugins/MirandaG15/src/LCDFramework/CLCDScreen.cpp | 282 |
1 files changed, 282 insertions, 0 deletions
diff --git a/plugins/MirandaG15/src/LCDFramework/CLCDScreen.cpp b/plugins/MirandaG15/src/LCDFramework/CLCDScreen.cpp new file mode 100644 index 0000000000..fa1a59e49a --- /dev/null +++ b/plugins/MirandaG15/src/LCDFramework/CLCDScreen.cpp @@ -0,0 +1,282 @@ +#include "stdafx.h"
+#include "CLCDOutputManager.h"
+#include "CLCDGfx.h"
+#include "CLCDObject.h"
+#include "CLCDScreen.h"
+
+//************************************************************************
+// Constructor
+//************************************************************************
+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;
+}
+
+//************************************************************************
+// Destructor
+//************************************************************************
+CLCDScreen::~CLCDScreen()
+{
+
+}
+
+//************************************************************************
+// Initializes the screen
+//************************************************************************
+bool CLCDScreen::Initialize()
+{
+ CLCDConnection *pConnection = CLCDOutputManager::GetInstance()->GetLCDConnection();
+ if(pConnection->GetConnectionState() == CONNECTED) {
+ m_Size = pConnection->GetDisplaySize();
+ }
+
+ return true;
+}
+
+//************************************************************************
+// Shuts down the screen
+//************************************************************************
+bool CLCDScreen::Shutdown()
+{
+ // Shutdown all Objects
+ vector<CLCDObject*>::iterator iter = m_Objects.begin();
+ while(iter != m_Objects.end())
+ {
+ (*(iter))->Shutdown();
+ iter++;
+ }
+ return true;
+}
+
+//************************************************************************
+// called when the screens size has changed
+//************************************************************************
+void CLCDScreen::OnSizeChanged()
+{
+ CLCDConnection *pConnection = CLCDOutputManager::GetInstance()->GetLCDConnection();
+ if(!pConnection)
+ return;
+
+ m_Size = pConnection->GetDisplaySize();
+}
+
+//************************************************************************
+// Updates the screen
+//************************************************************************
+bool CLCDScreen::Update()
+{
+ // Loop through all objects and call their update function
+ vector<CLCDObject*>::iterator iter = m_Objects.begin();
+ CLCDObject *pObject = NULL;
+ while(iter != m_Objects.end())
+ {
+ pObject = *(iter);
+ pObject->Update();
+
+ iter++;
+ }
+ return true;
+}
+
+//************************************************************************
+// Draws the screen
+//************************************************************************
+bool CLCDScreen::Draw(CLCDGfx *pGfx)
+{
+ POINT ptPrevViewportOrg = { 0, 0 };
+ // Loop through all objects and call their draw function
+ vector<CLCDObject*>::iterator iter = m_Objects.begin();
+ CLCDObject *pObject = NULL;
+ while(iter != m_Objects.end())
+ {
+ pObject = *(iter);
+ // Only draw visible objects
+ 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->Draw(pGfx);
+
+ iter++;
+ }
+ // set the clipping region to nothing
+ SelectClipRgn(pGfx->GetHDC(), NULL);
+
+ // restore the viewport origin
+ SetViewportOrgEx(pGfx->GetHDC(),
+ 0,
+ 0,
+ NULL);
+
+ return true;
+}
+
+//************************************************************************
+// Set the screen's time until expiration
+//************************************************************************
+void CLCDScreen::SetExpiration(DWORD dwTime)
+{
+ if(dwTime == INFINITE)
+ m_dwExpiration = INFINITE;
+ else
+ m_dwExpiration = GetTickCount() + dwTime;
+}
+
+//************************************************************************
+// checks if the screen has expired
+//************************************************************************
+bool CLCDScreen::HasExpired()
+{
+ if(m_dwExpiration == INFINITE)
+ return false;
+
+ if(m_dwExpiration <= GetTickCount())
+ return true;
+ return false;
+}
+
+//************************************************************************
+// Set the alert status of the screen
+//************************************************************************
+void CLCDScreen::SetAlert(bool bAlert)
+{
+ m_bAlert = bAlert;
+}
+
+//************************************************************************
+// gets the alert status of the scren
+//************************************************************************
+bool CLCDScreen::GetAlert()
+{
+ return m_bAlert;
+}
+
+//************************************************************************
+// add an object to the screen's object list
+//************************************************************************
+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)
+ return false;
+ iter++;
+ }
+ m_Objects.push_back(pObject);
+ return true;
+}
+
+//************************************************************************
+// remove an object from the screen's object list
+//************************************************************************
+bool CLCDScreen::RemoveObject(CLCDObject *pObject)
+{
+ 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)
+ {
+ m_Objects.erase(iter);
+ return true;
+ }
+ iter++;
+ }
+ return false;
+}
+
+//************************************************************************
+// gets the screen's height
+//************************************************************************
+int CLCDScreen::GetHeight()
+{
+ return m_Size.cy;
+}
+
+//************************************************************************
+// gets the screen's width
+//************************************************************************
+int CLCDScreen::GetWidth()
+{
+ return m_Size.cx;
+}
+
+
+//************************************************************************
+// Called when the screen is activated
+//************************************************************************
+void CLCDScreen::OnActivation()
+{
+
+}
+
+//************************************************************************
+// Called when the screen is deactivated
+//************************************************************************
+void CLCDScreen::OnDeactivation()
+{
+
+}
+
+//************************************************************************
+// Called when the screen has expired
+//************************************************************************
+void CLCDScreen::OnExpiration()
+{
+
+}
+
+//************************************************************************
+// Called when an LCD-button is pressed
+//************************************************************************
+void CLCDScreen::OnLCDButtonDown(int iButton)
+{
+
+}
+
+//************************************************************************
+// Called when an LCD-button event is repeated
+//************************************************************************
+void CLCDScreen::OnLCDButtonRepeated(int iButton)
+{
+
+}
+
+//************************************************************************
+// Called when an LCD-button is released
+//************************************************************************
+void CLCDScreen::OnLCDButtonUp(int iButton)
+{
+
+}
\ No newline at end of file |