1. wColour now accepts both grey and gray under MSW
2. implemented setting colours for rich edit controls git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_2_BRANCH@7702 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -127,6 +127,11 @@ public:
|
|||||||
#if wxUSE_RICHEDIT
|
#if wxUSE_RICHEDIT
|
||||||
bool IsRich() const { return m_isRich; }
|
bool IsRich() const { return m_isRich; }
|
||||||
void SetRichEdit(bool isRich) { m_isRich = isRich; }
|
void SetRichEdit(bool isRich) { m_isRich = isRich; }
|
||||||
|
|
||||||
|
// rich edit controls are not compatible with normal ones and wem ust set
|
||||||
|
// the colours for them otherwise
|
||||||
|
virtual bool SetBackgroundColour(const wxColour& colour);
|
||||||
|
virtual bool SetForegroundColour(const wxColour& colour);
|
||||||
#endif // wxUSE_RICHEDIT
|
#endif // wxUSE_RICHEDIT
|
||||||
|
|
||||||
virtual void AdoptAttributesFromHWND();
|
virtual void AdoptAttributesFromHWND();
|
||||||
|
@@ -136,18 +136,13 @@ wxColourDatabase::~wxColourDatabase ()
|
|||||||
// Colour database stuff
|
// Colour database stuff
|
||||||
void wxColourDatabase::Initialize ()
|
void wxColourDatabase::Initialize ()
|
||||||
{
|
{
|
||||||
// Don't initialize for X: colours are found
|
static const struct wxColourDesc
|
||||||
// in FindColour below.
|
{
|
||||||
// Added: Not all
|
const wxChar *name;
|
||||||
|
|
||||||
struct cdef {
|
|
||||||
wxChar *name;
|
|
||||||
int r,g,b;
|
int r,g,b;
|
||||||
};
|
}
|
||||||
cdef cc;
|
wxColourTable[] =
|
||||||
static cdef table[]={
|
{
|
||||||
|
|
||||||
// #ifdef __WXMSW__
|
|
||||||
{wxT("AQUAMARINE"),112, 219, 147},
|
{wxT("AQUAMARINE"),112, 219, 147},
|
||||||
{wxT("BLACK"),0, 0, 0},
|
{wxT("BLACK"),0, 0, 0},
|
||||||
{wxT("BLUE"), 0, 0, 255},
|
{wxT("BLUE"), 0, 0, 255},
|
||||||
@@ -219,23 +214,17 @@ void wxColourDatabase::Initialize ()
|
|||||||
{wxT("WHITE"), 255, 255, 255},
|
{wxT("WHITE"), 255, 255, 255},
|
||||||
{wxT("YELLOW"), 255, 255, 0},
|
{wxT("YELLOW"), 255, 255, 0},
|
||||||
{wxT("YELLOW GREEN"), 153, 204, 50},
|
{wxT("YELLOW GREEN"), 153, 204, 50},
|
||||||
// #endif
|
|
||||||
|
|
||||||
#if defined(__WXGTK__) || defined(__X__)
|
|
||||||
{wxT("MEDIUM GOLDENROD"), 234, 234, 173},
|
{wxT("MEDIUM GOLDENROD"), 234, 234, 173},
|
||||||
{wxT("MEDIUM FOREST GREEN"), 107, 142, 35},
|
{wxT("MEDIUM FOREST GREEN"), 107, 142, 35},
|
||||||
{wxT("LIGHT MAGENTA"), 255, 0, 255},
|
{wxT("LIGHT MAGENTA"), 255, 0, 255},
|
||||||
{wxT("MEDIUM GREY"), 100, 100, 100},
|
{wxT("MEDIUM GREY"), 100, 100, 100},
|
||||||
#endif
|
|
||||||
|
|
||||||
{0,0,0,0}
|
|
||||||
};
|
};
|
||||||
int i;
|
|
||||||
for (i=0;cc=table[i],cc.name!=0;i++)
|
|
||||||
{
|
|
||||||
Append(cc.name,new wxColour(cc.r,cc.g,cc.b));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
for ( size_t n = 0; n < WXSIZEOF(wxColourTable); n++ )
|
||||||
|
{
|
||||||
|
const wxColourDesc& cc = wxColourTable[n];
|
||||||
|
Append(cc.name, new wxColour(cc.r,cc.g,cc.b));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -249,32 +238,43 @@ void wxColourDatabase::Initialize ()
|
|||||||
|
|
||||||
wxColour *wxColourDatabase::FindColour(const wxString& colour)
|
wxColour *wxColourDatabase::FindColour(const wxString& colour)
|
||||||
{
|
{
|
||||||
// VZ: make the comparaison case insensitive
|
// VZ: make the comparaison case insensitive and also match both grey and
|
||||||
wxString str = colour;
|
// gray
|
||||||
str.MakeUpper();
|
wxString col = colour;
|
||||||
|
col.MakeUpper();
|
||||||
|
wxString col2 = col;
|
||||||
|
if ( !col2.Replace(_T("GRAY"), _T("GREY")) )
|
||||||
|
col2.clear();
|
||||||
|
|
||||||
wxNode *node = Find(str);
|
wxNode *node = First();
|
||||||
if (node)
|
while ( node )
|
||||||
|
{
|
||||||
|
const wxChar *key = node->GetKeyString();
|
||||||
|
if ( col == key || col2 == key )
|
||||||
|
{
|
||||||
return (wxColour *)node->Data();
|
return (wxColour *)node->Data();
|
||||||
|
}
|
||||||
|
|
||||||
|
node = node->Next();
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef __WXMSW__
|
#ifdef __WXMSW__
|
||||||
else return NULL;
|
return NULL;
|
||||||
#endif
|
#endif
|
||||||
#ifdef __WXPM__
|
#ifdef __WXPM__
|
||||||
else return NULL;
|
return NULL;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// TODO for other implementations. This should really go into
|
// TODO for other implementations. This should really go into
|
||||||
// platform-specific directories.
|
// platform-specific directories.
|
||||||
#ifdef __WXMAC__
|
#ifdef __WXMAC__
|
||||||
else return NULL;
|
return NULL;
|
||||||
#endif
|
#endif
|
||||||
#ifdef __WXSTUBS__
|
#ifdef __WXSTUBS__
|
||||||
else return NULL;
|
return NULL;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __WXGTK__
|
#ifdef __WXGTK__
|
||||||
else {
|
|
||||||
wxColour *col = new wxColour( colour );
|
wxColour *col = new wxColour( colour );
|
||||||
|
|
||||||
if (!(col->Ok())) {
|
if (!(col->Ok())) {
|
||||||
@@ -283,11 +283,9 @@ wxColour *wxColourDatabase::FindColour(const wxString& colour)
|
|||||||
}
|
}
|
||||||
Append( colour, col );
|
Append( colour, col );
|
||||||
return col;
|
return col;
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __X__
|
#ifdef __X__
|
||||||
else {
|
|
||||||
XColor xcolour;
|
XColor xcolour;
|
||||||
|
|
||||||
#ifdef __WXMOTIF__
|
#ifdef __WXMOTIF__
|
||||||
@@ -311,8 +309,7 @@ wxColour *wxColourDatabase::FindColour(const wxString& colour)
|
|||||||
Append(colour, col);
|
Append(colour, col);
|
||||||
|
|
||||||
return col;
|
return col;
|
||||||
}
|
#endif // __X__
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString wxColourDatabase::FindName (const wxColour& colour) const
|
wxString wxColourDatabase::FindName (const wxColour& colour) const
|
||||||
|
@@ -1135,6 +1135,54 @@ void wxTextCtrl::OnUpdateRedo(wxUpdateUIEvent& event)
|
|||||||
event.Enable( CanRedo() );
|
event.Enable( CanRedo() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// colour setting for the rich edit controls
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#if wxUSE_RICHEDIT
|
||||||
|
|
||||||
|
bool wxTextCtrl::SetBackgroundColour(const wxColour& colour)
|
||||||
|
{
|
||||||
|
if ( !wxTextCtrlBase::SetBackgroundColour(colour) )
|
||||||
|
{
|
||||||
|
// colour didn't really change
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( IsRich() )
|
||||||
|
{
|
||||||
|
// rich edit doesn't use WM_CTLCOLOR, hence we need to send
|
||||||
|
// EM_SETBKGNDCOLOR additionally
|
||||||
|
::SendMessage(GetHwnd(), EM_SETBKGNDCOLOR, 0, wxColourToRGB(colour));
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxTextCtrl::SetForegroundColour(const wxColour& colour)
|
||||||
|
{
|
||||||
|
if ( !wxTextCtrlBase::SetForegroundColour(colour) )
|
||||||
|
{
|
||||||
|
// colour didn't really change
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( IsRich() )
|
||||||
|
{
|
||||||
|
// change the colour of everything
|
||||||
|
CHARFORMAT cf;
|
||||||
|
wxZeroMemory(cf);
|
||||||
|
cf.cbSize = sizeof(cf);
|
||||||
|
cf.dwMask = CFM_COLOR;
|
||||||
|
cf.crTextColor = wxColourToRGB(colour);
|
||||||
|
::SendMessage(GetHwnd(), EM_SETCHARFORMAT, SCF_ALL, (LPARAM)&cf);
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // wxUSE_RICHEDIT
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// wxRichEditModule
|
// wxRichEditModule
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
Reference in New Issue
Block a user