2017-12-30:增加部分API,适应多线程处理准备。

This commit is contained in:
Polarix 2017-12-27 20:03:30 +08:00
parent d747aa59a8
commit 3c64019635
73 changed files with 4934 additions and 1492 deletions

View File

@ -7,27 +7,24 @@
* License:
**************************************************************/
#ifndef __INCLUDE_LCD_APPLICATION_H__
#define __INCLUDE_LCD_APPLICATION_H__
#ifndef __INCLUDE_CLASS_APPLICATION_H__
#define __INCLUDE_CLASS_APPLICATION_H__
#include <wx/dialog.h>
#include <wx/app.h>
#include "LCD_VirtualDevice.h"
#include "LCDFrame.h"
class Application : public wxApp
{
private:
LCD_VirtualDevice* m_pclsMainFrame;
public:
LCDFrame* m_pclsMainFrame;
private:
bool OnInit(void);
int OnExit(void);
bool OnInit(void);
int OnExit(void);
};
#endif //__INCLUDE_LCD_APPLICATION_H__
#endif //__INCLUDE_CLASS_APPLICATION_H__

View File

@ -1,21 +1,47 @@
#include "wx\wx.h"
#include "Application.h"
#include "Common.h"
IMPLEMENT_APP(Application);
bool Application::OnInit(void)
{
/*----------------------------------*/
/* Variable Declaration */
/*----------------------------------*/
bool bReturn;
/*----------------------------------*/
/* Initialize */
/*----------------------------------*/
bReturn = true;
/*----------------------------------*/
/* Process */
/*----------------------------------*/
// Register image media handle.
wxInitAllImageHandlers();
// Read virtual device parameter.
SetDefaultParameterData(&g_stParameters);
// Create main frame instance.
LCDFrame::Initialize((wxFrame*)NULL);
m_pclsMainFrame = new LCD_VirtualDevice((wxWindow*)NULL);
m_pclsMainFrame = LCDFrame::GetInstance();
SetTopWindow(m_pclsMainFrame);
m_pclsMainFrame->Show();
return true;
if(NULL != m_pclsMainFrame)
{
SetTopWindow(m_pclsMainFrame);
m_pclsMainFrame->Show();
}
else
{
// Create instance failed.
bReturn = false;
}
return bReturn;
}
int Application::OnExit()
{
return 0;

View File

@ -1,5 +1,6 @@
#ifndef __INCLUDE_LCD_COMMON_H__
#define __INCLUDE_LCD_COMMON_H__
#ifndef __INCLUDE_COMMON_H__
#define __INCLUDE_COMMON_H__
#include <stddef.h>
#include <stdint.h>
#define LCD_COLOR_OBJ_PIX (0xFF168363)
@ -15,6 +16,20 @@
#define _TRANS_TEXT(STR) _(STR)
#define LCD_COLOR_OBJ_PIX (0xFF168363)
#define LCD_COLOR_OBJ_BKG (0xFF00F0D7)
#define LCD_COLOR_OBJ_EDGE (0xFF383834)
#define LCD_COLOR_OBJ_GRID (0xFF383834)
#define LCD_DEFAULT_CONFIG_FILE ("Config.xml")
#define PARAM_DEFAULT_PIXEL_NUM_H (128)
#define PARAM_DEFAULT_PIXEL_NUM_V (64)
#define PARAM_DEFAULT_PIXEL_SIZE (2)
#define PARAM_DEFAULT_EDGE_WIDTH (5)
#define PARAM_DEFAULT_GRID_ENABLE (true)
#define PARAM_DEFAULT_GRID_DISABLE (false)
typedef union
{
uint8_t Channel[4];
@ -35,4 +50,8 @@ typedef struct
}PixelPanelParameter;
extern PixelPanelParameter g_stParameters;
void SetDefaultParameterData(PixelPanelParameter* pstParameter);
#endif // __INCLUDE_LCD_COMMON_H__

23
Common/src/Common.cpp Normal file
View File

@ -0,0 +1,23 @@
#include "Common.h"
PixelPanelParameter g_stParameters;
void SetDefaultParameterData(PixelPanelParameter* pstParameter)
{
if(NULL != pstParameter)
{
// Appearance
pstParameter->HorizontalPixelNumber = PARAM_DEFAULT_PIXEL_NUM_H;
pstParameter->VerticalPixelNumber = PARAM_DEFAULT_PIXEL_NUM_V;
pstParameter->PixelSize = PARAM_DEFAULT_PIXEL_SIZE;
pstParameter->EdgeWidth = PARAM_DEFAULT_EDGE_WIDTH;
pstParameter->EnableGrid = PARAM_DEFAULT_GRID_DISABLE;
// ScreenColor
pstParameter->PanelColor.RGBA = LCD_COLOR_OBJ_BKG;
pstParameter->PixelColor.RGBA = LCD_COLOR_OBJ_PIX;
pstParameter->EdgeColor.RGBA = LCD_COLOR_OBJ_EDGE;
pstParameter->EdgeColor.RGBA = LCD_COLOR_OBJ_GRID;
}
}

View File

@ -49,9 +49,15 @@ extern HMI_SCREEN_OBJECT g_stHMI_DemoRealtimeGraph;
//=======================================================================//
//= Function declare. =//
//=======================================================================//
void SimpleGUI_DemoProcess(void);
#ifdef __cplusplus
extern "C"
{
#endif /* __cplusplus */
void SimpleGUI_DemoProcessInitialize(void);
HMI_ENGINE_RESULT InitializeEngine(HMI_ENGINE_OBJECT* pstHMIEngineObject);
HMI_ENGINE_RESULT EventProcess(HMI_EVENT_TYPE eEventType, const HMI_EVENT* pstEvent);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif // __INCLUDE_DEMO_PROC_H__

13
Demo/inc/DemoProcText.h Normal file
View File

@ -0,0 +1,13 @@
#ifndef __INCLUDE_DEMO_PROC_TEXT__
#define __INCLUDE_DEMO_PROC_TEXT__
#include "SGUI_Typedef.h"
#defien DEMO_START_NOTICE (\
" 欢迎来到SimpleGUI演示工程本工程用于演示SimpleGUI各API的显示效果、\
使SimpleGUI演示工\
\n\
"\
)
#endif // __INCLUDE_DEMO_PROC_TEXT__

View File

@ -1,6 +1,6 @@
/*************************************************************************/
/** Copyright. **/
/** FileName: HMI_Data.c **/
/** FileName: DemoProc.c **/
/** Author: Polarix **/
/** Version: 1.0.0.0 **/
/** Description: User operation interface. **/
@ -24,7 +24,7 @@
//=======================================================================//
HMI_ENGINE_OBJECT g_stDemoEngine;
//=======================================================================//
//= Function implementation. =//
//= Function define. =//
//=======================================================================//
/*****************************************************************************/
@ -33,10 +33,9 @@ HMI_ENGINE_OBJECT g_stDemoEngine;
/** Parameters: None. **/
/** Return: None. **/
/** Notice: This function demonstrates how to use the interface and **/
/** HMI engine of Simple GUI.
**/
/** HMI engine of Simple GUI. **/
/*****************************************************************************/
void SimpleGUI_DemoProcess(void)
void SimpleGUI_DemoProcessInitialize(void)
{
InitializeEngine(&g_stDemoEngine);
}
@ -45,7 +44,7 @@ void SimpleGUI_DemoProcess(void)
/** Function Name: InitializeEngine **/
/** Purpose: Initialize HMI demo engine. **/
/** Parameters: **/
/** @pstHMIEngineObject[in]: HMI engine object pointer. **/
/** @ pstHMIEngineObject[in]: HMI engine object pointer. **/
/** Return: HMI_ENGINE_RESULT. **/
/** Notice: This function must be called when initialize. **/
/*****************************************************************************/
@ -119,7 +118,8 @@ HMI_ENGINE_RESULT InitializeEngine(HMI_ENGINE_OBJECT* pstHMIEngineObject)
/** Function Name: EventProcess **/
/** Purpose: Process posted event. **/
/** Parameters: **/
/** @pstHMIEngineObject[in]: HMI engine object pointer. **/
/** @ eEventType[in]: HMI event type. **/
/** @ pstEvent[in]: HMI event data. **/
/** Return: HMI_ENGINE_RESULT. **/
/** Notice: This function must be called when initialize. **/
/*****************************************************************************/

View File

@ -0,0 +1,2 @@
#include "DemoProcText.h"

View File

@ -67,7 +67,7 @@ HMI_SCREEN_OBJECT g_stHMIDemo_List = { HMI_SCREEN_ID_DEMO_LIST,
};
//=======================================================================//
//= Function implementation. =//
//= Function define. =//
//=======================================================================//
HMI_ENGINE_RESULT HMI_DemoList_Initialize(void)
{

View File

@ -45,7 +45,7 @@ HMI_SCREEN_OBJECT g_stHMIDemo_RTCNotice = { HMI_SCREEN_ID_DEMO_RTC_NOTIC
};
//=======================================================================//
//= Function implementation. =//
//= Function define. =//
//=======================================================================//
HMI_ENGINE_RESULT HMI_DemoRTCNotice_Initialize(void)
{

View File

@ -40,7 +40,7 @@ HMI_SCREEN_OBJECT g_stHMI_DemoRealtimeGraph = { HMI_SCREEN_ID_DEMO_REAL_TIME
};
//=======================================================================//
//= Function implementation. =//
//= Function define. =//
//=======================================================================//
HMI_ENGINE_RESULT HMI_DemoRealGraph_Initialize(void)
{
@ -107,7 +107,7 @@ HMI_ENGINE_RESULT HMI_DemoRealGraph_ProcessEvent(HMI_EVENT_TYPE eEventType, cons
}
else
{
uiTimer = 10;
uiTimer = 5;
iNewValue = *((SGUI_INT*)pstEvent->Data);
SGUI_RealtimeGraph_AppendValue(&s_stRealtimeGraph, iNewValue);
HMI_DemoRealGraph_RefreshScreen(NULL);

View File

@ -41,7 +41,7 @@ static HMI_ENGINE_RESULT HMI_DemoScrollingText_PostProcess(SGUI_INT iActionRe
//= Static variable declaration. =//
//=======================================================================//
// Demo text.
static char s_szDemoText[] =
static SGUI_CCHAR s_szDemoText[] =
{
" 欢迎来到SimpleGUI演示工程本工程用于演示SimpleGUI各API的显示效果、\
使SimpleGUI演示工\
@ -72,7 +72,7 @@ HMI_SCREEN_OBJECT g_stHMIDemo_ScrollingText = {
&s_stDemoScrollingTextActions};
//=======================================================================//
//= Function implementation. =//
//= Function define. =//
//=======================================================================//
/*****************************************************************************/
/** Function Name: HMI_DemoScrollingText_Initialize **/
@ -139,7 +139,7 @@ HMI_ENGINE_RESULT HMI_DemoScrollingText_ProcessEvent(HMI_EVENT_TYPE eEventType,
/* Variable Declaration */
/*----------------------------------*/
HMI_ENGINE_RESULT eProcessResult;
static SGUI_UINT uiTimer = 3;
static SGUI_UINT uiTimer = 1;
SGUI_UINT16* parrKeyValue;
/*----------------------------------*/
@ -177,6 +177,7 @@ HMI_ENGINE_RESULT HMI_DemoScrollingText_ProcessEvent(HMI_EVENT_TYPE eEventType,
}
else
{
SGUI_Frame_DrawFullScreenFrame(&s_stTextFrame);
SGUI_Text_DrawMultipleLinesText(s_szDemoText, SGUI_FONT_SIZE_H12, &s_stTextDisplayArea, s_iTextOffset, SGUI_DRAW_NORMAL);
if(s_iTextOffset + s_iTextHeight == 0)
{
@ -186,7 +187,7 @@ HMI_ENGINE_RESULT HMI_DemoScrollingText_ProcessEvent(HMI_EVENT_TYPE eEventType,
{
s_iTextOffset--;
}
uiTimer = 2;
uiTimer = 1;
}
eProcessResult = HMI_RET_NOACTION;
break;

View File

@ -46,7 +46,7 @@ HMI_SCREEN_OBJECT g_stHMIDemo_TextNotice = { HMI_SCREEN_ID_DEMO_TEXT_NOTI
};
//=======================================================================//
//= Function implementation. =//
//= Function define. =//
//=======================================================================//
HMI_ENGINE_RESULT HMI_DemoTextNotice_Initialize(void)
{

View File

@ -73,7 +73,7 @@ HMI_SCREEN_OBJECT g_stHMIDemo_VariableBox = { HMI_SCREEN_ID_DEMO_VARIABL
};
//=======================================================================//
//= Function implementation. =//
//= Function define. =//
//=======================================================================//
HMI_ENGINE_RESULT HMI_DemoVariableBox_Initialize(void)
{

107
Frame/inc/LCDFrame.h Normal file
View File

@ -0,0 +1,107 @@
#ifndef __INCLUDE_CLASS_LCD_FRAME_H__
#define __INCLUDE_CLASS_LCD_FRAME_H__
//=======================================================================//
//= Include files. =//
//=======================================================================//
#include <wx/frame.h>
#include <wx/panel.h>
#include <wx/colour.h>
#include <wx/string.h>
#include <wx/statusbr.h>
#include <wx/toolbar.h>
#include <wx/clipbrd.h>
#include <wx/filefn.h>
#include <wx/timer.h>
#include "MonochromeDotLCD.h"
//=======================================================================//
//= User Macro definition. =//
//=======================================================================//
#define FRAME_TITLE (_T("SimpleGUI Simulator"))
#define wxID_MAIN 1000
#define wxID_TOOLBAR 2000
#define wxID_TOOLBAR_QUICKSHOTS 2100
#define wxID_TOOLBAR_COPY 2101
#define wxID_TOOLBAR_SCREENSHOTS_FOLDER 2102
#define wxID_TOOLBAR_ABOUT 2103
#define wxID_TOOLBAR_EXIT 2104
#define wxID_STATUSBAR 3000
#define wxID_PANEL 4000
#define WXID_MILLISECOND_TIMER 5001
#define WXID_RTC_TIMER 5002
#define SCREENSHOTS_FOLDER_T "ScreenShots"
#define SCREENSHOTS_FILE_NAME_T "LCD_%04u%02u%02u_%02u%02u-%u.bmp"
#define SCREENSHOTS_FILE_FULLNAME_T wxString::Format("%s\\%s", SCREENSHOTS_FOLDER_T, SCREENSHOTS_FILE_NAME_T)
#define N_YEAR wxDateTime::Now().GetYear()
#define N_MONTH wxDateTime::Now().GetMonth()
#define N_DAY wxDateTime::Now().GetDay()
#define N_HOUR wxDateTime::Now().GetHour()
#define N_MINUTE wxDateTime::Now().GetMinute()
#define SCREENSHOTS_FOLDER _T(SCREENSHOTS_FOLDER_T)
#define SCREENSHOTS_FILE_NAME(IDX) wxString::Format(SCREENSHOTS_FILE_NAME_T, N_YEAR, N_MONTH, N_DAY, N_HOUR, N_MINUTE, IDX)
#define SCREENSHOTS_FILE_FULLNAME(IDX) wxString::Format(SCREENSHOTS_FILE_FULLNAME_T, N_YEAR, N_MONTH, N_DAY, N_HOUR, N_MINUTE, IDX)
//=======================================================================//
//= Class declare. =//
//=======================================================================//
class LCDFrame : public wxFrame
{
private:
// Controlers
wxStatusBar* m_pclsCtrlStatusBar;
wxToolBar* m_pclsCtrlToolBar;
MonochromeDotLCD* m_pclsCtrlPaintPanel;
wxTimer* m_pclsMilliSecondTimer;
wxTimer* m_pclsRTCTimer;
static LCDFrame* m_pclsInstance;
// Members.
void _setStatusText(const wxString& strString);
void _wxEvent_OnUpdateUI(wxUpdateUIEvent& clsEventObject) {OnUpdateUI(clsEventObject);}
void _wxEvent_OnSetFocus(wxFocusEvent& clsEventObject) {SetFocus();}
void _wxEvent_OnClose(wxCloseEvent& clsEventObject) {OnClose();}
void _wxEvent_OnKeyDown(wxKeyEvent& clsEventObject) {OnKeyDown(clsEventObject);}
void _wxEvent_OnPaint(wxPaintEvent& clsEventObject) {OnPaint(clsEventObject);clsEventObject.Skip();}
void _wxEvent_OnScreenshots(wxCommandEvent& clsEventObject) {Screenshots();}
void _wxEvent_OnToolCopy(wxCommandEvent& clsEventObject) {Copy();}
void _wxEvent_OnOpenScreenshotsFolder(wxCommandEvent &clsEventObject){OpenScreenshotsFolder();}
void _wxEvent_OnAbout(wxCommandEvent& clsEventObject) {;}
void _wxEvent_OnExit(wxCommandEvent& clsEventObject) {OnClose();}
void _wxEvent_OnTimerEvent(wxTimerEvent& event) {OnTimerEvent(event);}
void _wxEvent_OnRTCUpdate(wxTimerEvent& event) {OnRTCUpdate(event);}
void _createToolbar(void);
void _initializeTimer(void);
void _startTimer(int32_t iMilliSecondTimerInterval);
protected:
virtual void OnUpdateUI(wxUpdateUIEvent& clsEventObject);
virtual void OnClose(void);
virtual void OnKeyDown(wxKeyEvent& clsEventObject);
virtual void OnPaint(wxPaintEvent &clsEventObject);
virtual void Screenshots(void);
virtual void Copy(void);
virtual void OpenScreenshotsFolder(void);
virtual void OnTimerEvent(wxTimerEvent& event);
virtual void OnRTCUpdate(wxTimerEvent& event);
public:
LCDFrame( wxWindow* pclsParent,
wxWindowID iID = wxID_MAIN,
const wxString& strTitle = FRAME_TITLE);
~LCDFrame();
static void Initialize( wxWindow* pclsParent,
wxWindowID iID = wxID_MAIN,
const wxString& strTitle = FRAME_TITLE);
static LCDFrame* GetInstance(void);
void SetLCDPixel(uint32_t uiPosX, uint32_t uiPosY, uint32_t uiPixelValue);
uint32_t GetLCDPixel(uint32_t uiPosX, uint32_t uiPosY);
void RefreshLCD(void);
void ClearLCD(void);
DECLARE_EVENT_TABLE();
};
#endif //__INCLUDE_CLASS_LCD_FRAME_H__

View File

@ -1,52 +0,0 @@
#ifndef __INCLUDE_LCD_OPERATIONIF_H__
#define __INCLUDE_LCD_OPERATIONIF_H__
#include "LCD_VirtualDeviceParameter.h"
#include <stddef.h>
#include <stdint.h>
#include <stdbool.h>
#define RECT_START_X(R) (R.StartPosX)
#define RECT_START_Y(R) (R.StartPosY)
#define RECT_END_X(R) (R.EndPosX)
#define RECT_END_Y(R) (R.EndPosY)
#define RECT_INVALID_POSITION (-1)
#define RECT_RESET(R) {R.StartPosX=RECT_INVALID_POSITION;R.EndPosX=RECT_INVALID_POSITION;R.StartPosY=RECT_INVALID_POSITION;R.EndPosY=RECT_INVALID_POSITION;}
#ifdef __cplusplus
extern "C"
{
#endif
typedef struct
{
uint16_t StartPosX;
uint16_t StartPosY;
uint16_t EndPosX;
uint16_t EndPosY;
}TRect;
typedef struct
{
uint8_t Pixregister[LCD_SIZE_WIDTH][LCD_SIZE_HEIGHT];
bool InUpdating;
TRect ChangedArea;
}TPixArray;
// LCD Pix data array.
extern TPixArray g_LCDPixArray;
// Interface function declare
void VTIF_KeyBoardEvent(bool bShift, bool bCtrl, bool bAlt, uint16_t uiKeyCode);
void VTIF_TimerEvent(void);
void VTIF_RTCUpdateEvent(uint16_t uiYear, uint16_t uiMonth, uint16_t uiDay, uint16_t uiHour, uint16_t uiMinute, uint16_t uiSecond);
void VTIF_LCDInitializeDisplay(void);
void VTIF_SetPoint(uint16_t uiPosX, uint16_t uiPosY, uint8_t uiPixValue);
uint8_t VTIF_GetPoint(uint16_t uiPosX, uint16_t uiPosY);
void VTIF_ClearScreen(void);
#ifdef __cplusplus
}
#endif
#endif // __INCLUDE_LCD_OPERATIONIF_H__

View File

@ -1,150 +0,0 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Jun 17 2015)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#ifndef __INCLUDE_LCD_VIRTUAL_DEVICE_H__
#define __INCLUDE_LCD_VIRTUAL_DEVICE_H__
#include "LCD_VirtualDeviceParameter.h"
#include "LCD_OperationIF.h"
#include <wx/dcbuffer.h>
#include <wx/artprov.h>
#include <wx/xrc/xmlres.h>
#include <wx/panel.h>
#include <wx/gdicmn.h>
#include <wx/font.h>
#include <wx/colour.h>
#include <wx/string.h>
#include <wx/statusbr.h>
#include <wx/toolbar.h>
#include <wx/frame.h>
///////////////////////////////////////////////////////////////////////////
#define FRAME_TITLE (_T("SimpleGUI Simulator"))
#define wxID_MAIN 1000
#define wxID_TOOLBAR 2000
#define wxID_TOOLBAR_SCREENSHOTS 2100
#define wxID_TOOLBAR_COPY 2101
#define wxID_TOOLBAR_SCREENSHOTS_FOLDER 2102
#define wxID_TOOLBAR_ABOUT 2103
#define wxID_TOOLBAR_EXIT 2104
#define wxID_STATUSBAR 3000
#define wxID_PANEL 4000
#define WXID_TIMER 9001
#define WXID_RTCTIMER 9002
#define DC_PREPARE(DC) {DC.SetBrush(m_CBrush); DC.SetPen(m_CPen);}
#define DC_RELEASE(DC) {DC.SetBrush(wxNullBrush); DC.SetPen(wxNullPen);}
#if LCD_PIXSIZE > 1
#define DC_DRAW_POINT(DC, POSX, POSY) {DC.DrawRectangle(wxPoint(LCD_SIZE_MARGIN+POSX*LCD_PIXSIZE, LCD_SIZE_MARGIN+POSY*LCD_PIXSIZE), wxSize(LCD_PIXSIZE, LCD_PIXSIZE));}
#else
#define DC_DRAW_POINT(DC, POSX, POSY) {DC.DrawPoint(wxPoint(LCD_SIZE_MARGIN+POSX*LCD_PIXSIZE, LCD_SIZE_MARGIN+POSY*LCD_PIXSIZE));}
#endif // LCD_PIXSIZE
#define DC_SET_COLOR(COLOR) {m_CPen.SetColour(COLOR);m_CBrush.SetColour(COLOR);}
#define SCREENSHOTS_FOLDER_T "..\\..\\ScreenShots"
#define SCREENSHOTS_FILE_NAME_T "LCD_%04u%02u%02u_%02u%02u-%u.bmp"
#define SCREENSHOTS_FILE_FULLNAME_T wxString::Format("%s\\%s", SCREENSHOTS_FOLDER_T, SCREENSHOTS_FILE_NAME_T)
#define N_YEAR wxDateTime::Now().GetYear()
#define N_MONTH wxDateTime::Now().GetMonth()
#define N_DAY wxDateTime::Now().GetDay()
#define N_HOUR wxDateTime::Now().GetHour()
#define N_MINUTE wxDateTime::Now().GetMinute()
#define SCREENSHOTS_FOLDER _T(SCREENSHOTS_FOLDER_T)
#define SCREENSHOTS_FILE_NAME(IDX) wxString::Format(SCREENSHOTS_FILE_NAME_T, N_YEAR, N_MONTH, N_DAY, N_HOUR, N_MINUTE, IDX)
#define SCREENSHOTS_FILE_FULLNAME(IDX) wxString::Format(SCREENSHOTS_FILE_FULLNAME_T, N_YEAR, N_MONTH, N_DAY, N_HOUR, N_MINUTE, IDX)
///////////////////////////////////////////////////////////////////////////////
/// Class LCD_DisplayPanel
///////////////////////////////////////////////////////////////////////////////
class LCD_DisplayPanel : public wxPanel
{
private:
// Private object
wxPen m_CPen;
wxBrush m_CBrush;
wxClientDC m_CDC;
TPixArray* m_PixRegister;
void wxEvent_OnKeyDown(wxKeyEvent& event);
void wxEvent_OnSetFocus(wxFocusEvent& event);
protected:
public:
LCD_DisplayPanel( wxWindow* parent,
wxWindowID id = wxID_PANEL,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxSize(LCD_SIZE_WIDTH*LCD_PIXSIZE+2*LCD_SIZE_MARGIN, LCD_SIZE_HEIGHT*LCD_PIXSIZE+2*LCD_SIZE_MARGIN),
long style = wxTAB_TRAVERSAL);
~LCD_DisplayPanel(void);
void Paint(void);
void PartialPaint(void);
virtual bool SaveToFile(const wxString& CStrFilePath);
virtual bool CopyToClipBoard(void);
DECLARE_EVENT_TABLE();
};
///////////////////////////////////////////////////////////////////////////////
/// Class LCD_VirtualDevice
///////////////////////////////////////////////////////////////////////////////
class LCD_VirtualDevice : public wxFrame
{
private:
void SetStatusText(const wxString& cString);
void wxEvent_OnUpdateUI(wxUpdateUIEvent& event) {OnUpdateUI(event);}
void wxEvent_OnSetFocus(wxFocusEvent& event) {SetFocus();}
void wxEvent_OnClose(wxCloseEvent& event) {OnClose(event);}
void wxEvent_OnKeyDown(wxKeyEvent& event) {OnKeyDown(event);}
void wxEvent_OnPaint(wxPaintEvent &event) {OnPaint(event);event.Skip();}
void wxEvent_OnScreenshots(wxCommandEvent &event){Screenshots();}
void wxEvent_OnToolCopy(wxCommandEvent &event) {Copy();}
void wxEvent_OnOpenScreenshotsFolder(wxCommandEvent &event){OpenScreenshotsFolder();}
void wxEvent_OnAbout(wxCommandEvent &event) {;}
void wxEvent_OnExit(wxCommandEvent &event) {Destroy();}
void wxEvent_OnTimerEvent(wxTimerEvent& event) {OnTimer(event);}
void wxEvent_OnRTCUpdate(wxTimerEvent& event) {OnRTCUpdate(event);}
protected:
// Controlers
wxStatusBar* m_CtrlStatusBar;
wxToolBar* m_CtrlToolBar;
wxToolBarToolBase* m_CtrlToolButton_Screenshots;
wxToolBarToolBase* m_CtrlToolButton_ScreenCpoy;
wxToolBarToolBase* m_CtrlToolButton_OpenFolder;
wxToolBarToolBase* m_CtrlToolButton_About;
wxToolBarToolBase* m_CtrlToolButton_Exit;
LCD_DisplayPanel* m_CtrlPaintPanel;
wxTimer* m_pclsTimer;
wxTimer* m_pclsRTCTimer;
virtual void OnUpdateUI(wxUpdateUIEvent& event);
virtual void OnClose(wxCloseEvent& event) {Destroy();}
virtual void OnKeyDown(wxKeyEvent& event);
virtual void OnPaint(wxPaintEvent &event);
virtual void Screenshots(void);
virtual void Copy(void);
virtual void OpenScreenshotsFolder(void);
virtual void OnTimer(wxTimerEvent& event);
virtual void OnRTCUpdate(wxTimerEvent& event);
public:
LCD_VirtualDevice( wxWindow* parent,
wxWindowID id = wxID_MAIN,
const wxString& title = FRAME_TITLE,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxSize(500,300),
long style = wxSYSTEM_MENU | wxCAPTION | wxCLOSE_BOX | wxCLIP_CHILDREN);
~LCD_VirtualDevice();
DECLARE_EVENT_TABLE();
};
#endif //__INCLUDE_LCD_VIRTUAL_DEVICE_H__

View File

@ -1,29 +0,0 @@
#ifndef __INCLUDE_LCD_VIRTUALDEVICEPARAMETER_H_INCLUDED__
#define __INCLUDE_LCD_VIRTUALDEVICEPARAMETER_H_INCLUDED__
// Parameter
#define LCD_SIZE_MARGIN (10)
#define LCD_DISPLAY_EDGE (2)
#define LCD_PIXSIZE (2)
#define LCD_SIZE_WIDTH (192)
#define LCD_SIZE_HEIGHT (64)
#define LCD_COLOR_OBJ_PIX (wxColor(88,120,20))
#define LCD_COLOR_OBJ_BKG (wxColor(202,246,22))
#define LCD_COLOR_OBJ_EDGE (wxColor(116,164,25))
#define FRM_COLOR_OBJ_BKG (wxColor(51,100,195))
#if LCD_SIZE_WIDTH < 16
#error Define width of LCD size must greater then 16.
#endif
#if LCD_SIZE_HEIGHT < 16
#error Define height of LCD size must greater then 16.
#endif
//Common operation
//#define SET_BIT(PAGE, Bit) ((PAGE) = (PAGE) | (0x01 << (Bit)))
//#define CLR_BIT(PAGE, Bit) ((PAGE) = (PAGE) & (~(0x01 << (Bit))))
#define GET_BIT(PAGE, Bit) ((((PAGE) & (0x01 << (Bit)))>0)?1:0)
#endif //__INCLUDE_LCD_VIRTUALDEVICEPARAMETER_H_INCLUDED__

View File

@ -0,0 +1,50 @@
#ifndef __INCLUDE_CLASS_PIXEL_PANEL_H__
#define __INCLUDE_CLASS_PIXEL_PANEL_H__
//=======================================================================//
//= Include files. =//
//=======================================================================//
#include "wxDotLCD.h"
#include "Common.h"
#include <wx/colour.h>
//=======================================================================//
//= Class declare. =//
//=======================================================================//
class MonochromeDotLCD : public wxDotLCD
{
private:
uint32_t m_uiPageCount;
uint32_t m_uiColumnCount;
wxColor* m_pclsPanelColor;
wxColor* m_pclsPixelColor;
void wxEvent_OnSetFocus(wxFocusEvent& event) {OnSetFocus(event);}
protected:
void OnSetFocus(wxFocusEvent& event);
public:
typedef enum
{
LCD_PIXEL_COLOR_L = 0,
LCD_PIXEL_COLOR_H,
}LCD_PIXEL_COLOR_T;
MonochromeDotLCD(wxWindow *parent,
wxWindowID winid = wxID_ANY,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxTAB_TRAVERSAL | wxNO_BORDER,
const wxString& name = wxPanelNameStr);
~MonochromeDotLCD(void);
void SetParameter(PixelPanelParameter* pstPanelParameter);
void SetPixel(uint32_t uiPosX, uint32_t uiPosY, LCD_PIXEL_COLOR_T ePixelValue);
LCD_PIXEL_COLOR_T GetPixel(uint32_t uiPosX, uint32_t uiPosY);
void DrawPixel(uint32_t uiPosX, uint32_t uiPosY, LCD_PIXEL_COLOR_T ePixelValue);
void CleanScreen(void);
DECLARE_EVENT_TABLE();
};
#endif // __INCLUDE_CLASS_PIXEL_PANEL_H__

View File

@ -1,46 +0,0 @@
#ifndef __INCLUDE_CLS_LCD_SCREENPANEL_H__
#define __INCLUDE_CLS_LCD_SCREENPANEL_H__
#include <wx/colour.h>
#include "wxPixelPanel.h"
#include "Common.h"
class LCD_ScreenPanel : public wxPixelPanel
{
private:
uint32_t m_uiPageCount;
uint32_t m_uiColumnCount;
uint32_t m_uiPosColumn;
uint32_t m_uiPosPage;
wxColor* m_pclsPanelColor;
wxColor* m_pclsPixelColor;
void wxEvent_OnMouseClick(wxMouseEvent& event) {OnMouseClick(event);}
protected:
void OnMouseClick(wxMouseEvent& event);
public:
LCD_ScreenPanel( wxWindow *parent,
wxWindowID winid = wxID_ANY,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxTAB_TRAVERSAL | wxNO_BORDER,
const wxString& name = wxPanelNameStr);
~LCD_ScreenPanel(void);
void SetParameter(PixelPanelParameter* pstPanelParameter);
void SetColumn(uint32_t uiColumn);
void SetPage(uint32_t uiPage);
void SetPosition(uint32_t uiColumn, uint32_t uiPage);
void SetData(uint8_t uiData);
uint8_t GetData(void);
void CleanPanel(void);
DECLARE_EVENT_TABLE();
};
#endif // __INCLUDE_CLS_LCD_SCREENPANEL_H__

498
Frame/src/LCDFrame.cpp Normal file
View File

@ -0,0 +1,498 @@
/*************************************************************************/
/** Copyright. **/
/** FileName: LCDFrame.cpp **/
/** Author: Polarix **/
/** Version: 1.7.0.0 **/
/** Description: Main frame class define. **/
/*************************************************************************/
//=======================================================================//
//= Include files. =//
//=======================================================================//
#include <wx/msgdlg.h>
#include "LCDFrame.h"
#include "UserActionInterface.h"
//=======================================================================//
//= Static class member define. =//
//=======================================================================//
LCDFrame* LCDFrame::m_pclsInstance = NULL;
//=======================================================================//
//= Event table. =//
//=======================================================================//
BEGIN_EVENT_TABLE(LCDFrame,wxFrame)
EVT_UPDATE_UI(wxID_MAIN, LCDFrame::_wxEvent_OnUpdateUI)
EVT_SET_FOCUS(LCDFrame::_wxEvent_OnSetFocus)
EVT_CLOSE(LCDFrame::_wxEvent_OnClose)
EVT_SET_FOCUS(LCDFrame::_wxEvent_OnSetFocus)
EVT_KEY_DOWN(LCDFrame::_wxEvent_OnKeyDown)
EVT_PAINT(LCDFrame::_wxEvent_OnPaint)
EVT_TOOL(wxID_TOOLBAR_QUICKSHOTS, LCDFrame::_wxEvent_OnScreenshots)
EVT_TOOL(wxID_TOOLBAR_COPY, LCDFrame::_wxEvent_OnToolCopy)
EVT_TOOL(wxID_TOOLBAR_SCREENSHOTS_FOLDER, LCDFrame::_wxEvent_OnOpenScreenshotsFolder)
EVT_TOOL(wxID_TOOLBAR_EXIT, LCDFrame::_wxEvent_OnExit)
EVT_TIMER(WXID_MILLISECOND_TIMER, LCDFrame::_wxEvent_OnTimerEvent)
EVT_TIMER(WXID_RTC_TIMER , LCDFrame::_wxEvent_OnRTCUpdate)
END_EVENT_TABLE()
//=======================================================================//
//= Function define. =//
//=======================================================================//
/*************************************************************************/
/** Function Name: LCDFrame **/
/** Purpose: Constructor of main frame object. **/
/** Params: **/
/** @ pclsParent[in]: Parent object pointer. **/
/** @ iID[in]: Frame object ID. **/
/** @ strTitle[in]: Frame window title. **/
/** Return: None. **/
/** Notice: None. **/
/*************************************************************************/
LCDFrame::LCDFrame(wxWindow* pclsParent, wxWindowID iID, const wxString& strTitle) :
wxFrame(pclsParent, iID, strTitle, wxDefaultPosition, wxDefaultSize, wxSYSTEM_MENU | wxCAPTION | wxCLOSE_BOX | wxCLIP_CHILDREN)
{
SetSizeHints( wxDefaultSize, wxDefaultSize );
// Set frame icon.
SetIcon(wxIcon(_T("ID_ICON_MAIN"), wxBITMAP_TYPE_ICO_RESOURCE));
// Create tools bar and tool button.
_createToolbar();
// Create status bar.
m_pclsCtrlStatusBar = CreateStatusBar(1, wxST_SIZEGRIP, wxID_STATUSBAR);
// Create LCD screen panel.
m_pclsCtrlPaintPanel = new MonochromeDotLCD(this, wxID_PANEL);
m_pclsCtrlPaintPanel->SetParameter(&g_stParameters);
m_pclsCtrlPaintPanel->ResizeParent();
// Set frame object position on monitor.
Centre( wxBOTH );
// Update frame object UI.
UpdateWindowUI();
if(false == wxDirExists(SCREENSHOTS_FOLDER))
{
wxMkdir(SCREENSHOTS_FOLDER);
}
}
/*************************************************************************/
/** Function Name: ~LCDFrame **/
/** Purpose: Destructor of main frame object. **/
/** Params: None. **/
/** Return: None. **/
/** Notice: None. **/
/*************************************************************************/
LCDFrame::~LCDFrame()
{
/*----------------------------------*/
/* Process */
/*----------------------------------*/
delete m_pclsCtrlStatusBar;
delete m_pclsCtrlToolBar;
delete m_pclsCtrlPaintPanel;
}
/*************************************************************************/
/** Function Name: _setStatusText **/
/** Purpose: Set frame status bar text. **/
/** Params: **/
/** @ strString[in]: Set text. **/
/** Return: None. **/
/** Notice: None. **/
/*************************************************************************/
void LCDFrame::_setStatusText(const wxString& strString)
{
/*----------------------------------*/
/* Process */
/*----------------------------------*/
m_pclsCtrlStatusBar->SetStatusText(strString, 0);
}
/*************************************************************************/
/** Function Name: _createToolbar **/
/** Purpose: Create main frame tool bar. **/
/** Params: None. **/
/** Return: None. **/
/** Notice: None. **/
/*************************************************************************/
void LCDFrame::_createToolbar(void)
{
/*----------------------------------*/
/* Variable Declaration */
/*----------------------------------*/
wxToolBar* pclsNewToolBar;
/*----------------------------------*/
/* Initialize */
/*----------------------------------*/
pclsNewToolBar = NULL;
/*----------------------------------*/
/* Process */
/*----------------------------------*/
// Create tools bar.
pclsNewToolBar = CreateToolBar(wxTB_HORIZONTAL, wxID_TOOLBAR);
if(NULL != pclsNewToolBar)
{
// Screen shot button.
pclsNewToolBar->AddTool(wxID_TOOLBAR_QUICKSHOTS, _TRANS_TEXT("Quick Shot"),
wxBitmap(_T("ID_TOOL_QUICKSHOTS"), wxBITMAP_TYPE_PNG_RESOURCE),
wxBitmap(_T("ID_TOOL_QUICKSHOTS"), wxBITMAP_TYPE_PNG_RESOURCE),
wxITEM_NORMAL,
_TRANS_TEXT("Quick Shot"),
_TRANS_TEXT("Quick save screen shot to file."));
pclsNewToolBar->AddTool(wxID_TOOLBAR_COPY, _TRANS_TEXT("Copy Screen Image"),
wxBitmap(_T("ID_TOOL_COPYSCREENSHOT"), wxBITMAP_TYPE_PNG_RESOURCE),
wxBitmap(_T("ID_TOOL_COPYSCREENSHOT"), wxBITMAP_TYPE_PNG_RESOURCE),
wxITEM_NORMAL,
_TRANS_TEXT("Copy Screen Image"),
_TRANS_TEXT("Copy screenshots picture to clipboard."));
pclsNewToolBar->AddTool(wxID_TOOLBAR_SCREENSHOTS_FOLDER, _TRANS_TEXT("Open Screenshots Folder"),
wxBitmap(_T("ID_TOOL_OPENSCREENSHOTSFOLDER"), wxBITMAP_TYPE_PNG_RESOURCE),
wxBitmap(_T("ID_TOOL_OPENSCREENSHOTSFOLDER"), wxBITMAP_TYPE_PNG_RESOURCE),
wxITEM_NORMAL,
_TRANS_TEXT("Open Screenshots Folder"),
_TRANS_TEXT("Open screenshots saved folder."));
// Add a separator.
pclsNewToolBar->AddSeparator();
pclsNewToolBar->AddTool(wxID_TOOLBAR_EXIT, _TRANS_TEXT("Exit"),
wxBitmap(_T("ID_TOOL_EXIT"), wxBITMAP_TYPE_PNG_RESOURCE),
wxBitmap(_T("ID_TOOL_EXIT"), wxBITMAP_TYPE_PNG_RESOURCE),
wxITEM_NORMAL,
_TRANS_TEXT("Exit(Alt+F4)"),
_TRANS_TEXT("Exit."));
pclsNewToolBar->Realize();
}
m_pclsCtrlToolBar = pclsNewToolBar;
}
/*************************************************************************/
/** Function Name: _initializeTimer **/
/** Purpose: Create and initialize interrupt timer and RTC timer.**/
/** Params: None. **/
/** Return: None. **/
/** Notice: None. **/
/*************************************************************************/
void LCDFrame::_initializeTimer(void)
{
m_pclsMilliSecondTimer = new wxTimer(this, WXID_MILLISECOND_TIMER);
m_pclsRTCTimer = new wxTimer(this, WXID_RTC_TIMER);
}
/*************************************************************************/
/** Function Name: _startTimer **/
/** Purpose: Create and initialize interrupt timer and RTC timer.**/
/** Params: None. **/
/** Return: None. **/
/** Notice: None. **/
/*************************************************************************/
void LCDFrame::_startTimer(int32_t iMilliSecondTimerInterval)
{
if(NULL != m_pclsMilliSecondTimer)
{
if(0 < iMilliSecondTimerInterval)
{
m_pclsMilliSecondTimer->Start(iMilliSecondTimerInterval);
}
}
if(NULL != m_pclsRTCTimer)
{
m_pclsRTCTimer->Start(1000);
}
}
/*************************************************************************/
/** Function Name: OnKeyDown **/
/** Purpose: Key press event process. **/
/** Params: **/
/** @ clsEventObject[in]: Event data object. **/
/** Return: None. **/
/** Notice: None. **/
/*************************************************************************/
void LCDFrame::OnKeyDown(wxKeyEvent& clsEventObject)
{
/*----------------------------------*/
/* Variable Declaration */
/*----------------------------------*/
int iKeyCode;
/*----------------------------------*/
/* Initialize */
/*----------------------------------*/
iKeyCode = clsEventObject.GetKeyCode();
/*----------------------------------*/
/* Process */
/*----------------------------------*/
//wxMessageBox(wxString::Format("Key value: %d.", iKeyCode));
UAIF_OnKeyPress(clsEventObject.ShiftDown(), clsEventObject.ControlDown(), clsEventObject.AltDown(), iKeyCode);
}
/*************************************************************************/
/** Function Name: Copy **/
/** Purpose: Copy screen image to clipboard. **/
/** Params: None. **/
/** Return: None. **/
/** Notice: None. **/
/*************************************************************************/
void LCDFrame::Copy(void)
{
/*----------------------------------*/
/* Variable Declaration */
/*----------------------------------*/
bool bResult;
/*----------------------------------*/
/* Process */
/*----------------------------------*/
bResult = m_pclsCtrlPaintPanel->CopyScreenImageToClipBoard();
if(true == bResult)
{
_setStatusText(_T("Copied to clipboard."));
}
else
{
_setStatusText(_T("Copy failed."));
}
}
/*************************************************************************/
/** Function Name: Screenshots **/
/** Purpose: Save now time screen image to a bit map file. **/
/** Params: None. **/
/** Return: None. **/
/** Notice: None. **/
/*************************************************************************/
void LCDFrame::Screenshots(void)
{
/*----------------------------------*/
/* Variable Declaration */
/*----------------------------------*/
uint32_t uiFileCounter;
/*----------------------------------*/
/* Initialize */
/*----------------------------------*/
uiFileCounter = 1;
/*----------------------------------*/
/* Process */
/*----------------------------------*/
// Check image file existed and
while(true == wxFileExists(SCREENSHOTS_FILE_FULLNAME(uiFileCounter)))
{
uiFileCounter++;
}
// Try to save image file.
if(true == m_pclsCtrlPaintPanel->SaveScreenImageToFile(SCREENSHOTS_FILE_FULLNAME(uiFileCounter)))
{
_setStatusText(wxString::Format("Save screen to %s.", SCREENSHOTS_FILE_NAME(uiFileCounter)));
}
else
{
_setStatusText(_T("Save screen failed."));
}
}
/*************************************************************************/
/** Function Name: OnUpdateUI **/
/** Purpose: Update UI event process. **/
/** Params: **/
/** @ clsEventObject[in]: Event data object. **/
/** Return: None. **/
/** Notice: This function process used initialize pixel panel **/
/** display when UI is ready. **/
/*************************************************************************/
void LCDFrame::OnUpdateUI(wxUpdateUIEvent& clsEventObject)
{
/*----------------------------------*/
/* Variable Declaration */
/*----------------------------------*/
static bool bInitialized = false;
/*----------------------------------*/
/* Process */
/*----------------------------------*/
if(false == bInitialized)
{
// Initialize display.
m_pclsCtrlPaintPanel->CleanScreen();
_setStatusText(_T("Initialzied."));
bInitialized = true;
_initializeTimer();
_startTimer(1);
UAIF_OnInitialize();
m_pclsCtrlPaintPanel->RefreshDisplay();
}
}
/*************************************************************************/
/** Function Name: OnPaint **/
/** Purpose: Paint or repaint UI event process. **/
/** Params: **/
/** @ clsEventObject[in]: Event data object. **/
/** Return: None. **/
/** Notice: None. **/
/*************************************************************************/
void LCDFrame::OnPaint(wxPaintEvent &clsEventObject)
{
/*----------------------------------*/
/* Process */
/*----------------------------------*/
m_pclsCtrlPaintPanel->RefreshDisplay();
}
/*************************************************************************/
/** Function Name: OpenScreenshotsFolder **/
/** Purpose: Open screen shots image file folder. **/
/** Params: None. **/
/** Return: None. **/
/** Notice: None. **/
/*************************************************************************/
void LCDFrame::OpenScreenshotsFolder(void)
{
/*----------------------------------*/
/* Process */
/*----------------------------------*/
wxExecute(wxString::Format(_T("explorer %s\\%s"), wxGetCwd(), _T(SCREENSHOTS_FOLDER_T)));
}
/*************************************************************************/
/** Function Name: OnClose **/
/** Purpose: Called when frame close and object destroyed. **/
/** Params: None. **/
/** Return: None. **/
/** Notice: None. **/
/*************************************************************************/
void LCDFrame::OnClose(void)
{
/*----------------------------------*/
/* Process */
/*----------------------------------*/
if(NULL != m_pclsMilliSecondTimer)
{
m_pclsMilliSecondTimer->Stop();
delete m_pclsMilliSecondTimer;
}
if(NULL != m_pclsRTCTimer)
{
m_pclsRTCTimer->Stop();
delete m_pclsRTCTimer;
}
Destroy();
}
/*************************************************************************/
/** Function Name: RefreshLCD **/
/** Purpose: Refresh screen display by pixel color data. **/
/** Params: None. **/
/** Return: None. **/
/** Notice: None. **/
/*************************************************************************/
void LCDFrame::RefreshLCD(void)
{
/*----------------------------------*/
/* Process */
/*----------------------------------*/
m_pclsCtrlPaintPanel->RefreshDisplay();
}
/*************************************************************************/
/** Function Name: ClearLCD **/
/** Purpose: Clear screen display. **/
/** Params: None. **/
/** Return: None. **/
/** Notice: None. **/
/*************************************************************************/
void LCDFrame::ClearLCD(void)
{
/*----------------------------------*/
/* Process */
/*----------------------------------*/
m_pclsCtrlPaintPanel->CleanScreen();
}
/*************************************************************************/
/** Function Name: Initialize **/
/** Purpose: Create a main frame object. **/
/** Params: **/
/** @ pclsParent[in]: Parent object pointer. **/
/** @ iID[in]: Frame object ID. **/
/** @ strTitle[in]: Frame window title. **/
/** Return: None. **/
/** Notice: None. **/
/*************************************************************************/
void LCDFrame::Initialize(wxWindow* pclsParent, wxWindowID iID, const wxString& strTitle)
{
m_pclsInstance = new LCDFrame(pclsParent, iID, strTitle);
}
/*************************************************************************/
/** Function Name: OnThreadEnd **/
/** Purpose: Thread end event process. **/
/** Params: None. **/
/** Return: None. **/
/** Notice: None. **/
/*************************************************************************/
LCDFrame* LCDFrame::GetInstance(void)
{
return m_pclsInstance;
}
/*************************************************************************/
/** Function Name: SetLCDPixel **/
/** Purpose: Set a pixel value. **/
/** Params: **/
/** @ uiPosX[in]: X-Coordinate of pixel. **/
/** @ uiPosY[in]: Y-Coordinate of pixel. **/
/** @ strTitle[in]: Pixel value, 0 for clear, 1 for set. **/
/** Return: None. **/
/** Notice: This function only change the pixel register, To **/
/** update the screen display, need to call RefreshLCD **/
/** function or Or use the DrawPixel function directly. **/
/*************************************************************************/
void LCDFrame::SetLCDPixel(uint32_t uiPosX, uint32_t uiPosY, uint32_t uiPixelValue)
{
if(0 == uiPixelValue)
{
m_pclsCtrlPaintPanel->SetPixel(uiPosX, uiPosY, MonochromeDotLCD::LCD_PIXEL_COLOR_L);
}
else
{
m_pclsCtrlPaintPanel->SetPixel(uiPosX, uiPosY, MonochromeDotLCD::LCD_PIXEL_COLOR_H);
}
}
uint32_t LCDFrame::GetLCDPixel(uint32_t uiPosX, uint32_t uiPosY)
{
uint32_t uiPixelValue;
uiPixelValue = (uint32_t)m_pclsCtrlPaintPanel->GetPixel(uiPosX, uiPosY);
return uiPixelValue;
}
void LCDFrame::OnTimerEvent(wxTimerEvent& event)
{
UAIF_OnTimerEventProcess();
}
void LCDFrame::OnRTCUpdate(wxTimerEvent& event)
{
wxDateTime clsTime = wxDateTime::Now();
UAIF_OnRTCUpdateEventProcess( clsTime.GetYear(),
clsTime.GetMonth(),
clsTime.GetDay(),
clsTime.GetHour(),
clsTime.GetMinute(),
clsTime.GetSecond());
}

View File

@ -1,109 +0,0 @@
/*************************************************************************/
/** Copyright. **/
/** FileName: LCD_OperationIF.c **/
/** Author: XuYulin **/
/** Version: 1.0.0.0 **/
/** Description: Virtual LCD operation interface. **/
/** History: **/
/** XuyYulin 2017/2/27 2.0.0.0 New create. **/
/** XuYulin 2017/2/27 1.0 build this moudle **/
/*************************************************************************/
//=======================================================================//
//= Include files. =//
//=======================================================================//
#include "LCD_OperationIF.h"
#include "VirtualDeviceInterface.h"
#include <memory.h>
#include <stddef.h>
#include <stdint.h>
#include <stdbool.h>
//=======================================================================//
//= Static variable declaration. =//
//=======================================================================//
TPixArray g_LCDPixArray;
//=======================================================================//
//= Static function declaration. =//
//=======================================================================//
static void VTIF_UpdateChangedArea(uint16_t uiPosX, uint16_t uiPosY);
//=======================================================================//
//= Function implementation. =//
//=======================================================================//
void VTIF_KeyBoardEvent(bool bShift, bool bCtrl, bool bAlt, uint16_t uiKeyCode)
{
USR_ACT_OnKeyPress(bShift, bCtrl, bAlt, uiKeyCode);
}
void VTIF_TimerEvent(void)
{
USR_ACT_OnTimerEventProcess();
}
void VTIF_RTCUpdateEvent(uint16_t uiYear, uint16_t uiMonth, uint16_t uiDay, uint16_t uiHour, uint16_t uiMinute, uint16_t uiSecond)
{
USR_ACT_OnRTCUpdateEventProcess(uiYear, uiMonth, uiDay, uiHour, uiMinute, uiSecond);
}
void VTIF_LCDInitializeDisplay(void)
{
USR_ACT_OnInitialize();
}
void VTIF_SetPoint(uint16_t uiPosX, uint16_t uiPosY, uint8_t uiPixValue)
{
if((uiPosX < LCD_SIZE_WIDTH) && (uiPosY < LCD_SIZE_HEIGHT))
{
VTIF_UpdateChangedArea(uiPosX, uiPosY);
g_LCDPixArray.Pixregister[uiPosX][uiPosY] = uiPixValue;
}
}
uint8_t VTIF_GetPoint(uint16_t uiPosX, uint16_t uiPosY)
{
return g_LCDPixArray.Pixregister[uiPosX][uiPosY];
}
void VTIF_ClearScreen(void)
{
memset(&(g_LCDPixArray.Pixregister), 0x00, sizeof(g_LCDPixArray.Pixregister));
g_LCDPixArray.InUpdating = true;
g_LCDPixArray.ChangedArea.StartPosX = 0;
g_LCDPixArray.ChangedArea.EndPosX = LCD_SIZE_WIDTH-1;
g_LCDPixArray.ChangedArea.StartPosY = 0;
g_LCDPixArray.ChangedArea.EndPosY = LCD_SIZE_HEIGHT-1;
}
void VTIF_UpdateChangedArea(uint16_t uiPosX, uint16_t uiPosY)
{
if(false == g_LCDPixArray.InUpdating)
{
g_LCDPixArray.ChangedArea.StartPosX = uiPosX;
g_LCDPixArray.ChangedArea.EndPosX = uiPosX;
g_LCDPixArray.ChangedArea.StartPosY = uiPosY;
g_LCDPixArray.ChangedArea.EndPosY = uiPosY;
g_LCDPixArray.InUpdating = true;
}
else
{
if(g_LCDPixArray.ChangedArea.StartPosX > uiPosX)
{
g_LCDPixArray.ChangedArea.StartPosX = uiPosX;
}
if(g_LCDPixArray.ChangedArea.EndPosX < uiPosX)
{
g_LCDPixArray.ChangedArea.EndPosX = uiPosX;
}
if(g_LCDPixArray.ChangedArea.StartPosY > uiPosY)
{
g_LCDPixArray.ChangedArea.StartPosY = uiPosY;
}
if(g_LCDPixArray.ChangedArea.EndPosY < uiPosY)
{
g_LCDPixArray.ChangedArea.EndPosY = uiPosY;
}
}
}

View File

@ -1,322 +0,0 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Jun 17 2015)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#include "wx\wx.h"
#include "LCD_VirtualDevice.h"
#include <wx/dcbuffer.h>
#include <wx/clipbrd.h>
#include <wx/filefn.h>
///////////////////////////////////////////////////////////////////////////
BEGIN_EVENT_TABLE(LCD_DisplayPanel,wxPanel)
EVT_KEY_DOWN(LCD_DisplayPanel::wxEvent_OnKeyDown)
EVT_SET_FOCUS(LCD_DisplayPanel::wxEvent_OnSetFocus)
END_EVENT_TABLE()
LCD_DisplayPanel::LCD_DisplayPanel( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style ):
wxPanel(parent, id, pos, size, style),
m_CDC(this),
m_PixRegister(&g_LCDPixArray)
{
SetSizeHints(wxDefaultSize, wxDefaultSize);
}
LCD_DisplayPanel::~LCD_DisplayPanel()
{
}
void LCD_DisplayPanel::wxEvent_OnKeyDown(wxKeyEvent& event)
{
event.ResumePropagation(1);
event.Skip();
}
void LCD_DisplayPanel::wxEvent_OnSetFocus(wxFocusEvent& event)
{
event.ResumePropagation(1);
event.Skip();
}
void LCD_DisplayPanel::Paint(void)
{
wxBitmap CDCBufferImage(LCD_SIZE_WIDTH*LCD_PIXSIZE+2*LCD_SIZE_MARGIN, LCD_SIZE_HEIGHT*LCD_PIXSIZE+2*LCD_SIZE_MARGIN, wxBITMAP_SCREEN_DEPTH);
wxBufferedDC CDCBuffer(&m_CDC, CDCBufferImage);
// Clear background
DC_SET_COLOR(FRM_COLOR_OBJ_BKG);
DC_PREPARE(CDCBuffer);
CDCBuffer.DrawRectangle(wxPoint(0, 0), wxSize(LCD_SIZE_WIDTH*LCD_PIXSIZE+2*LCD_SIZE_MARGIN, LCD_SIZE_HEIGHT*LCD_PIXSIZE+2*LCD_SIZE_MARGIN));
// Draw LCD edge.
DC_SET_COLOR(LCD_COLOR_OBJ_EDGE);
DC_PREPARE(CDCBuffer);
CDCBuffer.DrawRectangle( wxPoint(LCD_SIZE_MARGIN-LCD_DISPLAY_EDGE, LCD_SIZE_MARGIN-LCD_DISPLAY_EDGE),
wxSize((LCD_SIZE_WIDTH * LCD_PIXSIZE)+(2*LCD_DISPLAY_EDGE), (LCD_SIZE_HEIGHT * LCD_PIXSIZE)+(2*LCD_DISPLAY_EDGE)));
// Draw LCD display area
DC_SET_COLOR(LCD_COLOR_OBJ_BKG);
DC_PREPARE(CDCBuffer);
CDCBuffer.DrawRectangle(wxPoint(LCD_SIZE_MARGIN, LCD_SIZE_MARGIN), wxSize((LCD_SIZE_WIDTH * LCD_PIXSIZE), (LCD_SIZE_HEIGHT * LCD_PIXSIZE)));
for(size_t i_W=0; i_W<LCD_SIZE_WIDTH; i_W++)
{
for(size_t i_H=0; i_H<LCD_SIZE_HEIGHT; i_H++)
{
if(0 == m_PixRegister->Pixregister[i_W][i_H])
{
DC_SET_COLOR(LCD_COLOR_OBJ_BKG);
}
else
{
DC_SET_COLOR(LCD_COLOR_OBJ_PIX);
}
DC_PREPARE(CDCBuffer);
DC_DRAW_POINT(CDCBuffer, i_W, i_H);
}
}
}
void LCD_DisplayPanel::PartialPaint(void)
{
if(true == m_PixRegister->InUpdating)
{
wxBitmap CDCBufferImage(LCD_SIZE_WIDTH*LCD_PIXSIZE+2*LCD_SIZE_MARGIN, LCD_SIZE_HEIGHT*LCD_PIXSIZE+2*LCD_SIZE_MARGIN, wxBITMAP_SCREEN_DEPTH);
wxBufferedDC CDCBuffer(&m_CDC, CDCBufferImage);
CDCBuffer.Blit( wxPoint(0,0),
wxSize(LCD_SIZE_WIDTH*LCD_PIXSIZE+2*LCD_SIZE_MARGIN, LCD_SIZE_HEIGHT*LCD_PIXSIZE+2*LCD_SIZE_MARGIN),
&m_CDC,
wxPoint(0, 0));
for(uint32_t i_W=m_PixRegister->ChangedArea.StartPosX; i_W<=m_PixRegister->ChangedArea.EndPosX; i_W++)
{
for(uint32_t i_H=m_PixRegister->ChangedArea.StartPosY; i_H<=m_PixRegister->ChangedArea.EndPosY; i_H++)
{
if(0 == m_PixRegister->Pixregister[i_W][i_H])
{
DC_SET_COLOR(LCD_COLOR_OBJ_BKG);
}
else
{
DC_SET_COLOR(LCD_COLOR_OBJ_PIX);
}
DC_PREPARE(CDCBuffer);
DC_DRAW_POINT(CDCBuffer, i_W, i_H);
}
}
m_PixRegister->InUpdating = false;
m_PixRegister->ChangedArea.StartPosX = LCD_SIZE_WIDTH;
m_PixRegister->ChangedArea.StartPosY = LCD_SIZE_HEIGHT;
m_PixRegister->ChangedArea.EndPosX = 0;
m_PixRegister->ChangedArea.EndPosY = 0;
DC_RELEASE(CDCBuffer);
}
}
bool LCD_DisplayPanel::SaveToFile(const wxString& CStrFilePath)
{
// Create and initialize bitmap.
wxBitmap CBitMap(LCD_SIZE_WIDTH*LCD_PIXSIZE+(2*LCD_DISPLAY_EDGE)+2, LCD_SIZE_HEIGHT*LCD_PIXSIZE+(2*LCD_DISPLAY_EDGE)+2, wxBITMAP_SCREEN_DEPTH);
wxMemoryDC CMemoryDC(CBitMap);
CMemoryDC.Blit( wxPoint(0, 0),
wxSize(LCD_SIZE_WIDTH*LCD_PIXSIZE+(2*LCD_DISPLAY_EDGE)+2, LCD_SIZE_HEIGHT*LCD_PIXSIZE+(2*LCD_DISPLAY_EDGE)+2),
&m_CDC,
wxPoint(LCD_SIZE_MARGIN-(LCD_DISPLAY_EDGE+1), LCD_SIZE_MARGIN-(LCD_DISPLAY_EDGE+1)));
return CBitMap.SaveFile(CStrFilePath, wxBITMAP_TYPE_BMP);
}
bool LCD_DisplayPanel::CopyToClipBoard(void)
{
// Create and initialize bitmap.
wxBitmap CBitMap(LCD_SIZE_WIDTH*LCD_PIXSIZE+(2*LCD_DISPLAY_EDGE)+2, LCD_SIZE_HEIGHT*LCD_PIXSIZE+(2*LCD_DISPLAY_EDGE)+2, wxBITMAP_SCREEN_DEPTH);
wxMemoryDC CMemoryDC(CBitMap);
CMemoryDC.Blit( wxPoint(0, 0),
wxSize(LCD_SIZE_WIDTH*LCD_PIXSIZE+(2*LCD_DISPLAY_EDGE)+2, LCD_SIZE_HEIGHT*LCD_PIXSIZE+(2*LCD_DISPLAY_EDGE)+2),
&m_CDC,
wxPoint(LCD_SIZE_MARGIN-(LCD_DISPLAY_EDGE+1), LCD_SIZE_MARGIN-(LCD_DISPLAY_EDGE+1)));
if(wxTheClipboard->Open())
{
wxTheClipboard->SetData(new wxBitmapDataObject(CBitMap));
wxTheClipboard->Close();
return true;
}
else
{
return false;
}
}
///////////////////////////////////////////////////////////////////////////
BEGIN_EVENT_TABLE(LCD_VirtualDevice,wxFrame)
EVT_UPDATE_UI(wxID_MAIN, LCD_VirtualDevice::wxEvent_OnUpdateUI)
EVT_SET_FOCUS(LCD_VirtualDevice::wxEvent_OnSetFocus)
EVT_CLOSE(LCD_VirtualDevice::wxEvent_OnClose)
EVT_SET_FOCUS(LCD_VirtualDevice::wxEvent_OnSetFocus)
EVT_KEY_DOWN(LCD_VirtualDevice::wxEvent_OnKeyDown)
EVT_PAINT(LCD_VirtualDevice::wxEvent_OnPaint)
EVT_TOOL(wxID_TOOLBAR_SCREENSHOTS, LCD_VirtualDevice::wxEvent_OnScreenshots)
EVT_TOOL(wxID_TOOLBAR_COPY, LCD_VirtualDevice::wxEvent_OnToolCopy)
EVT_TOOL(wxID_TOOLBAR_SCREENSHOTS_FOLDER, LCD_VirtualDevice::wxEvent_OnOpenScreenshotsFolder)
EVT_TOOL(wxID_TOOLBAR_EXIT, LCD_VirtualDevice::wxEvent_OnExit)
EVT_TIMER(WXID_TIMER , LCD_VirtualDevice::wxEvent_OnTimerEvent)
EVT_TIMER(WXID_RTCTIMER , LCD_VirtualDevice::wxEvent_OnRTCUpdate)
END_EVENT_TABLE()
LCD_VirtualDevice::LCD_VirtualDevice(wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style) :
wxFrame(parent, id, title, pos, size, style)
{
SetSizeHints( wxDefaultSize, wxDefaultSize );
//Layout();
SetIcon(wxIcon(_T("ID_ICON_MAIN"), wxBITMAP_TYPE_ICO_RESOURCE));
m_CtrlStatusBar = CreateStatusBar(1, wxST_SIZEGRIP, wxID_STATUSBAR);
m_CtrlToolBar = CreateToolBar(wxTB_HORIZONTAL, wxID_TOOLBAR);
m_CtrlToolButton_Screenshots = m_CtrlToolBar->AddTool( wxID_TOOLBAR_SCREENSHOTS, _T("Screenshots"),
wxBitmap(_T("ID_TOOL_SCREENSHOTS")),
wxBitmap(_T("ID_TOOL_SCREENSHOTS")),
wxITEM_NORMAL,
_T("Screenshots"),
_T("Save LCD screenshots to file."));
m_CtrlToolButton_ScreenCpoy = m_CtrlToolBar->AddTool( wxID_TOOLBAR_COPY, _T("Copy LCD screen"),
wxBitmap(_T("ID_TOOL_COPY")),
wxBitmap(_T("ID_TOOL_COPY")),
wxITEM_NORMAL,
_T("Copy"),
_T("Copy current LCD Screen image to clipboard."));
m_CtrlToolButton_OpenFolder = m_CtrlToolBar->AddTool( wxID_TOOLBAR_SCREENSHOTS_FOLDER, _T("Open folder"),
wxBitmap(_T("ID_TOOL_OPENFOLDER")),
wxBitmap(_T("ID_TOOL_OPENFOLDER")),
wxITEM_NORMAL,
_T("Open screenshots folder"),
_T("Open screenshots image saved folder."));
m_CtrlToolBar->AddSeparator();
m_CtrlToolButton_Exit = m_CtrlToolBar->AddTool( wxID_TOOLBAR_EXIT, _T("Exit"),
wxBitmap(_T("ID_TOOL_EXIT")),
wxBitmap(_T("ID_TOOL_EXIT")),
wxITEM_NORMAL,
_T("Exit"),
_T("Exit."));
m_CtrlToolBar->Realize();
SetClientSize(LCD_SIZE_WIDTH*LCD_PIXSIZE+2*LCD_SIZE_MARGIN, LCD_SIZE_HEIGHT*LCD_PIXSIZE+2*LCD_SIZE_MARGIN);
m_CtrlPaintPanel = new LCD_DisplayPanel(this, wxID_PANEL, wxPoint(0, 0), wxSize(LCD_SIZE_WIDTH*LCD_PIXSIZE+2*LCD_SIZE_MARGIN, LCD_SIZE_HEIGHT*LCD_PIXSIZE+2*LCD_SIZE_MARGIN));
m_CtrlPaintPanel->SetBackgroundColour(FRM_COLOR_OBJ_BKG);
Centre( wxBOTH );
if(false == wxDirExists(SCREENSHOTS_FOLDER))
{
wxMkdir(SCREENSHOTS_FOLDER);
}
UpdateWindow(GetHandle());
// Register timer.
m_pclsTimer = new wxTimer(this, WXID_TIMER);
m_pclsRTCTimer = new wxTimer(this, WXID_RTCTIMER);
}
LCD_VirtualDevice::~LCD_VirtualDevice()
{
delete m_CtrlStatusBar;
delete m_CtrlToolBar;
if(NULL != m_pclsTimer)
{
m_pclsTimer->Stop();
delete m_pclsTimer;
}
if(NULL != m_pclsRTCTimer)
{
m_pclsRTCTimer->Stop();
delete m_pclsRTCTimer;
}
}
void LCD_VirtualDevice::SetStatusText(const wxString& cString)
{
m_CtrlStatusBar->SetStatusText(cString, 0);
}
void LCD_VirtualDevice::OnKeyDown(wxKeyEvent& event)
{
uint16_t uiKeyCode;
uiKeyCode = (uint16_t)event.GetKeyCode();
VTIF_KeyBoardEvent(event.ShiftDown(), event.ControlDown(), event.AltDown(), uiKeyCode);
m_CtrlPaintPanel->PartialPaint();
}
void LCD_VirtualDevice::Copy(void)
{
bool bResult = m_CtrlPaintPanel->CopyToClipBoard();
if(true == bResult)
{
SetStatusText(_T("Copied to clipboard."));
}
else
{
SetStatusText(_T("Copy failed."));
}
}
void LCD_VirtualDevice::Screenshots(void)
{
uint32_t uiFileCounter = 1;
while(true == wxFileExists(SCREENSHOTS_FILE_FULLNAME(uiFileCounter)))
{
uiFileCounter++;
}
if(true == m_CtrlPaintPanel->SaveToFile(SCREENSHOTS_FILE_FULLNAME(uiFileCounter)))
{
SetStatusText(wxString::Format("Save screen to %s.", SCREENSHOTS_FILE_NAME(uiFileCounter)));
}
else
{
SetStatusText(_T("Save screen failed."));
}
}
void LCD_VirtualDevice::OnUpdateUI(wxUpdateUIEvent& event)
{
static bool bInitialized = false;
if(false == bInitialized)
{
VTIF_LCDInitializeDisplay();
bInitialized = true;
m_CtrlPaintPanel->Paint();
SetStatusText(_T("Initialzied."));
// Start timer
m_pclsTimer->Start(1);
m_pclsRTCTimer->Start(1000);
}
}
void LCD_VirtualDevice::OnPaint(wxPaintEvent &event)
{
m_CtrlPaintPanel->Paint();
}
void LCD_VirtualDevice::OpenScreenshotsFolder(void)
{
wxExecute(wxString::Format(_T("explorer %s\\%s"), wxGetCwd(), _T(SCREENSHOTS_FOLDER_T)));
}
void LCD_VirtualDevice::OnTimer(wxTimerEvent& event)
{
VTIF_TimerEvent();
m_CtrlPaintPanel->PartialPaint();
}
void LCD_VirtualDevice::OnRTCUpdate(wxTimerEvent& event)
{
wxDateTime clsTime = wxDateTime::Now();
VTIF_RTCUpdateEvent( clsTime.GetYear(),
clsTime.GetMonth(),
clsTime.GetDay(),
clsTime.GetHour(),
clsTime.GetMinute(),
clsTime.GetSecond());
//m_CtrlPaintPanel->PartialPaint();
}

View File

@ -0,0 +1,127 @@
/*************************************************************************/
/** Copyright. **/
/** FileName: LCDScreenPanel.cpp **/
/** Author: Polarix **/
/** Version: 1.7.0.0 **/
/** Description: Main frame class define. **/
/*************************************************************************/
//=======================================================================//
//= Include files. =//
//=======================================================================//
#include "MonochromeDotLCD.h"
//=======================================================================//
//= Event table. =//
//=======================================================================//
BEGIN_EVENT_TABLE(MonochromeDotLCD,wxDotLCD)
EVT_SET_FOCUS (MonochromeDotLCD::wxEvent_OnSetFocus)
END_EVENT_TABLE()
//=======================================================================//
//= Function define. =//
//=======================================================================//
MonochromeDotLCD::MonochromeDotLCD(wxWindow *parent, wxWindowID winid, const wxPoint& pos, const wxSize& size, long style, const wxString& name):
wxDotLCD(parent, winid, pos, size, style, name)
{
m_pclsPanelColor = new wxColor(0x00, 0x00, 0x00, 0x00);
m_pclsPixelColor = new wxColor(0x00, 0x00, 0x00, 0x00);
}
MonochromeDotLCD::~MonochromeDotLCD(void)
{
delete m_pclsPanelColor;
delete m_pclsPixelColor;
}
void MonochromeDotLCD::SetParameter(PixelPanelParameter* pstPanelParameter)
{
if(NULL != pstPanelParameter)
{
wxDotLCD::SetDisplaySizes( pstPanelParameter->EdgeWidth,
pstPanelParameter->HorizontalPixelNumber,
pstPanelParameter->VerticalPixelNumber,
pstPanelParameter->PixelSize,
pstPanelParameter->EnableGrid);
m_uiColumnCount = pstPanelParameter->HorizontalPixelNumber;
m_uiPageCount = pstPanelParameter->VerticalPixelNumber/8;
m_pclsPanelColor->SetRGBA(pstPanelParameter->PanelColor.RGBA);
m_pclsPixelColor->SetRGBA(pstPanelParameter->PixelColor.RGBA);
wxDotLCD::SetDisplayColors( wxColor(pstPanelParameter->EdgeColor.RGBA),
wxColor(pstPanelParameter->PanelColor.RGBA),
wxColor(pstPanelParameter->GridColor.RGBA));
}
CleanScreen();
}
void MonochromeDotLCD::SetPixel(uint32_t uiPosX, uint32_t uiPosY, LCD_PIXEL_COLOR_T ePixelValue)
{
if(LCD_PIXEL_COLOR_L == ePixelValue)
{
wxDotLCD::SetPixelColor(uiPosX, uiPosY, *m_pclsPanelColor);
}
else
{
wxDotLCD::SetPixelColor(uiPosX, uiPosY, *m_pclsPixelColor);
}
}
MonochromeDotLCD::LCD_PIXEL_COLOR_T MonochromeDotLCD::GetPixel(uint32_t uiPosX, uint32_t uiPosY)
{
/*----------------------------------*/
/* Variable Declaration */
/*----------------------------------*/
MonochromeDotLCD::LCD_PIXEL_COLOR_T eReturn;
uint32_t uiPixelColor;
/*----------------------------------*/
/* Initialize */
/*----------------------------------*/
uiPixelColor = GetPixelColor(uiPosX, uiPosY);
/*----------------------------------*/
/* Process */
/*----------------------------------*/
if(uiPixelColor == m_pclsPixelColor->GetRGBA())
{
eReturn = MonochromeDotLCD::LCD_PIXEL_COLOR_H;
}
else
{
eReturn = MonochromeDotLCD::LCD_PIXEL_COLOR_L;
}
return eReturn;
}
void MonochromeDotLCD::DrawPixel(uint32_t uiPosX, uint32_t uiPosY, LCD_PIXEL_COLOR_T ePixelValue)
{
if(LCD_PIXEL_COLOR_L == ePixelValue)
{
wxDotLCD::DrawPixel(uiPosX, uiPosY, *m_pclsPanelColor);
}
else
{
wxDotLCD::DrawPixel(uiPosX, uiPosY, *m_pclsPixelColor);
}
}
void MonochromeDotLCD::OnSetFocus(wxFocusEvent& event)
{
event.ResumePropagation(1);
event.Skip();
}
void MonochromeDotLCD::CleanScreen(void)
{
uint32_t uiHorizontalPixelNumber, uiVerticalPixelNumber;
GetDisplaySize(NULL, &uiHorizontalPixelNumber, &uiVerticalPixelNumber, NULL, NULL);
for(uint32_t i_V=0; i_V<uiVerticalPixelNumber; i_V++)
{
for(uint32_t i_H=0; i_H<uiHorizontalPixelNumber; i_H++)
{
SetPixelColor(i_H, i_V, *m_pclsPanelColor);
}
}
}

View File

@ -1,129 +0,0 @@
#include "PixelPanel.h"
BEGIN_EVENT_TABLE(LCD_ScreenPanel,wxPixelPanel)
EVT_MOUSE_EVENTS (LCD_ScreenPanel::wxEvent_OnMouseClick)
END_EVENT_TABLE()
LCD_ScreenPanel::LCD_ScreenPanel(wxWindow *parent, wxWindowID winid, const wxPoint& pos, const wxSize& size, long style, const wxString& name):
wxPixelPanel(parent, winid, pos, size, style, name)
{
m_pclsPanelColor = new wxColor(0x00, 0x00, 0x00, 0x00);
m_pclsPixelColor = new wxColor(0x00, 0x00, 0x00, 0x00);
}
LCD_ScreenPanel::~LCD_ScreenPanel(void)
{
delete m_pclsPanelColor;
delete m_pclsPixelColor;
}
void LCD_ScreenPanel::CleanPanel(void)
{
uint32_t uiHorizontalPixelNumber, uiVerticalPixelNumber;
GetDisplaySize(NULL, &uiHorizontalPixelNumber, &uiVerticalPixelNumber, NULL, NULL);
for(uint32_t i_V=0; i_V<uiVerticalPixelNumber; i_V++)
{
for(uint32_t i_H=0; i_H<uiHorizontalPixelNumber; i_H++)
{
SetPixel(i_H, i_V, *m_pclsPanelColor);
}
}
}
void LCD_ScreenPanel::SetParameter(PixelPanelParameter* pstPanelParameter)
{
if(NULL != pstPanelParameter)
{
wxPixelPanel::SetDisplaySizes( pstPanelParameter->EdgeWidth,
pstPanelParameter->HorizontalPixelNumber,
pstPanelParameter->VerticalPixelNumber,
pstPanelParameter->PixelSize,
pstPanelParameter->EnableGrid);
m_uiColumnCount = pstPanelParameter->HorizontalPixelNumber;
m_uiPageCount = pstPanelParameter->VerticalPixelNumber/8;
m_pclsPanelColor->SetRGBA(pstPanelParameter->PanelColor.RGBA);
m_pclsPixelColor->SetRGBA(pstPanelParameter->PixelColor.RGBA);
wxPixelPanel::SetDisplayColors( wxColor(pstPanelParameter->EdgeColor.RGBA),
wxColor(pstPanelParameter->PanelColor.RGBA),
wxColor(pstPanelParameter->GridColor.RGBA));
}
CleanPanel();
}
void LCD_ScreenPanel::SetPosition(uint32_t uiColumn, uint32_t uiPage)
{
SetColumn(uiColumn);
SetPage(uiPage);
}
void LCD_ScreenPanel::SetData(uint8_t uiData)
{
for(uint32_t i=0; i<8; i++)
{
wxPixelPanel::SetPixel(m_uiPosColumn, m_uiPosPage*8+i, (0<(uiData & 0x01)?(*m_pclsPixelColor):(*m_pclsPanelColor)));
uiData = uiData >> 1;
}
m_uiPosColumn++;
m_uiPosColumn = m_uiPosColumn%m_uiColumnCount;
}
uint8_t LCD_ScreenPanel::GetData(void)
{
uint8_t uiReadByte = 0x00;
for(uint32_t i=0; i<8; i++)
{
uiReadByte = uiReadByte >> 1;
if(m_pclsPixelColor->GetRGBA() == wxPixelPanel::GetPixel(m_uiPosColumn, m_uiPosPage*8+i))
{
uiReadByte = uiReadByte | 0x80;
}
}
m_uiPosColumn++;
m_uiPosColumn = m_uiPosColumn%m_uiColumnCount;
return uiReadByte;
}
void LCD_ScreenPanel::SetColumn(uint32_t uiColumn)
{
m_uiPosColumn = uiColumn;
m_uiPosColumn = m_uiPosColumn%m_uiColumnCount;
}
void LCD_ScreenPanel::SetPage(uint32_t uiPage)
{
m_uiPosPage = uiPage;
m_uiPosPage = m_uiPosPage%m_uiPageCount;
}
void LCD_ScreenPanel::OnMouseClick(wxMouseEvent& event)
{
uint32_t uiEdgeWidth, uiHorizontalPixelNumber, uiVerticalPixelNumber, uiPixelSize;
bool bGridVisible;
long uiPixelPosX, uiPixelPosY;
wxPoint clsMousePositoin = event.GetPosition();
if(true == event.LeftDown())
{
GetDisplaySize(&uiEdgeWidth, &uiHorizontalPixelNumber, &uiVerticalPixelNumber, &uiPixelSize,&bGridVisible);
uiPixelPosX = (clsMousePositoin.x - uiEdgeWidth)/GetPixelSize();
uiPixelPosY = (clsMousePositoin.y - uiEdgeWidth)/GetPixelSize();
if( (uiPixelPosX >= 0) && (uiPixelPosY >= 0) &&
(uiPixelPosX < (long)uiHorizontalPixelNumber) && (uiPixelPosY < (long)uiVerticalPixelNumber))
{
if(m_pclsPanelColor->GetRGBA() == GetPixel(uiPixelPosX, uiPixelPosY))
{
DrawPixel(uiPixelPosX, uiPixelPosY, *m_pclsPixelColor);
}
else
{
DrawPixel(uiPixelPosX, uiPixelPosY, *m_pclsPanelColor);
}
}
}
}

View File

@ -3,10 +3,13 @@
//=======================================================================//
//= Include files. =//
//=======================================================================//
#include <stdbool.h>
#include "SGUI_Config.h"
#include "SGUI_Typedef.h"
#if (_SIMPLE_GUI_VIRTUAL_ENVIRONMENT_SIMULATOR_ > 0)
#include "LCD_OperationIF.h"
//#include "LCD_OperationIF.h"
#include "VirtualDeviceInterface.h"
#else
// Insert platform driver head file here.
#endif //_SIMPLE_GUI_ENABLE_SIMULATOR_

View File

@ -10,6 +10,11 @@
//= Include files. =//
//=======================================================================//
#include "SGUI_Basic.h"
#if (_SIMPLE_GUI_VIRTUAL_ENVIRONMENT_SIMULATOR_ > 0)
#include "VirtualDeviceInterface.h"
#else
// Include your device driver interface here.
#endif //_SIMPLE_GUI_ENABLE_SIMULATOR_
//=======================================================================//
//= Static variable declaration. =//
@ -140,7 +145,7 @@ SGUI_CBYTE SGUI_BASIC_FONT_H8[] = {
};
//=======================================================================//
//= Function implementation. =//
//= Function define. =//
//=======================================================================//
/*************************************************************************/
/** Function Name: SGUI_Basic_DrawPoint **/
@ -163,7 +168,7 @@ void SGUI_Basic_DrawPoint(SGUI_UINT uiCoordinateX, SGUI_UINT uiCoordinateY, SGUI
if(SGUI_COLOR_FRGCLR == eColor)
{
#if (_SIMPLE_GUI_VIRTUAL_ENVIRONMENT_SIMULATOR_ > 0)
VTIF_SetPoint(uiCoordinateX, uiCoordinateY, 1);
VDIF_SetPixel(uiCoordinateX, uiCoordinateY, 1);
#else
// Call draw pix interface here.
#endif //_SIMPLE_GUI_ENABLE_SIMULATOR_
@ -171,7 +176,7 @@ void SGUI_Basic_DrawPoint(SGUI_UINT uiCoordinateX, SGUI_UINT uiCoordinateY, SGUI
else if(SGUI_COLOR_BKGCLR == eColor)
{
#if (_SIMPLE_GUI_VIRTUAL_ENVIRONMENT_SIMULATOR_ > 0)
VTIF_SetPoint(uiCoordinateX, uiCoordinateY, 0);
VDIF_SetPixel(uiCoordinateX, uiCoordinateY, 0);
#else
// Call draw pix interface here.
#endif //_SIMPLE_GUI_ENABLE_SIMULATOR_
@ -208,7 +213,7 @@ SGUI_COLOR SGUI_Basic_GetPoint(SGUI_UINT uiCoordinateX, SGUI_UINT uiCoordinateY)
if((uiCoordinateX < LCD_SIZE_WIDTH) && (uiCoordinateY < LCD_SIZE_HEIGHT))
{
#if (_SIMPLE_GUI_VIRTUAL_ENVIRONMENT_SIMULATOR_ > 0)
uiPixValue = VTIF_GetPoint(uiCoordinateX, uiCoordinateY);
uiPixValue = VDIF_GetPixel(uiCoordinateX, uiCoordinateY);
#else
// Call read pix interface here.
#endif //_SIMPLE_GUI_ENABLE_SIMULATOR_
@ -238,7 +243,7 @@ void SGUI_Basic_ClearScreen(void)
/* Process */
/*----------------------------------*/
#if (_SIMPLE_GUI_VIRTUAL_ENVIRONMENT_SIMULATOR_ > 0)
VTIF_ClearScreen();
VDIF_ClearDisplay();
#else
// Call clear screen function here;
#endif //_SIMPLE_GUI_ENABLE_SIMULATOR_

View File

@ -42,7 +42,7 @@ static SGUI_CHAR g_arrcEncodeBuffer[_SIMPLE_GUI_ENCODE_BUFFER_SIZE];
#endif
//=======================================================================//
//= Function implementation. =//
//= Function define. =//
//=======================================================================//
/*************************************************************************/
/** Function Name: SGUI_Common_IntegerToStringWithDecimalPoint **/

View File

@ -12,7 +12,7 @@
#include "SGUI_Frame.h"
//=======================================================================//
//= Function implementation. =//
//= Function define. =//
//=======================================================================//
/*************************************************************************/
/** Function Name: SGUI_Frame_DrawFullScreenFrame **/

View File

@ -46,7 +46,7 @@ static inline void SGUI_LIST_RefreshListItems(SGUI_LIST_STRUCT* pstList);
static inline void SGUI_LIST_DrawItem(SGUI_LIST_STRUCT* pstList, SGUI_SIZE uiIndex);
//=======================================================================//
//= Function implementation. =//
//= Function define. =//
//=======================================================================//
/*************************************************************************/
/** Function Name: SGUI_LIST_InitializeListData **/

View File

@ -99,7 +99,7 @@ const uint8_t* g_arrNoticeIcon[] = {
};
//=======================================================================//
//= Function implementation. =//
//= Function define. =//
//=======================================================================//
/*************************************************************************/
/** Function Name: SGUI_Notice_RefreshNotice **/

View File

@ -13,7 +13,7 @@
#include "SGUI_ProcessBar.h"
//=======================================================================//
//= Function implementation. =//
//= Function define. =//
//=======================================================================//
/*************************************************************************/
/** Function Name: SGUI_RefreshProcessBar **/

View File

@ -26,7 +26,7 @@
static SGUI_INT SGUI_RealtimeGraph_GetValuePointYCoordinate(SGUI_RTGRAPH* pstRTGraph, SGUI_INT iValue);
//=======================================================================//
//= Function implementation. =//
//= Function define. =//
//=======================================================================//
/*************************************************************************/
/** Function Name: SGUI_RealtimeGraph_Initialize **/

View File

@ -13,7 +13,7 @@
#include "SGUI_ScrollBar.h"
//=======================================================================//
//= Function implementation. =//
//= Function define. =//
//=======================================================================//
/*************************************************************************/
/** Function Name: SGUI_ScrollBar_RefreshScrollBar **/

View File

@ -35,7 +35,7 @@ static void SGUI_Text_ReadFontData(SGUI_FONT_SIZE eFontSize, SGU
static SGUI_SIZE SGUI_Text_GetCharacterTableIndex(SGUI_UINT16 uiCharacterCode);
//=======================================================================//
//= Function implementation. =//
//= Function define. =//
//=======================================================================//
/*************************************************************************/

View File

@ -25,7 +25,7 @@ static char arrTextBuffer[VARBOX_TEXT_BUFFER_SIZE] = {0x00}; //Used when conv
void SGUI_TextVariableBox_UpdateCharacter(SGUI_TEXT_VARBOX_STRUCT* pstTextValue, char cNewCharacters, SGUI_DRAW_MODE eMode);
//=======================================================================//
//= Function implementation. =//
//= Function define. =//
//=======================================================================//
/*************************************************************************/
/** Function Name: GUI_RefreshVariableBox **/

View File

@ -1,5 +1,5 @@
#ifndef HMI_PROCESS_H_INCLUDED
#define HMI_PROCESS_H_INCLUDED
#ifndef __INCLUDE_HMI_ENGINE_H__
#define __INCLUDE_HMI_ENGINE_H__
//=======================================================================//
//= Include files. =//
//=======================================================================//
@ -128,4 +128,4 @@ HMI_ENGINE_RESULT HMI_ProcessEvent(HMI_EVENT_TYPE eEventType, const HMI_EVENT*
HMI_ENGINE_RESULT HMI_PostProcess(SGUI_INT iActionResult);
HMI_ENGINE_RESULT HMI_Goto(SGUI_INT iDestScreenID, const void* pstParameters);
HMI_ENGINE_RESULT HMI_GoBack(const void* pstParameters);
#endif // HMI_PROCESS_H_INCLUDED
#endif // __INCLUDE_HMI_ENGINE_H__

View File

@ -23,7 +23,7 @@ static HMI_ENGINE_OBJECT* g_pstActivedEngineObject;
static inline HMI_SCREEN_OBJECT* HMI_GetScreenObjectInEngine(HMI_ENGINE_OBJECT* pstHMIEngineObject, SGUI_INT iScreenID);
//=======================================================================//
//= Function implementation. =//
//= Function define. =//
//=======================================================================//
/*****************************************************************************/
/** Function Name: HMI_PrepareEngine. **/

View File

@ -0,0 +1,24 @@
#ifndef __INCLUDE_USER_ACTION_INTERFACE__
#define __INCLUDE_USER_ACTION_INTERFACE__
//=======================================================================//
//= Include files. =//
//=======================================================================//
#include <stdint.h>
#include <stdbool.h>
//=======================================================================//
//= Public function declaration. =//
//=======================================================================//
#ifdef __cplusplus
extern "C"
{
#endif /* __cplusplus */
void UAIF_OnInitialize(void);
void UAIF_OnKeyPress(bool bShift, bool bCtrl, bool bAlt, uint16_t uiKeyCode);
void UAIF_OnTimerEventProcess(void);
void UAIF_OnRTCUpdateEventProcess(uint16_t uiYear, uint16_t uiMonth, uint16_t uiDay, uint16_t uiHour, uint16_t uiMinute, uint16_t uiSecond);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif // __INCLUDE_USER_ACTION_INTERFACE__

View File

@ -1,9 +1,9 @@
#ifndef __INCLUDE_VIRTUAL_DEVICE_INTERFACE_H__
#define __INCLUDE_VIRTUAL_DEVICE_INTERFACE_H__
#include <stddef.h>
//=======================================================================//
//= Include files. =//
//=======================================================================//
#include <stdint.h>
#include <stdbool.h>
#include <stdlib.h>
//=======================================================================//
//= User definition. =//
@ -38,12 +38,38 @@
#define KEY_PRESS_EVENT_VALUE_MAX (4)
// Parameter
#define LCD_SIZE_WIDTH (128)
#define LCD_SIZE_HEIGHT (64)
#if LCD_SIZE_WIDTH < 16
#error Define width of LCD size must greater then 16.
#endif
#if LCD_SIZE_HEIGHT < 16
#error Define height of LCD size must greater then 16.
#endif
//Common operation
//#define SET_BIT(PAGE, Bit) ((PAGE) = (PAGE) | (0x01 << (Bit)))
//#define CLR_BIT(PAGE, Bit) ((PAGE) = (PAGE) & (~(0x01 << (Bit))))
#define GET_BIT(PAGE, Bit) ((((PAGE) & (0x01 << (Bit)))>0)?1:0)
//=======================================================================//
//= Public function declaration. =//
//=======================================================================//
void USR_ACT_OnInitialize(void);
void USR_ACT_OnKeyPress(bool bShift, bool bCtrl, bool bAlt, uint16_t uiKeyCode);
void USR_ACT_OnTimerEventProcess(void);
void USR_ACT_OnRTCUpdateEventProcess(uint16_t uiYear, uint16_t uiMonth, uint16_t uiDay, uint16_t uiHour, uint16_t uiMinute, uint16_t uiSecond);
#ifdef __cplusplus
extern "C"
{
#endif /* __cplusplus */
void VDIF_SetPixel(uint32_t uiPosX, uint32_t uiPosY, uint32_t uiPixelValue);
uint32_t VDIF_GetPixel(uint32_t uiPosX, uint32_t uiPosY);
void VDIF_RefreshDisplay(void);
void VDIF_ClearDisplay(void);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif // __INCLUDE_VIRTUAL_DEVICE_INTERFACE_H__

View File

@ -1,54 +1,41 @@
/*************************************************************************/
/** Copyright. **/
/** FileName: UserAction.c **/
/** Author: XuYulin **/
/** FileName: VirtualDeviceInterface.c **/
/** Author: Polarix **/
/** Version: 1.0.0.0 **/
/** Description: User operation interface. **/
/** History: **/
/** XuyYulin 2017/2/27 2.0.0.0 New create. **/
/** XuYulin 2017/2/27 1.0 build this moudle **/
/** Description: Virtual device operation interface. **/
/*************************************************************************/
//=======================================================================//
//= Include files. =//
//=======================================================================//
#include "UserActionInterface.h"
#include "VirtualDeviceInterface.h"
#include "LCD_OperationIF.h"
#include "DemoProc.h"
#include "HMI_Engine.h"
#include "SGUI_Common.h"
#include <stdlib.h>
//=======================================================================//
//= Function implementation. =//
//= Function define. =//
//=======================================================================//
/*************************************************************************/
/** Function Name: USR_ACT_OnInitialize **/
/** Purpose: Process with application startup. **/
/** Resources: None. **/
/** Params: None. **/
/** Return: None. **/
/** Notice: None. **/
/*************************************************************************/
void USR_ACT_OnInitialize(void)
void UAIF_OnInitialize(void)
{
/*----------------------------------*/
/* Process */
/*----------------------------------*/
SimpleGUI_DemoProcess();
SimpleGUI_DemoProcessInitialize();
}
/*************************************************************************/
/** Function Name: USR_ACT_OnKeyPress **/
/** Purpose: Recive and process keyboard event. **/
/** Purpose: Recive and process key press event. **/
/** Resources: None. **/
/** Params: **/
/** @uiKeyCode: Key code. **/
/** @ bShift: Shift key is pressed. **/
/** @ bCtrl: Ctrl key is pressed. **/
/** @ bAlt: Alt key is pressed. **/
/** @ uiKeyCode: Key code. **/
/** Return: None. **/
/** Notice: None. **/
/*************************************************************************/
void USR_ACT_OnKeyPress(bool bShift, bool bCtrl, bool bAlt, uint16_t uiKeyCode)
void UAIF_OnKeyPress(bool bShift, bool bCtrl, bool bAlt, uint16_t uiKeyCode)
{
/*----------------------------------*/
/*----------------------------------*/
/* Variable Declaration */
/*----------------------------------*/
SGUI_UINT16 arruiPressedKey[HMI_EVENT_KEY_VALUE_LENGTH_MAX];
@ -72,25 +59,18 @@ void USR_ACT_OnKeyPress(bool bShift, bool bCtrl, bool bAlt, uint16_t uiKeyCode)
arruiPressedKey[0] |= KEY_OPTION_ALT;
}
arruiPressedKey[1] = uiKeyCode;
stEvent.Data = (void*)arruiPressedKey;
stEvent.Data = (SGUI_BYTE*)arruiPressedKey;
/*----------------------------------*/
/* Process */
/*----------------------------------*/
// Call demo process.
EventProcess(HMI_ENGINE_EVENT_ACTION, (void*)(&stEvent));
EventProcess(HMI_ENGINE_EVENT_ACTION, &stEvent);
VDIF_RefreshDisplay();
}
/*************************************************************************/
/** Function Name: USR_ACT_OnTimerEventProcess **/
/** Purpose: Timer event process. **/
/** Resources: None. **/
/** Params: None. **/
/** Return: None. **/
/** Notice: None. **/
/*************************************************************************/
void USR_ACT_OnTimerEventProcess(void)
void UAIF_OnTimerEventProcess(void)
{
/*----------------------------------*/
/*----------------------------------*/
/* Variable Declaration */
/*----------------------------------*/
HMI_EVENT stEvent;
@ -108,28 +88,15 @@ void USR_ACT_OnTimerEventProcess(void)
iRandomNumber = rand();
iRandomNumber = (iRandomNumber % 200)-100;
stEvent.Data = (void*)(&iRandomNumber);
stEvent.Data = (SGUI_BYTE*)(&iRandomNumber);
// Post timer event.
HMI_ProcessEvent(HMI_ENGINE_EVENT_ACTION, &stEvent);
EventProcess(HMI_ENGINE_EVENT_ACTION, &stEvent);
VDIF_RefreshDisplay();
}
/*************************************************************************/
/** Function Name: USR_ACT_OnRTCUpdateEventProcess **/
/** Purpose: RTC timer event process. **/
/** Resources: None. **/
/** Params: None. **/
/**@uiYear :Year. **/
/**@uiMonth :Month. **/
/**@uiDay :Day. **/
/**@uiHour :Hour. **/
/**@uiMinute :Minute. **/
/**@uiSecond :Second. **/
/** Return: None. **/
/** Notice: None. **/
/*************************************************************************/
void USR_ACT_OnRTCUpdateEventProcess(uint16_t uiYear, uint16_t uiMonth, uint16_t uiDay, uint16_t uiHour, uint16_t uiMinute, uint16_t uiSecond)
void UAIF_OnRTCUpdateEventProcess(uint16_t uiYear, uint16_t uiMonth, uint16_t uiDay, uint16_t uiHour, uint16_t uiMinute, uint16_t uiSecond)
{
/*----------------------------------*/
/*----------------------------------*/
/* Variable Declaration */
/*----------------------------------*/
SGUI_TIME stRTCTime;
@ -145,11 +112,12 @@ void USR_ACT_OnRTCUpdateEventProcess(uint16_t uiYear, uint16_t uiMonth, uint16_t
stRTCTime.Minute = uiMinute;
stRTCTime.Second = uiSecond;
stEvent.Action = HMI_ENGINE_ACTION_ON_TIMER_RTC;
stEvent.Data = (void*)(&stRTCTime);
stEvent.Data = (SGUI_BYTE*)(&stRTCTime);
/*----------------------------------*/
/* Process */
/*----------------------------------*/
// Post RTC update message to a screen.
HMI_ProcessEvent(HMI_ENGINE_EVENT_DATA, &stEvent);
EventProcess(HMI_ENGINE_EVENT_DATA, &stEvent);
VDIF_RefreshDisplay();
}

View File

@ -0,0 +1,141 @@
/*************************************************************************/
/** Copyright. **/
/** FileName: VirtualDeviceInterface.c **/
/** Author: Polarix **/
/** Version: 1.0.0.0 **/
/** Description: Virtual device operation interface. **/
/*************************************************************************/
//=======================================================================//
//= Include files. =//
//=======================================================================//
#include "VirtualDeviceInterface.h"
#include "LCDFrame.h"
//=======================================================================//
//= Function define. =//
//=======================================================================//
/*************************************************************************/
/** Function Name: VDIF_SetPixel **/
/** Purpose: Set virtual device pixel register data. **/
/** Params: **/
/** @ uiPosX[in]: Pixel x-coordinate on display panel. **/
/** @ uiPosY[in]: Pixel y-coordinate on display panel. **/
/** @ uiPixelValue[out]: Pixel value, 0 for clear, 1 for set. **/
/** Return: None. **/
/** Notice: None. **/
/*************************************************************************/
void VDIF_SetPixel(uint32_t uiPosX, uint32_t uiPosY, uint32_t uiPixelValue)
{
/*----------------------------------*/
/* Variable Declaration */
/*----------------------------------*/
LCDFrame* pclsMainFrameObjectPtr;
/*----------------------------------*/
/* Initialize */
/*----------------------------------*/
pclsMainFrameObjectPtr = LCDFrame::GetInstance();
/*----------------------------------*/
/* Process */
/*----------------------------------*/
if(NULL != pclsMainFrameObjectPtr)
{
pclsMainFrameObjectPtr->SetLCDPixel(uiPosX, uiPosY, uiPixelValue);
}
}
/*************************************************************************/
/** Function Name: VDIF_GetPixel **/
/** Purpose: Get a pixel value form virtual device register. **/
/** Params: **/
/** @ uiPosX[in]: Pixel x-coordinate on display panel. **/
/** @ uiPosY[in]: Pixel y-coordinate on display panel. **/
/** Return: Pixel state, 0 for cleared, 1 for set. **/
/** Notice: None. **/
/*************************************************************************/
uint32_t VDIF_GetPixel(uint32_t uiPosX, uint32_t uiPosY)
{
/*----------------------------------*/
/* Variable Declaration */
/*----------------------------------*/
LCDFrame* pclsMainFrameObjectPtr;
uint32_t uiPixelValue;
/*----------------------------------*/
/* Initialize */
/*----------------------------------*/
pclsMainFrameObjectPtr = LCDFrame::GetInstance();
/*----------------------------------*/
/* Process */
/*----------------------------------*/
if(NULL != pclsMainFrameObjectPtr)
{
uiPixelValue = pclsMainFrameObjectPtr->GetLCDPixel(uiPosX, uiPosY);
}
else
{
uiPixelValue = 0;
}
return uiPixelValue;
}
/*************************************************************************/
/** Function Name: VDIF_RefreshDisplay. **/
/** Purpose: Refresh virtual device display. **/
/** Params: None. **/
/** Return: None. **/
/** Notice: None. **/
/*************************************************************************/
void VDIF_RefreshDisplay(void)
{
/*----------------------------------*/
/* Variable Declaration */
/*----------------------------------*/
LCDFrame* pclsMainFrameObjectPtr;
/*----------------------------------*/
/* Initialize */
/*----------------------------------*/
pclsMainFrameObjectPtr = LCDFrame::GetInstance();
/*----------------------------------*/
/* Process */
/*----------------------------------*/
if(NULL != pclsMainFrameObjectPtr)
{
pclsMainFrameObjectPtr->RefreshLCD();
}
}
/*************************************************************************/
/** Function Name: VDIF_ClearDisplay. **/
/** Purpose: Clear screen display. **/
/** Params: None. **/
/** Return: None. **/
/** Notice: None. **/
/*************************************************************************/
void VDIF_ClearDisplay(void)
{
/*----------------------------------*/
/* Variable Declaration */
/*----------------------------------*/
LCDFrame* pclsMainFrameObjectPtr;
/*----------------------------------*/
/* Initialize */
/*----------------------------------*/
pclsMainFrameObjectPtr = LCDFrame::GetInstance();
/*----------------------------------*/
/* Process */
/*----------------------------------*/
if(NULL != pclsMainFrameObjectPtr)
{
pclsMainFrameObjectPtr->ClearLCD();
pclsMainFrameObjectPtr->RefreshLCD();
}
}

View File

@ -8,12 +8,12 @@
<Build>
<Target title="Debug">
<Option output="../../Build/Debug/bin/SimpleGUI" prefix_auto="1" extension_auto="1" />
<Option working_dir="../../Build" />
<Option object_output="../../Build/Debug/obj/" />
<Option type="0" />
<Option compiler="gcc" />
<Option projectLinkerOptionsRelation="2" />
<Compiler>
<Add option="-std=c++11" />
<Add option="-g" />
<Add directory="$(#wx31)/lib/gcc_dll/mswu" />
</Compiler>
@ -27,6 +27,7 @@
</Target>
<Target title="Release">
<Option output="../../Build/Release/bin/SimpleGUI" prefix_auto="1" extension_auto="1" />
<Option working_dir="../../Build" />
<Option object_output="../../Build/Release/obj/" />
<Option type="0" />
<Option compiler="gcc" />
@ -47,6 +48,7 @@
</Build>
<Compiler>
<Add option="-Wall" />
<Add option="-std=c++11" />
<Add option="-pipe" />
<Add option="-mthreads" />
<Add option="-D__GNUWIN32__" />
@ -55,7 +57,6 @@
<Add option="-DwxUSE_UNICODE" />
<Add directory="$(#wx31)/include" />
<Add directory="../../Frame/inc" />
<Add directory="../../User/inc" />
<Add directory="../../GUI/inc" />
<Add directory="../../Library/inc" />
<Add directory="../../HMI/inc" />
@ -63,6 +64,7 @@
<Add directory="../../wxExpand/inc" />
<Add directory="../../Application/inc" />
<Add directory="../../Common/inc" />
<Add directory="../../Interface/inc" />
</Compiler>
<ResourceCompiler>
<Add directory="$(#wx31)/include" />
@ -75,7 +77,9 @@
<Unit filename="../../Application/inc/Application.h" />
<Unit filename="../../Application/src/Application.cpp" />
<Unit filename="../../Common/inc/Common.h" />
<Unit filename="../../Common/src/Common.cpp" />
<Unit filename="../../Demo/inc/DemoProc.h" />
<Unit filename="../../Demo/inc/DemoProcText.h" />
<Unit filename="../../Demo/src/DemoProc.c">
<Option compilerVar="CC" />
</Unit>
@ -97,15 +101,10 @@
<Unit filename="../../Demo/src/VariableBox.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="../../Frame/inc/LCD_OperationIF.h" />
<Unit filename="../../Frame/inc/LCD_VirtualDevice.h" />
<Unit filename="../../Frame/inc/LCD_VirtualDeviceParameter.h" />
<Unit filename="../../Frame/inc/PixelPanel.h" />
<Unit filename="../../Frame/src/LCD_OperationIF.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="../../Frame/src/LCD_VirtualDevice.cpp" />
<Unit filename="../../Frame/src/PixelPanel.cpp" />
<Unit filename="../../Frame/inc/LCDFrame.h" />
<Unit filename="../../Frame/inc/MonochromeDotLCD.h" />
<Unit filename="../../Frame/src/LCDFrame.cpp" />
<Unit filename="../../Frame/src/MonochromeDotLCD.cpp" />
<Unit filename="../../GUI/inc/SGUI_Basic.h" />
<Unit filename="../../GUI/inc/SGUI_Common.h" />
<Unit filename="../../GUI/inc/SGUI_Config.h" />
@ -159,16 +158,22 @@
<Unit filename="../../HMI/src/HMI_Engine.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="../../Interface/inc/UserActionInterface.h" />
<Unit filename="../../Interface/inc/VirtualDeviceInterface.h">
<Option target="&lt;{~None~}&gt;" />
</Unit>
<Unit filename="../../Interface/src/UserActionInterface.cpp">
<Option compilerVar="CC" />
</Unit>
<Unit filename="../../Interface/src/VirtualDeviceInterface.cpp">
<Option compilerVar="CC" />
</Unit>
<Unit filename="../../Library/inc/iconv.h" />
<Unit filename="../../Resource/Resource.rc">
<Option compilerVar="WINDRES" />
</Unit>
<Unit filename="../../User/inc/VirtualDeviceInterface.h" />
<Unit filename="../../User/src/VirtualDeviceInterface.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="../../wxExpand/inc/wxPixelPanel.h" />
<Unit filename="../../wxExpand/src/wxPixelPanel.cpp" />
<Unit filename="../../wxExpand/inc/wxDotLCD.h" />
<Unit filename="../../wxExpand/src/wxDotLCD.cpp" />
<Extensions>
<code_completion />
<envvars />

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_layout_file>
<FileVersion major="1" minor="0" />
<ActiveTarget name="Debug" />
<File name="..\..\Interface\src\UserActionInterface.cpp" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="4301" topLine="63" />
</Cursor>
</File>
<File name="..\..\Common\src\Common.cpp" open="1" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="368" topLine="0" />
</Cursor>
</File>
<File name="..\..\Demo\src\RealtimeGraph.c" open="1" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="4448" topLine="69" />
</Cursor>
</File>
<File name="..\..\HMI\inc\HMI_Engine.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="4459" topLine="102" />
</Cursor>
</File>
<File name="..\..\Demo\src\ScrollingText.c" open="1" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="8606" topLine="141" />
</Cursor>
</File>
<File name="..\..\Demo\src\TextNotice.c" open="1" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="48" />
</Cursor>
</File>
<File name="..\..\Demo\inc\DemoProcText.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="103" topLine="0" />
</Cursor>
</File>
<File name="..\..\HMI\src\HMI_Engine.c" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="12432" topLine="298" />
</Cursor>
</File>
<File name="..\..\Interface\inc\UserActionInterface.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="767" topLine="0" />
</Cursor>
</File>
<File name="..\..\Interface\inc\VirtualDeviceInterface.h" open="1" top="1" tabpos="6" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1683" topLine="37" />
</Cursor>
</File>
<File name="..\..\Frame\src\LCDFrame.cpp" open="0" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="14704" topLine="304" />
</Cursor>
</File>
<File name="..\..\GUI\inc\SGUI_Typedef.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1027" topLine="0" />
</Cursor>
</File>
<File name="..\..\GUI\src\SGUI_Basic.c" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="21653" topLine="571" />
</Cursor>
</File>
<File name="..\..\Common\inc\Common.h" open="1" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="895" topLine="12" />
</Cursor>
</File>
<File name="..\..\Frame\inc\LCDFrame.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1107" topLine="0" />
</Cursor>
</File>
<File name="..\..\GUI\src\SGUI_Frame.c" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="3931" topLine="56" />
</Cursor>
</File>
<File name="..\..\GUI\inc\SGUI_Common.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="449" topLine="0" />
</Cursor>
</File>
<File name="..\..\Demo\src\DemoProc.c" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="5669" topLine="120" />
</Cursor>
</File>
<File name="..\..\GUI\inc\SGUI_Config.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="508" topLine="0" />
</Cursor>
</File>
<File name="..\..\Interface\src\VirtualDeviceInterface.cpp" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="4114" topLine="66" />
</Cursor>
</File>
<File name="..\..\GUI\inc\SGUI_List.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1137" topLine="27" />
</Cursor>
</File>
<File name="..\..\wxExpand\src\wxDotLCD.cpp" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="532" topLine="0" />
</Cursor>
</File>
<File name="..\..\Demo\inc\DemoProc.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="2069" topLine="32" />
</Cursor>
</File>
</CodeBlocks_layout_file>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 644 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 416 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 530 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 667 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 390 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 626 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 475 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 907 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 584 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 499 B

View File

@ -1,9 +1,18 @@
ID_ICON_MAIN ICON "Icons\\ICON_Main.ico"
ID_ICON_FRAME BITMAP "Icons\\ICON_Frame.bmp"
ID_TOOL_SCREENSHOTS BITMAP "Tools\\Screenshots.bmp"
ID_TOOL_COPY BITMAP "Tools\\Copy.bmp"
ID_TOOL_OPENFOLDER BITMAP "Tools\\OpenFolder.bmp"
ID_TOOL_ABOUT BITMAP "Tools\\About.bmp"
ID_TOOL_EXIT BITMAP "Tools\\Exit.bmp"
ID_ICON_APPLICATION ICON "Images\\Application\\ICON_MainFrame.ico"
ID_ICON_MAIN_FRAME ICON "Images\\Application\\ICON_MainFrame.ico"
ID_ICON_LOG_FRAME ICON "Images\\Application\\ICON_LogFrame.ico"
ID_TOOL_CLEARSCREEN RCDATA "Images\\ToolBarIcons\\ClearScreen.png"
ID_TOOL_COPYSCREENSHOT RCDATA "Images\\ToolBarIcons\\CopyScreenShot.png"
ID_TOOL_QUICKSHOTS RCDATA "Images\\ToolBarIcons\\QuickShot.png"
ID_TOOL_SAVESCREENSHOT RCDATA "Images\\ToolBarIcons\\SaveScreenShot.png"
ID_TOOL_OPENSCREENSHOTSFOLDER RCDATA "Images\\ToolBarIcons\\OpenScreenShotsFolder.png"
ID_TOOL_DEVICECONNECT RCDATA "Images\\ToolBarIcons\\DeviceConnect.png"
ID_TOOL_DEVICEDISCONNECT RCDATA "Images\\ToolBarIcons\\DeviceDisconnect.png"
ID_TOOL_SHOWLOGWINDOW RCDATA "Images\\ToolBarIcons\\ShowLogWindow.png"
ID_TOOL_SHOWLOGWINDOW_DISABLE RCDATA "Images\\ToolBarIcons\\ShowLogWindow_Disable.png"
ID_TOOL_SETTING RCDATA "Images\\ToolBarIcons\\Settings.png"
ID_TOOL_ABOUT RCDATA "Images\\ToolBarIcons\\About.png"
ID_TOOL_EXIT RCDATA "Images\\ToolBarIcons\\Exit.png"
ID_IMAGE_ABOUT RCDATA "Images\\Application\\About.png"
#include "wx/msw/wx.rc"

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -1,5 +1,5 @@
#ifndef _INCLUDE_CLASS_PANELLCD_H__
#define _INCLUDE_CLASS_PANELLCD_H__
#ifndef _INCLUDE_CLASS_WXEX_PIXEL_PANEL_H__
#define _INCLUDE_CLASS_WXEX_PIXEL_PANEL_H__
#include <wx/panel.h>
#include <wx/dcbuffer.h>
@ -9,7 +9,7 @@
/// Class LCD_DisplayPanel
///////////////////////////////////////////////////////////////////////////////
class wxPixelPanel : public wxPanel
class wxDotLCD : public wxPanel
{
private: //Appearance parameters.
// Colors
@ -27,20 +27,20 @@ private: //Appearance parameters.
private: // Private data.
uint32_t* m_parrDisplayBuffer;
wxWindow* m_pclsParent;
void (wxPixelPanel::*m_pfDrawPoint)(wxMemoryDC& clsCDCObject, uint32_t uiPosX, uint32_t uiPosY, uint32_t uiPixelSize);
void (wxDotLCD::*m_pfDrawPoint)(wxMemoryDC& clsCDCObject, uint32_t uiPosX, uint32_t uiPosY, uint32_t uiPixelSize);
private: // Private object;
wxClientDC m_CDC;
wxPen m_CPen;
wxBrush m_CBrush;
wxClientDC m_clsCDC;
wxPen m_clsPen;
wxBrush m_clsBrush;
private: // Event callback function.
void wxEvent_OnPaint(wxPaintEvent &event) {OnPaint();event.Skip();}
void _wxEvent_OnPaint(wxPaintEvent &event) {OnPaint();event.Skip();}
public: // Constructor/Destructor
wxPixelPanel(wxWindow *parent, wxWindowID winid = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxTAB_TRAVERSAL | wxNO_BORDER,const wxString& name = wxPanelNameStr);
~wxPixelPanel();
wxDotLCD(wxWindow *parent, wxWindowID winid = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxTAB_TRAVERSAL | wxNO_BORDER,const wxString& name = wxPanelNameStr);
~wxDotLCD();
public: // Public interface
void SetDisplaySizes(uint32_t uiEdgeWidth, uint32_t uiHorizontalPixelNumber, uint32_t uiVerticalPixelNumber, uint32_t uiPixelSize, bool bGridVisible);
@ -58,27 +58,26 @@ public: // Public interface
void SetGridColor(const wxColor& clsColor);
wxWindow* GetParentWindow(void);
void OnPaint(void);
void SetPixel(uint32_t uiPosX, uint32_t uiPosY, wxColor& clsColor, bool bRefreshNow = false);
void SetPixelColor(uint32_t uiPosX, uint32_t uiPosY, wxColor& clsColor, bool bRefreshNow = false);
void DrawPixel(uint32_t uiPosX, uint32_t uiPosY, wxColor& clsColor);
uint32_t GetPixel(uint32_t uiPosX, uint32_t uiPosY);
uint32_t GetPixelColor(uint32_t uiPosX, uint32_t uiPosY);
void RefreshDisplay(void);
void CleanPanel(void);
bool SaveToFile(const wxString& CStrFilePath);
bool CopyToClipBoard(void);
bool SaveScreenImageToFile(const wxString& strFilePath);
bool CopyScreenImageToClipBoard(void);
void ResizeParent(void);
private: // Private process function.
inline void DrawPointSinglePixel(wxMemoryDC& clsCDCObject, uint32_t uiPosX, uint32_t uiPosY, uint32_t uiPixelSize);
inline void DrawPointMultiplePixel(wxMemoryDC& clsCDCObject, uint32_t uiPosX, uint32_t uiPosY, uint32_t uiPixelSize);
inline void DrawPointMultiplePixelWithGrid(wxMemoryDC& clsCDCObject, uint32_t uiPosX, uint32_t uiPosY, uint32_t uiPixelSize);
inline void ReleaseDC(wxMemoryDC& clsCDCObject) {clsCDCObject.SetBrush(wxNullBrush); clsCDCObject.SetPen(wxNullPen);}
inline void PrepareDC(wxMemoryDC& clsCDCObject) {clsCDCObject.SetBrush(m_CBrush); clsCDCObject.SetPen(m_CPen);}
inline void PrepareDC(wxMemoryDC& clsCDCObject) {clsCDCObject.SetBrush(m_clsBrush); clsCDCObject.SetPen(m_clsPen);}
inline void ReleaseDC(wxClientDC& clsCDCObject) {clsCDCObject.SetBrush(wxNullBrush); clsCDCObject.SetPen(wxNullPen);}
inline void PrepareDC(wxClientDC& clsCDCObject) {clsCDCObject.SetBrush(m_CBrush); clsCDCObject.SetPen(m_CPen);}
inline void SetDCColor(const wxColor& clsColour) {m_CPen.SetColour(clsColour);m_CBrush.SetColour(clsColour);}
inline void PrepareDC(wxClientDC& clsCDCObject) {clsCDCObject.SetBrush(m_clsBrush); clsCDCObject.SetPen(m_clsPen);}
inline void SetDCColor(const wxColor& clsColour) {m_clsPen.SetColour(clsColour);m_clsBrush.SetColour(clsColour);}
DECLARE_EVENT_TABLE();
};
#endif // _INCLUDE_CLASS_PANELLCD_H__
#endif // _INCLUDE_CLASS_WXEX_PIXEL_PANEL_H__

549
wxExpand/src/wxDotLCD.cpp Normal file
View File

@ -0,0 +1,549 @@
//=======================================================================//
//= Include files. =//
//=======================================================================//
#include <wx/clipbrd.h>
#include "wxDotLCD.h"
//=======================================================================//
//= Event table. =//
//=======================================================================//
BEGIN_EVENT_TABLE(wxDotLCD,wxPanel)
EVT_PAINT (wxDotLCD::_wxEvent_OnPaint)
END_EVENT_TABLE()
//=======================================================================//
//= Function define. =//
//=======================================================================//
wxDotLCD::wxDotLCD(wxWindow *parent, wxWindowID winid, const wxPoint& pos, const wxSize& size, long style, const wxString& name):
wxPanel(parent, winid, pos, size, style, name),
m_clsCDC(this)
{
m_pclsParent = parent;
m_parrDisplayBuffer = NULL;
m_pfDrawPoint = NULL;
m_uiHorizontalPixelNumber = 0;
m_uiVerticalPixelNumber = 0;
m_uiPixelSize = 0;
m_uiEdgeWidth = 0;
m_bGridVisible = false;
m_pclsEdgeColor = new wxColor(0x80, 0x80, 0x80, 0x00);
m_pclsBaseColor = new wxColor(0xFF, 0xFF, 0xFF, 0x00);
m_pclsGridColor = new wxColor(0x80, 0x80, 0x80, 0x00);
}
wxDotLCD::~wxDotLCD()
{
if(NULL != m_parrDisplayBuffer)
{
free(m_parrDisplayBuffer);
}
delete m_pclsEdgeColor;
delete m_pclsBaseColor;
delete m_pclsGridColor;
}
void wxDotLCD::SetDisplaySizes(uint32_t uiEdgeWidth, uint32_t uiHorizontalPixelNumber, uint32_t uiVerticalPixelNumber, uint32_t uiPixelSize, bool bGridVisible)
{
// Set grid visible status.
m_uiEdgeWidth = uiEdgeWidth;
m_bGridVisible = bGridVisible;
m_uiPixelSize = uiPixelSize;
/*----------------------------------*/
/* Process */
/*----------------------------------*/
if(m_uiPixelSize == 0)
{
m_pfDrawPoint = NULL;
}
else if(m_uiPixelSize == 1)
{
m_pfDrawPoint = &DrawPointSinglePixel;
}
else
{
if((true == bGridVisible) && (m_uiPixelSize > 2))
{
m_pfDrawPoint = &DrawPointMultiplePixelWithGrid;
}
else
{
m_pfDrawPoint = &DrawPointMultiplePixel;
}
}
// Free current buffer.
if(NULL != m_parrDisplayBuffer)
{
free(m_parrDisplayBuffer);
}
if((uiHorizontalPixelNumber > 0) && (uiVerticalPixelNumber > 0))
{
uint32_t uiDisplayBufferSize;
// Recalculate buffer size.
m_uiHorizontalPixelNumber = uiHorizontalPixelNumber;
m_uiVerticalPixelNumber = uiVerticalPixelNumber;
uiDisplayBufferSize = m_uiHorizontalPixelNumber*m_uiVerticalPixelNumber;
// Reallocate display buffer;
m_parrDisplayBuffer = (uint32_t*)malloc(uiDisplayBufferSize*sizeof(uint32_t));
if(NULL != m_parrDisplayBuffer)
{
// Clear memory.
memset(m_parrDisplayBuffer, 0x00, uiDisplayBufferSize);
}
}
else
{
m_uiHorizontalPixelNumber = 0;
m_uiVerticalPixelNumber = 0;
}
}
void wxDotLCD::GetDisplaySize(uint32_t* puiEdgeWidth, uint32_t* puiHorizontalPixelNumber, uint32_t* puiVerticalPixelNumber, uint32_t* puiPixelSize, bool* pbGridVisible)
{
/*----------------------------------*/
/* Process */
/*----------------------------------*/
if(NULL != puiEdgeWidth)
{
*puiEdgeWidth = m_uiEdgeWidth;
}
if(NULL != puiHorizontalPixelNumber)
{
*puiHorizontalPixelNumber = m_uiHorizontalPixelNumber;
}
if(NULL != puiVerticalPixelNumber)
{
*puiVerticalPixelNumber = m_uiVerticalPixelNumber;
}
if(NULL != puiPixelSize)
{
*puiPixelSize = m_uiPixelSize;
}
if(NULL != pbGridVisible)
{
*pbGridVisible = m_bGridVisible;
}
}
void wxDotLCD::SetDisplayColors(const wxColor& clsEdgeColor, const wxColor& clsBaseColor, const wxColor& clsGridColor)
{
/*----------------------------------*/
/* Process */
/*----------------------------------*/
if(NULL != m_pclsEdgeColor)
{
m_pclsEdgeColor->SetRGB(clsEdgeColor.GetRGB());
}
if(NULL != m_pclsBaseColor)
{
m_pclsBaseColor->SetRGB(clsBaseColor.GetRGB());
}
if(NULL != m_pclsGridColor)
{
m_pclsGridColor->SetRGB(clsGridColor.GetRGB());
}
}
void wxDotLCD::SetDisplayAreaSize( uint32_t uiHorizontalPixelNumber, uint32_t uiVerticalPixelNumber)
{
/*----------------------------------*/
/* Process */
/*----------------------------------*/
m_uiHorizontalPixelNumber = uiHorizontalPixelNumber;
m_uiVerticalPixelNumber = uiVerticalPixelNumber;
}
void wxDotLCD::SetEdgeWidth(uint32_t uiEdgeWidth)
{
/*----------------------------------*/
/* Process */
/*----------------------------------*/
m_uiEdgeWidth = uiEdgeWidth;
}
void wxDotLCD::SetPixelSize(uint32_t uiPixelSize)
{
/*----------------------------------*/
/* Process */
/*----------------------------------*/
m_uiPixelSize = uiPixelSize;
}
void wxDotLCD::SetGridVisibled(bool bGridVisible)
{
/*----------------------------------*/
/* Process */
/*----------------------------------*/
m_bGridVisible = bGridVisible;
}
void wxDotLCD::CleanPanel(void)
{
/*----------------------------------*/
/* Variable Declaration */
/*----------------------------------*/
uint32_t uiDisplayBufferSize;
/*----------------------------------*/
/* Initialize */
/*----------------------------------*/
uiDisplayBufferSize = m_uiHorizontalPixelNumber*m_uiVerticalPixelNumber;
/*----------------------------------*/
/* Process */
/*----------------------------------*/
memset(m_parrDisplayBuffer, 0x00, sizeof(uint32_t)*uiDisplayBufferSize);
RefreshDisplay();
}
void wxDotLCD::SetEdgeColor(const wxColor& clsColor)
{
/*----------------------------------*/
/* Process */
/*----------------------------------*/
if(NULL != m_pclsEdgeColor)
{
m_pclsEdgeColor->SetRGB(clsColor.GetRGB());
}
}
void wxDotLCD::SetBaseColor(const wxColor& clsColor)
{
/*----------------------------------*/
/* Process */
/*----------------------------------*/
if(NULL != m_pclsBaseColor)
{
m_pclsBaseColor->SetRGB(clsColor.GetRGB());
}
}
void wxDotLCD::SetGridColor(const wxColor& clsColor)
{
/*----------------------------------*/
/* Process */
/*----------------------------------*/
if(NULL != m_pclsGridColor)
{
m_pclsGridColor->SetRGB(clsColor.GetRGB());
}
}
void wxDotLCD::OnPaint(void)
{
/*----------------------------------*/
/* Process */
/*----------------------------------*/
RefreshDisplay();
}
void wxDotLCD::DrawPointSinglePixel(wxMemoryDC& clsCDCObject, uint32_t uiPosX, uint32_t uiPosY, uint32_t uiPixelSize)
{
/*----------------------------------*/
/* Process */
/*----------------------------------*/
clsCDCObject.DrawPoint(wxPoint(m_uiEdgeWidth+uiPosX, m_uiEdgeWidth+uiPosY));
}
void wxDotLCD::DrawPointMultiplePixel(wxMemoryDC& clsCDCObject, uint32_t uiPosX, uint32_t uiPosY, uint32_t uiPixelSize)
{
/*----------------------------------*/
/* Process */
/*----------------------------------*/
clsCDCObject.DrawRectangle(wxPoint(m_uiEdgeWidth+uiPosX*uiPixelSize, m_uiEdgeWidth+uiPosY*uiPixelSize), wxSize(uiPixelSize, uiPixelSize));
}
void wxDotLCD::DrawPointMultiplePixelWithGrid(wxMemoryDC& clsCDCObject, uint32_t uiPosX, uint32_t uiPosY, uint32_t uiPixelSize)
{
/*----------------------------------*/
/* Process */
/*----------------------------------*/
clsCDCObject.DrawRectangle(wxPoint(m_uiEdgeWidth+uiPosX*uiPixelSize+1, m_uiEdgeWidth+uiPosY*uiPixelSize+1), wxSize(uiPixelSize-1, uiPixelSize-1));
}
/*************************************************************************/
/** Function Name: SetPixelColor **/
/** Purpose: Set a pixel RGBA color value. **/
/** Params: **/
/** @ uiPosX[in]: X-Coordinate of pixel. **/
/** @ uiPosY[in]: Y-Coordinate of pixel. **/
/** @ clsColor[in]: Color data object. **/
/** @ bRefreshNow[in]: Refresh display at once, default to false. **/
/** Return: None. **/
/** Notice: This function only change the pixel color register **/
/** if bRefreshNow is false(default), and when the **/
/** parameter bRefreshNow is true, all pixel blocks of **/
/** LCD screen panel will be repaint. if need to draw **/
/** only one pixel, please use the DrawPixel function **/
/** directly. **/
/*************************************************************************/
void wxDotLCD::SetPixelColor(uint32_t uiPosX, uint32_t uiPosY, wxColor& clsColor, bool bRefreshNow)
{
/*----------------------------------*/
/* Process */
/*----------------------------------*/
if((uiPosX < m_uiHorizontalPixelNumber) && (uiPosY < m_uiVerticalPixelNumber))
{
if(NULL != m_parrDisplayBuffer)
{
*(m_parrDisplayBuffer+uiPosX+(uiPosY*m_uiHorizontalPixelNumber)) = clsColor.GetRGBA();
}
if(true == bRefreshNow)
{
RefreshDisplay();
}
}
}
uint32_t wxDotLCD::GetPixelColor(uint32_t uiPosX, uint32_t uiPosY)
{
/*----------------------------------*/
/* Variable Declaration */
/*----------------------------------*/
uint32_t uiReturnValue = 0x00;
/*----------------------------------*/
/* Process */
/*----------------------------------*/
if((uiPosX < m_uiHorizontalPixelNumber) && (uiPosY < m_uiVerticalPixelNumber))
{
if(NULL != m_parrDisplayBuffer)
{
uiReturnValue = *(m_parrDisplayBuffer+uiPosX+(uiPosY*m_uiHorizontalPixelNumber));
}
}
return uiReturnValue;
}
/*************************************************************************/
/** Function Name: DrawPixel **/
/** Purpose: Draw a pixel. **/
/** Params: **/
/** @ uiPosX[in]: X-Coordinate of pixel. **/
/** @ uiPosY[in]: Y-Coordinate of pixel. **/
/** @ clsColor[in]: Color data object. **/
/** Return: None. **/
/** Notice: Draw only one pixel directly. **/
/*************************************************************************/
void wxDotLCD::DrawPixel(uint32_t uiPosX, uint32_t uiPosY, wxColor& clsColor)
{
/*----------------------------------*/
/* Process */
/*----------------------------------*/
if(m_uiPixelSize != 0)
{
SetDCColor(clsColor);
PrepareDC(m_clsCDC);
if(m_uiPixelSize == 1)
{
m_clsCDC.DrawPoint(wxPoint(m_uiEdgeWidth+uiPosX, m_uiEdgeWidth+uiPosY));
}
else
{
if((true == m_bGridVisible) && (m_uiPixelSize > 2))
{
m_clsCDC.DrawRectangle(wxPoint(m_uiEdgeWidth+uiPosX*m_uiPixelSize+1, m_uiEdgeWidth+uiPosY*m_uiPixelSize+1), wxSize(m_uiPixelSize-1, m_uiPixelSize-1));
}
else
{
m_clsCDC.DrawRectangle(wxPoint(m_uiEdgeWidth+uiPosX*m_uiPixelSize, m_uiEdgeWidth+uiPosY*m_uiPixelSize), wxSize(m_uiPixelSize, m_uiPixelSize));
}
}
SetPixelColor(uiPosX, uiPosY, clsColor);
ReleaseDC(m_clsCDC);
}
if(NULL != m_parrDisplayBuffer)
{
*(m_parrDisplayBuffer+uiPosX+(uiPosY*m_uiHorizontalPixelNumber)) = clsColor.GetRGBA();
}
}
/*************************************************************************/
/** Function Name: RefreshDisplay **/
/** Purpose: Repaint LCD screen panel. **/
/** Params: None. **/
/** Return: None. **/
/** Notice: Call this function after the SetPixelColor called, **/
/** all pixels of the LCD panel will be repaint by the **/
/** pixels's RGBA value register array. **/
/*************************************************************************/
void wxDotLCD::RefreshDisplay(void)
{
/*----------------------------------*/
/* Variable Declaration */
/*----------------------------------*/
uint32_t uiPaintSizeWidth, uiPaintSizeHeight;
/*----------------------------------*/
/* Initialize */
/*----------------------------------*/
uiPaintSizeWidth = m_uiHorizontalPixelNumber*m_uiPixelSize+m_uiEdgeWidth*2;
uiPaintSizeHeight = m_uiVerticalPixelNumber*m_uiPixelSize+m_uiEdgeWidth*2;
// Set buffer size.
if((true == m_bGridVisible) && (2 < m_uiPixelSize))
{
uiPaintSizeWidth++;
uiPaintSizeHeight++;
}
// Create buffer image and DC object.
wxBitmap clsBufferImage(uiPaintSizeWidth, uiPaintSizeHeight);
wxBufferedDC clsBufferedDC(&m_clsCDC, clsBufferImage);
// Draw background.
SetDCColor(*m_pclsEdgeColor);
PrepareDC(clsBufferedDC);
clsBufferedDC.DrawRectangle(wxPoint(0, 0),wxSize(uiPaintSizeWidth, uiPaintSizeHeight));
// Draw grid line.
if((true == m_bGridVisible) && (2 < m_uiPixelSize))
{
SetDCColor(*m_pclsGridColor);
PrepareDC(clsBufferedDC);
clsBufferedDC.DrawRectangle(wxPoint(m_uiEdgeWidth, m_uiEdgeWidth),
wxSize( m_uiHorizontalPixelNumber*m_uiPixelSize+1,
m_uiVerticalPixelNumber*m_uiPixelSize+1));
}
if(NULL != m_pfDrawPoint)
{
// Refresh each pixel on screen.
for(uint32_t i_H=0; i_H<m_uiVerticalPixelNumber; i_H++)
{
for(uint32_t i_W=0; i_W<m_uiHorizontalPixelNumber; i_W++)
{
SetDCColor(wxColor(*(m_parrDisplayBuffer+(i_W+i_H*m_uiHorizontalPixelNumber))));
PrepareDC(clsBufferedDC);
(this->*m_pfDrawPoint)(clsBufferedDC, i_W, i_H, m_uiPixelSize);
}
}
}
}
/*************************************************************************/
/** Function Name: ResizeParent **/
/** Purpose: Resize parent window to adapt current object size. **/
/** Params: None. **/
/** Return: None. **/
/** Notice: Call this function after the SetPixelColor called, **/
/** all pixels of the LCD panel will be repaint by the **/
/** pixels's RGBA value register array. **/
/*************************************************************************/
void wxDotLCD::ResizeParent(void)
{
/*----------------------------------*/
/* Variable Declaration */
/*----------------------------------*/
uint32_t uiPaintSizeWidth, uiPaintSizeHeight;
/*----------------------------------*/
/* Initialize */
/*----------------------------------*/
// Get drawing area size.
uiPaintSizeWidth = m_uiHorizontalPixelNumber*m_uiPixelSize+m_uiEdgeWidth*2;
uiPaintSizeHeight = m_uiVerticalPixelNumber*m_uiPixelSize+m_uiEdgeWidth*2;
/*----------------------------------*/
/* Process */
/*----------------------------------*/
if((true == m_bGridVisible) && (2 <m_uiPixelSize))
{
m_pclsParent->SetClientSize(uiPaintSizeWidth+1, uiPaintSizeHeight+1);
}
else
{
m_pclsParent->SetClientSize(uiPaintSizeWidth, uiPaintSizeHeight);
}
}
/*************************************************************************/
/** Function Name: SaveScreenImageToFile **/
/** Purpose: Save current panel image to a jpeg file. **/
/** Params: **/
/** @ strFilePath[in]: Save file path. **/
/** Return: **/
/** @ true: Save successfully. **/
/** @ false: Save failed. **/
/** Notice: To support jpeg format, need add wxWidgets jpeg **/
/** format handler in initialize(OnInit) function of **/
/** the wxApp Object. **/
/** wxImage::AddHandler(new wxJPEGHandler) **/
/*************************************************************************/
bool wxDotLCD::SaveScreenImageToFile(const wxString& strFilePath)
{
/*----------------------------------*/
/* Variable Declaration */
/*----------------------------------*/
// Create and initialize bitmap.
wxBitmap* pclsBitMap;
wxMemoryDC* pclsMemoryDC;
bool bReturn;
/*----------------------------------*/
/* Initialize */
/*----------------------------------*/
bReturn = false;
/*----------------------------------*/
/* Process */
/*----------------------------------*/
// Create bitmap buffer.
pclsBitMap = new wxBitmap(GetSize(), wxBITMAP_SCREEN_DEPTH);
if(NULL != pclsBitMap)
{
pclsMemoryDC = new wxMemoryDC(*pclsBitMap);
if(NULL != pclsMemoryDC)
{
bReturn = pclsMemoryDC->Blit(wxPoint(0, 0), GetSize(), &m_clsCDC, wxPoint(0, 0));
if(true == bReturn)
{
bReturn = pclsBitMap->SaveFile(strFilePath, wxBITMAP_TYPE_JPEG);
}
}
}
//
delete pclsBitMap;
delete pclsMemoryDC;
return bReturn;
}
bool wxDotLCD::CopyScreenImageToClipBoard(void)
{
uint32_t uiPictureWidth, uiPictureHeight;
// Get panel size
uiPictureWidth = GetSize().GetX();
uiPictureHeight = GetSize().GetY();
wxBitmap CBitMap(uiPictureWidth, uiPictureHeight, wxBITMAP_SCREEN_DEPTH);
wxMemoryDC CMemoryDC(CBitMap);
CMemoryDC.Blit(wxPoint(0, 0), wxSize(uiPictureWidth, uiPictureHeight), &m_clsCDC, wxPoint(0, 0));
if(wxTheClipboard->Open())
{
wxTheClipboard->SetData(new wxBitmapDataObject(CBitMap));
wxTheClipboard->Close();
return true;
}
else
{
return false;
}
}
wxWindow* wxDotLCD::GetParentWindow(void)
{
return m_pclsParent;
}

View File

@ -1,385 +0,0 @@
#include <wx/clipbrd.h>
#include "wxPixelPanel.h"
BEGIN_EVENT_TABLE(wxPixelPanel,wxPanel)
EVT_PAINT (wxPixelPanel::wxEvent_OnPaint)
END_EVENT_TABLE()
wxPixelPanel::wxPixelPanel(wxWindow *parent, wxWindowID winid, const wxPoint& pos, const wxSize& size, long style, const wxString& name):
wxPanel(parent, winid, pos, size, style, name),
m_CDC(this)
{
m_pclsParent = parent;
m_parrDisplayBuffer = NULL;
m_pfDrawPoint = NULL;
m_uiHorizontalPixelNumber = 0;
m_uiVerticalPixelNumber = 0;
m_uiPixelSize = 0;
m_uiEdgeWidth = 0;
m_bGridVisible = false;
m_pclsEdgeColor = new wxColor(0x80, 0x80, 0x80, 0x00);
m_pclsBaseColor = new wxColor(0xFF, 0xFF, 0xFF, 0x00);
m_pclsGridColor = new wxColor(0x80, 0x80, 0x80, 0x00);
}
wxPixelPanel::~wxPixelPanel()
{
if(NULL != m_parrDisplayBuffer)
{
free(m_parrDisplayBuffer);
}
delete m_pclsEdgeColor;
delete m_pclsBaseColor;
delete m_pclsGridColor;
}
void wxPixelPanel::SetDisplaySizes(uint32_t uiEdgeWidth, uint32_t uiHorizontalPixelNumber, uint32_t uiVerticalPixelNumber, uint32_t uiPixelSize, bool bGridVisible)
{
// Set grid visible status.
m_uiEdgeWidth = uiEdgeWidth;
m_bGridVisible = bGridVisible;
m_uiPixelSize = uiPixelSize;
if(m_uiPixelSize == 0)
{
m_pfDrawPoint = NULL;
}
else if(m_uiPixelSize == 1)
{
m_pfDrawPoint = &DrawPointSinglePixel;
}
else
{
if((true == bGridVisible) && (m_uiPixelSize > 2))
{
m_pfDrawPoint = &DrawPointMultiplePixelWithGrid;
}
else
{
m_pfDrawPoint = &DrawPointMultiplePixel;
}
}
// Free current buffer.
if(NULL != m_parrDisplayBuffer)
{
free(m_parrDisplayBuffer);
}
if((uiHorizontalPixelNumber > 0) && (uiVerticalPixelNumber > 0))
{
uint32_t uiDisplayBufferSize;
// Recalculate buffer size.
m_uiHorizontalPixelNumber = uiHorizontalPixelNumber;
m_uiVerticalPixelNumber = uiVerticalPixelNumber;
uiDisplayBufferSize = m_uiHorizontalPixelNumber*m_uiVerticalPixelNumber;
// Reallocate display buffer;
m_parrDisplayBuffer = (uint32_t*)malloc(uiDisplayBufferSize*sizeof(uint32_t));
if(NULL != m_parrDisplayBuffer)
{
// Clear memory.
memset(m_parrDisplayBuffer, 0x00, uiDisplayBufferSize);
}
}
else
{
m_uiHorizontalPixelNumber = 0;
m_uiVerticalPixelNumber = 0;
}
}
void wxPixelPanel::GetDisplaySize(uint32_t* puiEdgeWidth, uint32_t* puiHorizontalPixelNumber, uint32_t* puiVerticalPixelNumber, uint32_t* puiPixelSize, bool* pbGridVisible)
{
if(NULL != puiEdgeWidth)
{
*puiEdgeWidth = m_uiEdgeWidth;
}
if(NULL != puiHorizontalPixelNumber)
{
*puiHorizontalPixelNumber = m_uiHorizontalPixelNumber;
}
if(NULL != puiVerticalPixelNumber)
{
*puiVerticalPixelNumber = m_uiVerticalPixelNumber;
}
if(NULL != puiPixelSize)
{
*puiPixelSize = m_uiPixelSize;
}
if(NULL != pbGridVisible)
{
*pbGridVisible = m_bGridVisible;
}
}
void wxPixelPanel::SetDisplayColors(const wxColor& clsEdgeColor, const wxColor& clsBaseColor, const wxColor& clsGridColor)
{
if(NULL != m_pclsEdgeColor)
{
m_pclsEdgeColor->SetRGB(clsEdgeColor.GetRGB());
}
if(NULL != m_pclsBaseColor)
{
m_pclsBaseColor->SetRGB(clsBaseColor.GetRGB());
}
if(NULL != m_pclsGridColor)
{
m_pclsGridColor->SetRGB(clsGridColor.GetRGB());
}
}
void wxPixelPanel::SetDisplayAreaSize( uint32_t uiHorizontalPixelNumber, uint32_t uiVerticalPixelNumber)
{
m_uiHorizontalPixelNumber = uiHorizontalPixelNumber;
m_uiVerticalPixelNumber = uiVerticalPixelNumber;
}
void wxPixelPanel::SetEdgeWidth(uint32_t uiEdgeWidth)
{
m_uiEdgeWidth = uiEdgeWidth;
}
void wxPixelPanel::SetPixelSize(uint32_t uiPixelSize)
{
m_uiPixelSize = uiPixelSize;
}
void wxPixelPanel::SetGridVisibled(bool bGridVisible)
{
m_bGridVisible = bGridVisible;
}
void wxPixelPanel::CleanPanel(void)
{
uint32_t uiDisplayBufferSize;
uiDisplayBufferSize = m_uiHorizontalPixelNumber*m_uiVerticalPixelNumber;
memset(m_parrDisplayBuffer, 0x00, sizeof(uint32_t)*uiDisplayBufferSize);
RefreshDisplay();
}
void wxPixelPanel::SetEdgeColor(const wxColor& clsColor)
{
if(NULL != m_pclsEdgeColor)
{
m_pclsEdgeColor->SetRGB(clsColor.GetRGB());
}
}
void wxPixelPanel::SetBaseColor(const wxColor& clsColor)
{
if(NULL != m_pclsBaseColor)
{
m_pclsBaseColor->SetRGB(clsColor.GetRGB());
}
}
void wxPixelPanel::SetGridColor(const wxColor& clsColor)
{
if(NULL != m_pclsGridColor)
{
m_pclsGridColor->SetRGB(clsColor.GetRGB());
}
}
void wxPixelPanel::OnPaint(void)
{
RefreshDisplay();
}
void wxPixelPanel::DrawPointSinglePixel(wxMemoryDC& clsCDCObject, uint32_t uiPosX, uint32_t uiPosY, uint32_t uiPixelSize)
{
clsCDCObject.DrawPoint(wxPoint(m_uiEdgeWidth+uiPosX, m_uiEdgeWidth+uiPosY));
}
void wxPixelPanel::DrawPointMultiplePixel(wxMemoryDC& clsCDCObject, uint32_t uiPosX, uint32_t uiPosY, uint32_t uiPixelSize)
{
clsCDCObject.DrawRectangle(wxPoint(m_uiEdgeWidth+uiPosX*uiPixelSize, m_uiEdgeWidth+uiPosY*uiPixelSize), wxSize(uiPixelSize, uiPixelSize));
}
void wxPixelPanel::DrawPointMultiplePixelWithGrid(wxMemoryDC& clsCDCObject, uint32_t uiPosX, uint32_t uiPosY, uint32_t uiPixelSize)
{
clsCDCObject.DrawRectangle(wxPoint(m_uiEdgeWidth+uiPosX*uiPixelSize+1, m_uiEdgeWidth+uiPosY*uiPixelSize+1), wxSize(uiPixelSize-1, uiPixelSize-1));
}
void wxPixelPanel::SetPixel(uint32_t uiPosX, uint32_t uiPosY, wxColor& clsColor, bool bRefreshNow)
{
if((uiPosX < m_uiHorizontalPixelNumber) && (uiPosY < m_uiVerticalPixelNumber))
{
if(NULL != m_parrDisplayBuffer)
{
*(m_parrDisplayBuffer+uiPosX+(uiPosY*m_uiHorizontalPixelNumber)) = clsColor.GetRGBA();
}
if(true == bRefreshNow)
{
RefreshDisplay();
}
}
}
uint32_t wxPixelPanel::GetPixel(uint32_t uiPosX, uint32_t uiPosY)
{
uint32_t uiReturnValue = 0x00;
if((uiPosX < m_uiHorizontalPixelNumber) && (uiPosY < m_uiVerticalPixelNumber))
{
if(NULL != m_parrDisplayBuffer)
{
uiReturnValue = *(m_parrDisplayBuffer+uiPosX+(uiPosY*m_uiHorizontalPixelNumber));
}
}
return uiReturnValue;
}
void wxPixelPanel::DrawPixel(uint32_t uiPosX, uint32_t uiPosY, wxColor& clsColor)
{
/*----------------------------------*/
/* Process */
/*----------------------------------*/
if(m_uiPixelSize != 0)
{
SetDCColor(clsColor);
PrepareDC(m_CDC);
if(m_uiPixelSize == 1)
{
m_CDC.DrawPoint(wxPoint(m_uiEdgeWidth+uiPosX, m_uiEdgeWidth+uiPosY));
}
else
{
if((true == m_bGridVisible) && (m_uiPixelSize > 2))
{
m_CDC.DrawRectangle(wxPoint(m_uiEdgeWidth+uiPosX*m_uiPixelSize+1, m_uiEdgeWidth+uiPosY*m_uiPixelSize+1), wxSize(m_uiPixelSize-1, m_uiPixelSize-1));
}
else
{
m_CDC.DrawRectangle(wxPoint(m_uiEdgeWidth+uiPosX*m_uiPixelSize, m_uiEdgeWidth+uiPosY*m_uiPixelSize), wxSize(m_uiPixelSize, m_uiPixelSize));
}
}
SetPixel(uiPosX, uiPosY, clsColor);
ReleaseDC(m_CDC);
}
}
void wxPixelPanel::RefreshDisplay(void)
{
uint32_t uiPaintSizeWidth, uiPaintSizeHeight;
uiPaintSizeWidth = m_uiHorizontalPixelNumber*m_uiPixelSize+m_uiEdgeWidth*2;
uiPaintSizeHeight = m_uiVerticalPixelNumber*m_uiPixelSize+m_uiEdgeWidth*2;
// Set buffer size.
if((true == m_bGridVisible) && (2 < m_uiPixelSize))
{
uiPaintSizeWidth++;
uiPaintSizeHeight++;
}
// Create buffer image and DC object.
wxBitmap clsBufferImage(uiPaintSizeWidth, uiPaintSizeHeight);
wxBufferedDC clsBufferedDC(&m_CDC, clsBufferImage);
// Draw background.
SetDCColor(*m_pclsEdgeColor);
PrepareDC(clsBufferedDC);
clsBufferedDC.DrawRectangle(wxPoint(0, 0),wxSize(uiPaintSizeWidth, uiPaintSizeHeight));
// Draw grid line.
if((true == m_bGridVisible) && (2 < m_uiPixelSize))
{
SetDCColor(*m_pclsGridColor);
PrepareDC(clsBufferedDC);
clsBufferedDC.DrawRectangle(wxPoint(m_uiEdgeWidth, m_uiEdgeWidth),
wxSize( m_uiHorizontalPixelNumber*m_uiPixelSize+1,
m_uiVerticalPixelNumber*m_uiPixelSize+1));
}
if(NULL != m_pfDrawPoint)
{
// Refresh each pixel on screen.
for(uint32_t i_H=0; i_H<m_uiVerticalPixelNumber; i_H++)
{
for(uint32_t i_W=0; i_W<m_uiHorizontalPixelNumber; i_W++)
{
SetDCColor(wxColor(*(m_parrDisplayBuffer+(i_W+i_H*m_uiHorizontalPixelNumber))));
PrepareDC(clsBufferedDC);
(this->*m_pfDrawPoint)(clsBufferedDC, i_W, i_H, m_uiPixelSize);
}
}
}
}
void wxPixelPanel::ResizeParent(void)
{
/*----------------------------------*/
/* Variable Declaration */
/*----------------------------------*/
uint32_t uiPaintSizeWidth, uiPaintSizeHeight;
/*----------------------------------*/
/* Initialize */
/*----------------------------------*/
// Get drawing area size.
uiPaintSizeWidth = m_uiHorizontalPixelNumber*m_uiPixelSize+m_uiEdgeWidth*2;
uiPaintSizeHeight = m_uiVerticalPixelNumber*m_uiPixelSize+m_uiEdgeWidth*2;
/*----------------------------------*/
/* Process */
/*----------------------------------*/
if((true == m_bGridVisible) && (2 <m_uiPixelSize))
{
m_pclsParent->SetClientSize(uiPaintSizeWidth+1, uiPaintSizeHeight+1);
}
else
{
m_pclsParent->SetClientSize(uiPaintSizeWidth, uiPaintSizeHeight);
}
}
bool wxPixelPanel::SaveToFile(const wxString& CStrFilePath)
{
// Create and initialize bitmap.
uint32_t uiPictureWidth, uiPictureHeight;
// Get panel size
uiPictureWidth = GetSize().GetX();
uiPictureHeight = GetSize().GetY();
wxBitmap CBitMap(uiPictureWidth, uiPictureHeight, wxBITMAP_SCREEN_DEPTH);
wxMemoryDC CMemoryDC(CBitMap);
CMemoryDC.Blit(wxPoint(0, 0), wxSize(uiPictureWidth, uiPictureHeight), &m_CDC, wxPoint(0, 0));
return CBitMap.SaveFile(CStrFilePath, wxBITMAP_TYPE_JPEG);
}
bool wxPixelPanel::CopyToClipBoard(void)
{
uint32_t uiPictureWidth, uiPictureHeight;
// Get panel size
uiPictureWidth = GetSize().GetX();
uiPictureHeight = GetSize().GetY();
wxBitmap CBitMap(uiPictureWidth, uiPictureHeight, wxBITMAP_SCREEN_DEPTH);
wxMemoryDC CMemoryDC(CBitMap);
CMemoryDC.Blit(wxPoint(0, 0), wxSize(uiPictureWidth, uiPictureHeight), &m_CDC, wxPoint(0, 0));
if(wxTheClipboard->Open())
{
wxTheClipboard->SetData(new wxBitmapDataObject(CBitMap));
wxTheClipboard->Close();
return true;
}
else
{
return false;
}
}
wxWindow* wxPixelPanel::GetParentWindow(void)
{
return m_pclsParent;
}