Add opacity control feature to wxColourData.

Added internal flag (with corresponding accessors) which purpose is to enable/disable modifying the opacity of the colours in colour dialogs.
This commit is contained in:
Artur Wieczorek 2015-10-27 10:02:51 +01:00
parent 3dc013920b
commit 809a07a65d
2 changed files with 18 additions and 0 deletions

View File

@ -26,6 +26,8 @@ public:
void SetChooseFull(bool flag) { m_chooseFull = flag; }
bool GetChooseFull() const { return m_chooseFull; }
void SetChooseAlpha(bool flag) { m_chooseAlpha = flag; }
bool GetChooseAlpha() const { return m_chooseAlpha; }
void SetColour(const wxColour& colour) { m_dataColour = colour; }
const wxColour& GetColour() const { return m_dataColour; }
wxColour& GetColour() { return m_dataColour; }
@ -45,6 +47,9 @@ public:
wxColour m_custColours[NUM_CUSTOM];
bool m_chooseFull;
protected:
bool m_chooseAlpha;
wxDECLARE_DYNAMIC_CLASS(wxColourData);
};

View File

@ -25,6 +25,7 @@ wxIMPLEMENT_DYNAMIC_CLASS(wxColourData, wxObject);
wxColourData::wxColourData()
{
m_chooseFull = false;
m_chooseAlpha = false;
m_dataColour.Set(0,0,0);
// m_custColours are wxNullColours initially
}
@ -61,6 +62,7 @@ wxColourData& wxColourData::operator=(const wxColourData& data)
m_dataColour = data.m_dataColour;
m_chooseFull = data.m_chooseFull;
m_chooseAlpha = data.m_chooseAlpha;
return *this;
}
@ -85,6 +87,9 @@ wxString wxColourData::ToString() const
str += clr.GetAsString(wxC2S_HTML_SYNTAX);
}
str.Append(wxCOL_DATA_SEP);
str.Append(m_chooseAlpha ? '1' : '0');
return str;
}
@ -102,6 +107,14 @@ bool wxColourData::FromString(const wxString& str)
else
success = m_custColours[i].Set(token);
}
if ( success )
{
token = tokenizer.GetNextToken();
m_chooseAlpha = token == wxS("1");
success = m_chooseAlpha || token == wxS("0");
}
return success;
}