Patch #3312 2012-08-06 02:55

ollydbg

wxsmith angular meter refine
Download
3312-wxsmith_angula.patch (14.5 KB)
Category
Plugin::Refinement
Status
Accepted
Close date
2012-12-21 07:42
Assigned to
ollydbg
Index: include/wx/KWIC/AngularMeter.h
===================================================================
--- include/wx/KWIC/AngularMeter.h    (revision 8190)
+++ include/wx/KWIC/AngularMeter.h    (working copy)
@@ -11,6 +11,7 @@
 //
 /////////////////////////////////////////////////////////////////////////////
 
+#include <wx/dcmemory.h>
 
 #define MAXSECTORCOLOR 10
 
@@ -19,27 +20,28 @@
 public:
     kwxAngularMeter(wxWindow *parent, const wxWindowID id = -1, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize);
     kwxAngularMeter(){};
+
     virtual ~kwxAngularMeter();
-    bool Create(wxWindow* parent, const wxWindowID id, const wxPoint& pos, const wxSize& size);
-
     void SetSectorColor(int nSector, wxColour colour) ;
-    void SetNumSectors(int nSector) { m_nSec = nSector ; };
-    void SetNumTick(int nTick) { m_nTick = nTick ; };
-    void SetRange(int min, int max) { m_nRangeStart = min ; m_nRangeEnd = max ; } ;
-    void SetAngle(int min, int max) { m_nAngleStart = min ; m_nAngleEnd = max ; } ;
+    void SetNumSectors(int nSector) { m_nSec = nSector ; m_bNeedRedrawBackground = true;};
+    void SetNumTick(int nTick) { m_nTick = nTick ; m_bNeedRedrawBackground = true;};
+    void SetRange(int min, int max) { m_nRangeStart = min ; m_nRangeEnd = max ; m_bNeedRedrawBackground = true;} ;
+    void SetAngle(int min, int max) { m_nAngleStart = min ; m_nAngleEnd = max ; m_bNeedRedrawBackground = true;} ;
     void SetValue(int val);
     void SetNeedleColour(wxColour colour) { m_cNeedleColour = colour ; } ;
-    void SetBackColour(wxColour colour) { m_cBackColour = colour ; } ;
+    void SetBackColour(wxColour colour) { m_cBackColour = colour ; m_bNeedRedrawBackground = true;} ;
     void SetBorderColour(wxColour colour) { m_cBorderColour = colour ; } ;
     void SetTxtFont(wxFont &font) { m_Font = font ; } ;
     void DrawCurrent(bool state) { m_bDrawCurrent = state ; } ;
+    void ConstructBackground();
 
 
 private:
     // any class wishing to process wxWindows events must use this macro
     DECLARE_EVENT_TABLE()
 
-    void OnPaint(wxPaintEvent& event);
+    void    OnPaint(wxPaintEvent& event);
+    void    OnEraseBackGround(wxEraseEvent& event) {};
     void    DrawTicks(wxDC &dc) ;
     void    DrawNeedle(wxDC &dc) ;
     void    DrawSectors(wxDC &dc) ;
@@ -65,4 +67,10 @@
     wxColour m_cBorderColour ;
 
     wxBitmap  *m_pPreviewBmp ;
+
+    wxMemoryDC m_BackgroundDc;
+
+    bool m_bNeedRedrawBackground;
+
+
 };
Index: src/wx/KWIC/AngularMeter.cpp
===================================================================
--- src/wx/KWIC/AngularMeter.cpp    (revision 8190)
+++ src/wx/KWIC/AngularMeter.cpp    (working copy)
@@ -27,50 +27,94 @@
 #include <wx/event.h>
 
 
+//IMPLEMENT_DYNAMIC_CLASS(kwxAngularMeter, wxWindow)
+
 BEGIN_EVENT_TABLE(kwxAngularMeter,wxWindow)
     EVT_PAINT(kwxAngularMeter::OnPaint)
+    EVT_ERASE_BACKGROUND(kwxAngularMeter::OnEraseBackGround)
 END_EVENT_TABLE()
 
 kwxAngularMeter::kwxAngularMeter(wxWindow* parent, const wxWindowID id, const wxPoint& pos, const wxSize& size)
+    : wxWindow(parent, id, pos, size, 0)
 {
-    Create(parent, id, pos, size);
-}
 
-bool kwxAngularMeter::Create(wxWindow* parent, const wxWindowID id, const wxPoint& pos, const wxSize& size)
-{
-    if(!wxWindow::Create(parent, id, pos, size))
-        return false;
+  if (parent)
+    SetBackgroundColour(parent->GetBackgroundColour());
+  else
+    SetBackgroundColour(*wxLIGHT_GREY);
 
-    if (parent)
-        SetBackgroundColour(parent->GetBackgroundColour());
-    else
-        SetBackgroundColour(*wxLIGHT_GREY);
-
+    //SetSize(size);
     SetAutoLayout(TRUE);
     Refresh();
 
     m_id = id;
 
-    //valori di default
+    //Default values
 
-    m_nScaledVal = 0;        //gradi
+    m_nScaledVal = 0;        //degrees
     m_nRealVal = 0;
-    m_nTick = 0;    //numero tacche
-    m_nSec = 1;        //default numero settori
+    m_nTick = 0;    //number of notches
+    m_nSec = 1;        //default number of sectors
     m_nRangeStart = 0;
     m_nRangeEnd = 220;
     m_nAngleStart = -20;
     m_nAngleEnd = 200;
     m_aSectorColor[0] = *wxWHITE;
-    m_cBackColour = GetBackgroundColour() ;        //default sfondo applicazione
-    m_cNeedleColour = *wxRED;    //indicatore
+//    m_cBackColour = *wxLIGHT_GREY;
+    m_cBackColour = GetBackgroundColour() ;        //default background application
+    m_cNeedleColour = *wxRED;    //indicator
     m_cBorderColour = GetBackgroundColour() ;
     m_dPI = 4.0 * atan(1.0);
     m_Font = *wxSWISS_FONT;    //font
     m_bDrawCurrent = true ;
 
-    membitmap = new wxBitmap(size.GetWidth(), size.GetHeight());
-    return true;
+    membitmap = new wxBitmap(size.GetWidth(), size.GetHeight()) ;
+
+    m_BackgroundDc.SelectObject(*membitmap);
+    m_BackgroundDc.SetBackground(parent->GetBackgroundColour());
+    m_BackgroundDc.Clear();
+    m_BackgroundDc.SetPen(*wxRED_PEN);
+    //m_BackgroundDc.SetBrush(*wxTRANSPARENT_BRUSH);
+    m
download for full patch...
ollydbg 2012-08-06 03:02

I just change the code for some reasons:

1, buffered background display, this can improve the drawing a bit

2, adjust the tick and label positions, the old code did not calculate the position correctly.

I have contact the author of KWIC, they replied that they has no time to maintain it since 2007, so I think we can made change to our c::b trunk?

BTW: this is the screen shot:

http://i683.photobucket.com/albums/vv194/ollydbg_cb/2012-08-06105743.png

mortenmacfly 2012-08-07 16:01

...will give it a try...

(Also assigned it to you. ;-))

ollydbg 2012-10-24 06:40

@morten: I see you have apply the patch in rev8472. Thanks.