/* Copyright (C) 2013-2020, Dirk Krause SPDX-License-Identifier: BSD-3-Clause */ /* WARNING: This file was generated by the dkct program (see http://dktools.sourceforge.net/ for details). Changes you make here will be lost if dkct is run again! You should modify the original source and run dkct on it. Original source: DkWxBufferedControl.cpt */ /** @file DkWxBufferedControl.cpp The DkWxBufferedControl module. */ #line 196 "DkWxBufferedControl.cpt" #include "dk3conf.h" #include "DkWxBufferedControl.h" #line 203 "DkWxBufferedControl.cpt" wxChar const DkWxBufferedControl::DkWxBufferedControlName[] = { wxT("DkWxBufferedControl") }; #if wxCHECK_VERSION(3,0,0) wxIMPLEMENT_DYNAMIC_CLASS(DkWxBufferedControl, wxControl); #else IMPLEMENT_DYNAMIC_CLASS(DkWxBufferedControl, wxControl) #endif #if wxCHECK_VERSION(3,0,0) wxBEGIN_EVENT_TABLE(DkWxBufferedControl,wxControl) #else BEGIN_EVENT_TABLE(DkWxBufferedControl,wxControl) #endif EVT_ERASE_BACKGROUND(DkWxBufferedControl::OnErase) EVT_PAINT(DkWxBufferedControl::OnPaint) #if wxCHECK_VERSION(3,0,0) wxEND_EVENT_TABLE() #else END_EVENT_TABLE() #endif DkWxBufferedControl::DkWxBufferedControl() { #line 237 "DkWxBufferedControl.cpt" pBitmap = NULL; iWidth = -1; iHeight = -1; bMustDraw = true; SetBackgroundStyle(wxBG_STYLE_CUSTOM); #line 243 "DkWxBufferedControl.cpt" } bool DkWxBufferedControl::Create( wxWindow *pParent, wxWindowID wid, const wxPoint & pos, const wxSize & size, long style, const wxValidator & validator, wxChar const *name ) { bool back; back = wxControl::Create( pParent, wid, pos, size, style, validator, wxString(name) ); pBitmap = NULL; iWidth = -1; iHeight = -1; bMustDraw = true; SetBackgroundStyle(wxBG_STYLE_CUSTOM); return back; } DkWxBufferedControl::DkWxBufferedControl( wxWindow *pParent, wxWindowID wid, const wxPoint & pos, const wxSize & size, long style, const wxValidator & validator, wxChar const *name ) : wxControl( pParent, wid, pos, size, style, validator, wxString(name) ) { #line 292 "DkWxBufferedControl.cpt" pBitmap = NULL; iWidth = -1; iHeight = -1; bMustDraw = true; SetBackgroundStyle(wxBG_STYLE_CUSTOM); #line 298 "DkWxBufferedControl.cpt" } DkWxBufferedControl::~DkWxBufferedControl() { #line 305 "DkWxBufferedControl.cpt" { wxMutexLocker lock(mxProtectData); if(NULL != pBitmap) { #line 308 "DkWxBufferedControl.cpt" delete(pBitmap); pBitmap = NULL; } iWidth = -1; iHeight = -1; bMustDraw = false; } #line 316 "DkWxBufferedControl.cpt" } void DkWxBufferedControl::OnErase(wxEraseEvent & WXUNUSED(event)) { #line 324 "DkWxBufferedControl.cpt" /* Do nothing here. */ #line 326 "DkWxBufferedControl.cpt" } void DkWxBufferedControl::OnPaint(wxPaintEvent & event) { bool mustdraw = false; bool done = false; int w = 0; int h = 0; #line 338 "DkWxBufferedControl.cpt" wxPaintDC paintDC(this); { wxMutexLocker lock(mxProtectData); #if VERSION_BEFORE_20150821 w = iWidth; h = iHeight; #endif wxSize sz = GetClientSize(); if(NULL != pBitmap) { if((iWidth != sz.x) || (iHeight != sz.y)) { delete(pBitmap); #line 349 "DkWxBufferedControl.cpt" pBitmap = NULL; mustdraw = true; #line 351 "DkWxBufferedControl.cpt" } } w = iWidth = sz.x; h = iHeight = sz.y; if(NULL == pBitmap) { #line 355 "DkWxBufferedControl.cpt" pBitmap = new wxBitmap(iWidth, iHeight); mustdraw = true; #line 357 "DkWxBufferedControl.cpt" } if(NULL != pBitmap) { #line 359 "DkWxBufferedControl.cpt" if(false == mustdraw) { if(bMustDraw) { #line 361 "DkWxBufferedControl.cpt" mustdraw = true; } } if(mustdraw) { #line 365 "DkWxBufferedControl.cpt" wxMemoryDC memDC; memDC.SelectObject(*pBitmap); InternalPaint(memDC, event, true, w, h); memDC.SelectObject(wxNullBitmap); bMustDraw = false; #line 370 "DkWxBufferedControl.cpt" } else { #line 371 "DkWxBufferedControl.cpt" } paintDC.DrawBitmap(*pBitmap, 0, 0, false); done = true; } } if(!(done)) { #line 377 "DkWxBufferedControl.cpt" InternalPaint(paintDC, event, false, w, h); } #line 379 "DkWxBufferedControl.cpt" } void DkWxBufferedControl::PaintOperation( wxDC & WXUNUSED(pdc), wxPaintEvent & WXUNUSED(event), bool WXUNUSED(buffered), int WXUNUSED(clWidth), int WXUNUSED(clHeight) ) { /* The default implementation intentionally does nothing. */ } void DkWxBufferedControl::InternalPaint( wxDC & pdc, wxPaintEvent & event, bool buffered, int clWidth, int clHeight ) { wxBrush const br = pdc.GetBrush(); wxBrush const bg = pdc.GetBackground(); wxFont const fn = pdc.GetFont(); wxPen const pn = pdc.GetPen(); wxColour const tbg = pdc.GetTextBackground(); wxColour const tfg = pdc.GetTextForeground(); int bgm = pdc.GetBackgroundMode(); #line 414 "DkWxBufferedControl.cpt" PaintOperation(pdc, event, buffered, clWidth, clHeight); pdc.SetBackgroundMode(bgm); pdc.SetTextForeground(tfg); pdc.SetTextBackground(tbg); pdc.SetPen(pn); pdc.SetFont(fn); pdc.SetBackground(bg); pdc.SetBrush(br); #line 424 "DkWxBufferedControl.cpt" } void DkWxBufferedControl::SetMustUpdate(bool flag) { #line 432 "DkWxBufferedControl.cpt" { wxMutexLocker lock(mxProtectData); bMustDraw = flag; } #line 437 "DkWxBufferedControl.cpt" } void DkWxBufferedControl::releaseBuffer(void) { #line 445 "DkWxBufferedControl.cpt" { wxMutexLocker lock(mxProtectData); if(pBitmap) { #line 448 "DkWxBufferedControl.cpt" delete(pBitmap); pBitmap = NULL; } } #line 452 "DkWxBufferedControl.cpt" }