/* Copyright (C) 2011-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: DkWxColorView.cpt */ /** @file DkWxColorView.cpp The DkWxColorView module. */ #line 195 "DkWxColorView.cpt" #include "dk3conf.h" #include "DkWxColorView.h" #include #include #line 205 "DkWxColorView.cpt" #if wxCHECK_VERSION(3,0,0) wxBEGIN_EVENT_TABLE(DkWxColorView, wxControl) #else BEGIN_EVENT_TABLE(DkWxColorView, wxControl) #endif EVT_ERASE_BACKGROUND(DkWxColorView::OnErase) EVT_PAINT(DkWxColorView::OnPaint) EVT_LEFT_DOWN(DkWxColorView::OnLeftMouseButtonDown) #if wxCHECK_VERSION(3,0,0) wxEND_EVENT_TABLE() #else END_EVENT_TABLE() #endif #if wxCHECK_VERSION(3,0,0) wxIMPLEMENT_DYNAMIC_CLASS(DkWxColorView, wxControl); #else IMPLEMENT_DYNAMIC_CLASS(DkWxColorView, wxControl) #endif wxChar const DkWxColorView::DkWxColorViewName[] = { wxT("DkWxColorView") } ; DkWxColorView::DkWxColorView() { pParentWindow = NULL; pHelper = NULL; w = -1; h = -1; r = 255; g = 255; b = 255; ccdx = -1; ccdy = -1; } DkWxColorView::DkWxColorView( wxWindow *pParent, wxWindowID wxid, DkWxAppHelper *appHelper, int red, int green, int blue, wxPoint const & pos, wxSize const & size, long style, wxChar const *name ) : wxControl( pParent, wxid, pos, size, style, wxDefaultValidator, wxString(name) ) { pParentWindow = pParent; pHelper = appHelper; w = size.x; h = size.y; r = red; g = green; b = blue; ccdx = -1; ccdy = -1; } bool DkWxColorView::Create( wxWindow *pParent, wxWindowID wxid, DkWxAppHelper *appHelper, int red, int green, int blue, wxPoint const & pos, wxSize const & size, long style, wxChar const *name ) { bool back; back = wxControl::Create( pParent, wxid, pos, size, style, wxDefaultValidator, wxString(name) ); pParentWindow = pParent; pHelper = appHelper; w = size.x; h = size.y; r = red; g = green; b = blue; return back; } wxSize DkWxColorView::DoGetBestSize() const { wxSize back(((-1 < w) ? w : 20), ((-1 < h) ? h : 20)); return back; } void DkWxColorView::OnErase(wxEraseEvent & WXUNUSED(event)) { } void DkWxColorView::OnPaint(wxPaintEvent & WXUNUSED(event)) { wxBufferedPaintDC useDC(this); wxSize sz = GetClientSize(); wxColour mycolor(r, g, b); #if wxCHECK_VERSION(3,0,0) wxBrush myBrush(mycolor, wxBRUSHSTYLE_SOLID); #else wxBrush myBrush(mycolor, wxSOLID); #endif const wxBrush oldBrush = useDC.GetBrush(); useDC.SetBrush(myBrush); useDC.DrawRectangle(0, 0, sz.GetWidth(), sz.GetHeight()); useDC.SetBrush(wxNullBrush); } void DkWxColorView::OnLeftMouseButtonDown(wxMouseEvent & WXUNUSED(event)) { #line 351 "DkWxColorView.cpt" wxColourDialog dlg(this); if(pParentWindow) { if(pHelper) { #line 354 "DkWxColorView.cpt" pHelper->setRelatedPosition(pParentWindow, &dlg, &ccdx, &ccdy); } } if(dlg.ShowModal() == wxID_OK) { wxColour col = dlg.GetColourData().GetColour(); r = col.Red(); g = col.Green(); b = col.Blue(); dlg.GetPosition(&ccdx, &ccdy); Refresh(); Update(); } else { dlg.GetPosition(&ccdx, &ccdy); } #line 369 "DkWxColorView.cpt" } int DkWxColorView::getRed() const { return r; } int DkWxColorView::getGreen() const { return g; } int DkWxColorView::getBlue() const { return b; } void DkWxColorView::setRGB(int red, int green, int blue) { r = red; g = green; b = blue; if(r < 0) r = 0; if(g < 0) g = 0; if(b < 0) b = 0; if(r > 255) r = 255; if(g > 255) g = 255; if(b > 255) b = 255; }