From 393c836c338dc917290ac5c626b5ed24a075d3e9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Fri, 4 Jun 2004 16:03:03 +0000 Subject: [PATCH] changed wxColourData default palette to NULL colours instead of white git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@27628 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/latex/wx/colordlg.tex | 6 +++++- docs/latex/wx/colour.tex | 7 ++++--- src/common/cmndata.cpp | 14 +++++--------- src/msw/colordlg.cpp | 7 ++++++- 4 files changed, 20 insertions(+), 14 deletions(-) diff --git a/docs/latex/wx/colordlg.tex b/docs/latex/wx/colordlg.tex index f7f00a9b4b..62d8caa191 100644 --- a/docs/latex/wx/colordlg.tex +++ b/docs/latex/wx/colordlg.tex @@ -27,7 +27,11 @@ This class represents the colour chooser dialog. \func{}{wxColourDialog}{\param{wxWindow* }{parent}, \param{wxColourData* }{data = NULL}} Constructor. Pass a parent window, and optionally a pointer to a block of colour -data, which will be copied to the colour dialog's colour data. +data, which will be copied to the colour dialog's colour data. Custom +colours from colour data object will be be used in dialog's colour palette. +Invalid entries in custom colours list will be ignored on some platforms (GTK) +or replaced with white colour on platforms where custom colours palette has +fixed size (MSW). \wxheading{See also} diff --git a/docs/latex/wx/colour.tex b/docs/latex/wx/colour.tex index 95b359d281..67ac7fc45c 100644 --- a/docs/latex/wx/colour.tex +++ b/docs/latex/wx/colour.tex @@ -181,7 +181,8 @@ This class holds a variety of information related to colour dialogs. \func{}{wxColourData}{\void} -Constructor. Initializes the custom colours to white, the {\it data colour} setting +Constructor. Initializes the custom colours to {\tt wxNullColour}, +the {\it data colour} setting to black, and the {\it choose full} setting to true. @@ -218,7 +219,7 @@ The default colour is black. Gets the {\it i}th custom colour associated with the colour dialog. {\it i} should be an integer between 0 and 15. -The default custom colours are all white. +The default custom colours are invalid colours. \membersection{wxColourData::SetChooseFull}\label{wxcolourdatasetchoosefull} @@ -247,7 +248,7 @@ The default colour is black. Sets the {\it i}th custom colour for the colour dialog. {\it i} should be an integer between 0 and 15. -The default custom colours are all white. +The default custom colours are invalid colours. \membersection{wxColourData::operator $=$}\label{wxcolourdataassign} diff --git a/src/common/cmndata.cpp b/src/common/cmndata.cpp index c5a4472437..9264f0e48f 100644 --- a/src/common/cmndata.cpp +++ b/src/common/cmndata.cpp @@ -88,12 +88,9 @@ wxColourData::wxColourData() { - int i; - for (i = 0; i < 16; i++) - m_custColours[i].Set(255, 255, 255); - - m_chooseFull = FALSE; + m_chooseFull = false; m_dataColour.Set(0,0,0); + // m_custColours are wxNullColours initially } wxColourData::wxColourData(const wxColourData& data) @@ -108,16 +105,15 @@ wxColourData::~wxColourData() void wxColourData::SetCustomColour(int i, const wxColour& colour) { - if (i > 15 || i < 0) - return; + wxCHECK_RET( (i >= 0 && i < 16), _T("custom colour index out of range") ); m_custColours[i] = colour; } wxColour wxColourData::GetCustomColour(int i) { - if (i > 15 || i < 0) - return wxColour(0,0,0); + wxCHECK_MSG( (i >= 0 && i < 16), wxColour(0,0,0), + _T("custom colour index out of range") ); return m_custColours[i]; } diff --git a/src/msw/colordlg.cpp b/src/msw/colordlg.cpp index 53eed0cca9..92036a89af 100644 --- a/src/msw/colordlg.cpp +++ b/src/msw/colordlg.cpp @@ -128,7 +128,12 @@ int wxColourDialog::ShowModal() int i; for (i = 0; i < 16; i++) - custColours[i] = wxColourToRGB(m_colourData.m_custColours[i]); + { + if (m_colourData.m_custColours[i].Ok()) + custColours[i] = wxColourToRGB(m_colourData.m_custColours[i]); + else + custColours[i] = RGB(255,255,255); + } chooseColorStruct.lStructSize = sizeof(CHOOSECOLOR); if ( m_parent ) -- 2.45.2