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,106 +136,95 @@ 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;
|
||||||
|
int r,g,b;
|
||||||
|
}
|
||||||
|
wxColourTable[] =
|
||||||
|
{
|
||||||
|
{wxT("AQUAMARINE"),112, 219, 147},
|
||||||
|
{wxT("BLACK"),0, 0, 0},
|
||||||
|
{wxT("BLUE"), 0, 0, 255},
|
||||||
|
{wxT("BLUE VIOLET"), 159, 95, 159},
|
||||||
|
{wxT("BROWN"), 165, 42, 42},
|
||||||
|
{wxT("CADET BLUE"), 95, 159, 159},
|
||||||
|
{wxT("CORAL"), 255, 127, 0},
|
||||||
|
{wxT("CORNFLOWER BLUE"), 66, 66, 111},
|
||||||
|
{wxT("CYAN"), 0, 255, 255},
|
||||||
|
{wxT("DARK GREY"), 47, 47, 47}, // ?
|
||||||
|
|
||||||
struct cdef {
|
{wxT("DARK GREEN"), 47, 79, 47},
|
||||||
wxChar *name;
|
{wxT("DARK OLIVE GREEN"), 79, 79, 47},
|
||||||
int r,g,b;
|
{wxT("DARK ORCHID"), 153, 50, 204},
|
||||||
};
|
{wxT("DARK SLATE BLUE"), 107, 35, 142},
|
||||||
cdef cc;
|
{wxT("DARK SLATE GREY"), 47, 79, 79},
|
||||||
static cdef table[]={
|
{wxT("DARK TURQUOISE"), 112, 147, 219},
|
||||||
|
{wxT("DIM GREY"), 84, 84, 84},
|
||||||
// #ifdef __WXMSW__
|
{wxT("FIREBRICK"), 142, 35, 35},
|
||||||
{wxT("AQUAMARINE"),112, 219, 147},
|
{wxT("FOREST GREEN"), 35, 142, 35},
|
||||||
{wxT("BLACK"),0, 0, 0},
|
{wxT("GOLD"), 204, 127, 50},
|
||||||
{wxT("BLUE"), 0, 0, 255},
|
{wxT("GOLDENROD"), 219, 219, 112},
|
||||||
{wxT("BLUE VIOLET"), 159, 95, 159},
|
{wxT("GREY"), 128, 128, 128},
|
||||||
{wxT("BROWN"), 165, 42, 42},
|
{wxT("GREEN"), 0, 255, 0},
|
||||||
{wxT("CADET BLUE"), 95, 159, 159},
|
{wxT("GREEN YELLOW"), 147, 219, 112},
|
||||||
{wxT("CORAL"), 255, 127, 0},
|
{wxT("INDIAN RED"), 79, 47, 47},
|
||||||
{wxT("CORNFLOWER BLUE"), 66, 66, 111},
|
{wxT("KHAKI"), 159, 159, 95},
|
||||||
{wxT("CYAN"), 0, 255, 255},
|
{wxT("LIGHT BLUE"), 191, 216, 216},
|
||||||
{wxT("DARK GREY"), 47, 47, 47}, // ?
|
{wxT("LIGHT GREY"), 192, 192, 192},
|
||||||
|
{wxT("LIGHT STEEL BLUE"), 143, 143, 188},
|
||||||
{wxT("DARK GREEN"), 47, 79, 47},
|
{wxT("LIME GREEN"), 50, 204, 50},
|
||||||
{wxT("DARK OLIVE GREEN"), 79, 79, 47},
|
{wxT("LIGHT MAGENTA"), 255, 0, 255},
|
||||||
{wxT("DARK ORCHID"), 153, 50, 204},
|
{wxT("MAGENTA"), 255, 0, 255},
|
||||||
{wxT("DARK SLATE BLUE"), 107, 35, 142},
|
{wxT("MAROON"), 142, 35, 107},
|
||||||
{wxT("DARK SLATE GREY"), 47, 79, 79},
|
{wxT("MEDIUM AQUAMARINE"), 50, 204, 153},
|
||||||
{wxT("DARK TURQUOISE"), 112, 147, 219},
|
{wxT("MEDIUM GREY"), 100, 100, 100},
|
||||||
{wxT("DIM GREY"), 84, 84, 84},
|
{wxT("MEDIUM BLUE"), 50, 50, 204},
|
||||||
{wxT("FIREBRICK"), 142, 35, 35},
|
{wxT("MEDIUM FOREST GREEN"), 107, 142, 35},
|
||||||
{wxT("FOREST GREEN"), 35, 142, 35},
|
{wxT("MEDIUM GOLDENROD"), 234, 234, 173},
|
||||||
{wxT("GOLD"), 204, 127, 50},
|
{wxT("MEDIUM ORCHID"), 147, 112, 219},
|
||||||
{wxT("GOLDENROD"), 219, 219, 112},
|
{wxT("MEDIUM SEA GREEN"), 66, 111, 66},
|
||||||
{wxT("GREY"), 128, 128, 128},
|
{wxT("MEDIUM SLATE BLUE"), 127, 0, 255},
|
||||||
{wxT("GREEN"), 0, 255, 0},
|
{wxT("MEDIUM SPRING GREEN"), 127, 255, 0},
|
||||||
{wxT("GREEN YELLOW"), 147, 219, 112},
|
{wxT("MEDIUM TURQUOISE"), 112, 219, 219},
|
||||||
{wxT("INDIAN RED"), 79, 47, 47},
|
{wxT("MEDIUM VIOLET RED"), 219, 112, 147},
|
||||||
{wxT("KHAKI"), 159, 159, 95},
|
{wxT("MIDNIGHT BLUE"), 47, 47, 79},
|
||||||
{wxT("LIGHT BLUE"), 191, 216, 216},
|
{wxT("NAVY"), 35, 35, 142},
|
||||||
{wxT("LIGHT GREY"), 192, 192, 192},
|
{wxT("ORANGE"), 204, 50, 50},
|
||||||
{wxT("LIGHT STEEL BLUE"), 143, 143, 188},
|
{wxT("ORANGE RED"), 255, 0, 127},
|
||||||
{wxT("LIME GREEN"), 50, 204, 50},
|
{wxT("ORCHID"), 219, 112, 219},
|
||||||
{wxT("LIGHT MAGENTA"), 255, 0, 255},
|
{wxT("PALE GREEN"), 143, 188, 143},
|
||||||
{wxT("MAGENTA"), 255, 0, 255},
|
{wxT("PINK"), 188, 143, 234},
|
||||||
{wxT("MAROON"), 142, 35, 107},
|
{wxT("PLUM"), 234, 173, 234},
|
||||||
{wxT("MEDIUM AQUAMARINE"), 50, 204, 153},
|
{wxT("PURPLE"), 176, 0, 255},
|
||||||
{wxT("MEDIUM GREY"), 100, 100, 100},
|
{wxT("RED"), 255, 0, 0},
|
||||||
{wxT("MEDIUM BLUE"), 50, 50, 204},
|
{wxT("SALMON"), 111, 66, 66},
|
||||||
{wxT("MEDIUM FOREST GREEN"), 107, 142, 35},
|
{wxT("SEA GREEN"), 35, 142, 107},
|
||||||
{wxT("MEDIUM GOLDENROD"), 234, 234, 173},
|
{wxT("SIENNA"), 142, 107, 35},
|
||||||
{wxT("MEDIUM ORCHID"), 147, 112, 219},
|
{wxT("SKY BLUE"), 50, 153, 204},
|
||||||
{wxT("MEDIUM SEA GREEN"), 66, 111, 66},
|
{wxT("SLATE BLUE"), 0, 127, 255},
|
||||||
{wxT("MEDIUM SLATE BLUE"), 127, 0, 255},
|
{wxT("SPRING GREEN"), 0, 255, 127},
|
||||||
{wxT("MEDIUM SPRING GREEN"), 127, 255, 0},
|
{wxT("STEEL BLUE"), 35, 107, 142},
|
||||||
{wxT("MEDIUM TURQUOISE"), 112, 219, 219},
|
{wxT("TAN"), 219, 147, 112},
|
||||||
{wxT("MEDIUM VIOLET RED"), 219, 112, 147},
|
{wxT("THISTLE"), 216, 191, 216},
|
||||||
{wxT("MIDNIGHT BLUE"), 47, 47, 79},
|
{wxT("TURQUOISE"), 173, 234, 234},
|
||||||
{wxT("NAVY"), 35, 35, 142},
|
{wxT("VIOLET"), 79, 47, 79},
|
||||||
{wxT("ORANGE"), 204, 50, 50},
|
{wxT("VIOLET RED"), 204, 50, 153},
|
||||||
{wxT("ORANGE RED"), 255, 0, 127},
|
{wxT("WHEAT"), 216, 216, 191},
|
||||||
{wxT("ORCHID"), 219, 112, 219},
|
{wxT("WHITE"), 255, 255, 255},
|
||||||
{wxT("PALE GREEN"), 143, 188, 143},
|
{wxT("YELLOW"), 255, 255, 0},
|
||||||
{wxT("PINK"), 188, 143, 234},
|
{wxT("YELLOW GREEN"), 153, 204, 50},
|
||||||
{wxT("PLUM"), 234, 173, 234},
|
{wxT("MEDIUM GOLDENROD"), 234, 234, 173},
|
||||||
{wxT("PURPLE"), 176, 0, 255},
|
{wxT("MEDIUM FOREST GREEN"), 107, 142, 35},
|
||||||
{wxT("RED"), 255, 0, 0},
|
{wxT("LIGHT MAGENTA"), 255, 0, 255},
|
||||||
{wxT("SALMON"), 111, 66, 66},
|
{wxT("MEDIUM GREY"), 100, 100, 100},
|
||||||
{wxT("SEA GREEN"), 35, 142, 107},
|
};
|
||||||
{wxT("SIENNA"), 142, 107, 35},
|
|
||||||
{wxT("SKY BLUE"), 50, 153, 204},
|
|
||||||
{wxT("SLATE BLUE"), 0, 127, 255},
|
|
||||||
{wxT("SPRING GREEN"), 0, 255, 127},
|
|
||||||
{wxT("STEEL BLUE"), 35, 107, 142},
|
|
||||||
{wxT("TAN"), 219, 147, 112},
|
|
||||||
{wxT("THISTLE"), 216, 191, 216},
|
|
||||||
{wxT("TURQUOISE"), 173, 234, 234},
|
|
||||||
{wxT("VIOLET"), 79, 47, 79},
|
|
||||||
{wxT("VIOLET RED"), 204, 50, 153},
|
|
||||||
{wxT("WHEAT"), 216, 216, 191},
|
|
||||||
{wxT("WHITE"), 255, 255, 255},
|
|
||||||
{wxT("YELLOW"), 255, 255, 0},
|
|
||||||
{wxT("YELLOW GREEN"), 153, 204, 50},
|
|
||||||
// #endif
|
|
||||||
|
|
||||||
#if defined(__WXGTK__) || defined(__X__)
|
|
||||||
{wxT("MEDIUM GOLDENROD"), 234, 234, 173},
|
|
||||||
{wxT("MEDIUM FOREST GREEN"), 107, 142, 35},
|
|
||||||
{wxT("LIGHT MAGENTA"), 255, 0, 255},
|
|
||||||
{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,45 +238,54 @@ 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 )
|
||||||
return (wxColour *)node->Data();
|
{
|
||||||
|
const wxChar *key = node->GetKeyString();
|
||||||
|
if ( col == key || col2 == key )
|
||||||
|
{
|
||||||
|
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())) {
|
|
||||||
delete col;
|
delete col;
|
||||||
return (wxColour *) NULL;
|
return (wxColour *) NULL;
|
||||||
}
|
|
||||||
Append( colour, col );
|
|
||||||
return col;
|
|
||||||
}
|
}
|
||||||
|
Append( colour, 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