From f7bcc2f57e066d0a424772e6c590ea60539363bc Mon Sep 17 00:00:00 2001 From: Polarix Date: Mon, 21 Jan 2019 22:42:41 +0800 Subject: [PATCH] =?UTF-8?q?2019-01-21=EF=BC=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修正Virtual SDK虚拟LCD窗体失去焦点并重新获得焦点后,回车键和方向键不响应的问题。 为方便源码理解,订正实时曲线控件的一些变量名称。 --- GUI/inc/SGUI_RealtimeGraph.h | 12 ++++++------ GUI/src/SGUI_RealtimeGraph.c | 14 +++++++------- VirtualSDK/Application/src/Application.cpp | 4 ++-- VirtualSDK/Controls/inc/wxLCDBase.h | 1 + VirtualSDK/Controls/src/wxLCDBase.cpp | 9 +++++++++ VirtualSDK/Frame/src/LCDFrame.cpp | 1 + 6 files changed, 26 insertions(+), 15 deletions(-) diff --git a/GUI/inc/SGUI_RealtimeGraph.h b/GUI/inc/SGUI_RealtimeGraph.h index e676cab..cfaa084 100644 --- a/GUI/inc/SGUI_RealtimeGraph.h +++ b/GUI/inc/SGUI_RealtimeGraph.h @@ -11,11 +11,11 @@ //=======================================================================// typedef struct { - SGUI_INT yAxisMax; - SGUI_INT yAxisMin; - SGUI_BOOL EnableBaseline; + SGUI_INT yAxisMax; // Max value on screen display. + SGUI_INT yAxisMin; // Min value on screen display. + SGUI_BOOL EnableBaseline; // Enable to show zero-point line. SGUI_INT xAxisStepPixel; - SGUI_INT ValueArea; + SGUI_INT ValueArea; // Display value range, auto calculate when initialize. }SGUI_RTGRAPH_CONTROL; typedef struct @@ -23,8 +23,8 @@ typedef struct SGUI_INT ValueArray[SGUI_LCD_SIZE_WIDTH]; SGUI_INT LimitedValueArray[SGUI_LCD_SIZE_WIDTH]; SGUI_INT PointYCoordinateArray[SGUI_LCD_SIZE_WIDTH]; - SGUI_INT ZeroPointValue; - SGUI_INT ValueCount; + SGUI_INT BaseLineValue; // Base line value on graph map. + SGUI_INT ValueCount; // Display value point number, auto calculate when initialize. }SGUI_RTGRAPH_DATA; typedef struct diff --git a/GUI/src/SGUI_RealtimeGraph.c b/GUI/src/SGUI_RealtimeGraph.c index a3b8b59..b3ad313 100644 --- a/GUI/src/SGUI_RealtimeGraph.c +++ b/GUI/src/SGUI_RealtimeGraph.c @@ -71,20 +71,20 @@ void SGUI_RealtimeGraph_Initialize(SGUI_RTGRAPH* pstRTGraph) // Initialize graph data. //SGUI_Common_MemorySet(pstData, 0x00, sizeof(SGUI_RTGRAPH_DATA)); // Zero point value must NOT greater then yAxisMax and NOT less then yAxisMin. - if(pstData->ZeroPointValue > pstControl->yAxisMax) + if(pstData->BaseLineValue > pstControl->yAxisMax) { - pstData->ZeroPointValue = pstControl->yAxisMax; + pstData->BaseLineValue = pstControl->yAxisMax; } - if(pstData->ZeroPointValue < pstControl->yAxisMin) + if(pstData->BaseLineValue < pstControl->yAxisMin) { - pstData->ZeroPointValue = pstControl->yAxisMin; + pstData->BaseLineValue = pstControl->yAxisMin; } // Calculate the number of value points that can be used. pstData->ValueCount = (SGUI_LCD_SIZE_WIDTH-2)/pstControl->xAxisStepPixel; for(iValueIndex=0; iValueIndexValueCount; iValueIndex++) { - pstData->ValueArray[iValueIndex] = pstData->ZeroPointValue; - pstData->LimitedValueArray[iValueIndex] = pstData->ZeroPointValue; + pstData->ValueArray[iValueIndex] = pstData->BaseLineValue; + pstData->LimitedValueArray[iValueIndex] = pstData->BaseLineValue; pstData->PointYCoordinateArray[iValueIndex] = SGUI_RealtimeGraph_GetValuePointYCoordinate(pstRTGraph, pstData->LimitedValueArray[iValueIndex]); } } @@ -129,7 +129,7 @@ void SGUI_RealtimeGraph_Refresh(SGUI_SCR_DEV* pstIFObj, SGUI_RTGRAPH* pstRTGraph { if(SGUI_TRUE == pstControl->EnableBaseline) { - iBaseLineCoordinateY = SGUI_RealtimeGraph_GetValuePointYCoordinate(pstRTGraph, pstData->ZeroPointValue); + iBaseLineCoordinateY = SGUI_RealtimeGraph_GetValuePointYCoordinate(pstRTGraph, pstData->BaseLineValue); SGUI_Basic_DrawLine(pstIFObj, 1, iBaseLineCoordinateY, SGUI_LCD_SIZE_WIDTH-2, iBaseLineCoordinateY, SGUI_COLOR_FRGCLR); } diff --git a/VirtualSDK/Application/src/Application.cpp b/VirtualSDK/Application/src/Application.cpp index 2d2cbad..8e6d597 100644 --- a/VirtualSDK/Application/src/Application.cpp +++ b/VirtualSDK/Application/src/Application.cpp @@ -86,7 +86,7 @@ void Application::OnKeyDown(wxKeyEvent& clsEvent) /*----------------------------------*/ /* Process */ /*----------------------------------*/ - clsEvent.ResumePropagation(1); - clsEvent.Skip(); + //clsEvent.ResumePropagation(1); + //clsEvent.Skip(); } diff --git a/VirtualSDK/Controls/inc/wxLCDBase.h b/VirtualSDK/Controls/inc/wxLCDBase.h index 9987f18..07b4f01 100644 --- a/VirtualSDK/Controls/inc/wxLCDBase.h +++ b/VirtualSDK/Controls/inc/wxLCDBase.h @@ -66,6 +66,7 @@ class wxLCDBase virtual void OnPaint(wxPaintEvent &clsEvent); virtual void OnEraseBackGround(wxEraseEvent &clsEvent) {/* Do nothing. */} virtual void OnKeyDown(wxKeyEvent& clsEvent); + virtual void OnSetFocus(wxFocusEvent& clsEvent); virtual wxSize DoGetBestClientSize(void) const; public: diff --git a/VirtualSDK/Controls/src/wxLCDBase.cpp b/VirtualSDK/Controls/src/wxLCDBase.cpp index 3fbdffa..2b4acab 100644 --- a/VirtualSDK/Controls/src/wxLCDBase.cpp +++ b/VirtualSDK/Controls/src/wxLCDBase.cpp @@ -27,6 +27,7 @@ BEGIN_EVENT_TABLE(wxLCDBase,wxWindow) EVT_PAINT (wxLCDBase::OnPaint) EVT_ERASE_BACKGROUND (wxLCDBase::OnEraseBackGround) EVT_KEY_DOWN (wxLCDBase::OnKeyDown) + EVT_SET_FOCUS (wxLCDBase::OnSetFocus) END_EVENT_TABLE() //=======================================================================// @@ -358,6 +359,14 @@ void wxLCDBase::OnKeyDown(wxKeyEvent& clsEvent) clsEvent.Skip(); } +void wxLCDBase::OnSetFocus(wxFocusEvent& clsEvent) +{ + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + GetParent()->SetFocus(); + clsEvent.Skip(); +} void wxLCDBase::_drawPointSinglePixel(wxDC& clsDCObject, int iPosX, int iPosY, int iPixelSize) { /*----------------------------------*/ diff --git a/VirtualSDK/Frame/src/LCDFrame.cpp b/VirtualSDK/Frame/src/LCDFrame.cpp index f9e5d6e..9b5022c 100644 --- a/VirtualSDK/Frame/src/LCDFrame.cpp +++ b/VirtualSDK/Frame/src/LCDFrame.cpp @@ -220,6 +220,7 @@ void LCDFrame::OnKeyDown(wxKeyEvent& clsEvent) SGUI_SDK_SyncKeyEventData(uiKeyCode); SGUI_SDK_SetEvnetSyncFlag(ENV_FLAG_IDX_SDK_KEY_EVENT, true); + clsEvent.ResumePropagation(1); clsEvent.Skip(); }