fix assert because of passing more than one border bit in style to the base class Create()

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@44902 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2007-03-18 23:07:58 +00:00
parent 02c7347b7f
commit 88c23b64c7

View File

@@ -68,17 +68,17 @@ static wxColor wxStepColour(const wxColor& c, int ialpha)
{ {
if (ialpha == 100) if (ialpha == 100)
return c; return c;
double r = c.Red(), g = c.Green(), b = c.Blue(); double r = c.Red(), g = c.Green(), b = c.Blue();
double bg; double bg;
// ialpha is 0..200 where 0 is completely black // ialpha is 0..200 where 0 is completely black
// and 200 is completely white and 100 is the same // and 200 is completely white and 100 is the same
// convert that to normal alpha 0.0 - 1.0 // convert that to normal alpha 0.0 - 1.0
ialpha = wxMin(ialpha, 200); ialpha = wxMin(ialpha, 200);
ialpha = wxMax(ialpha, 0); ialpha = wxMax(ialpha, 0);
double alpha = ((double)(ialpha - 100.0))/100.0; double alpha = ((double)(ialpha - 100.0))/100.0;
if (ialpha > 100) if (ialpha > 100)
{ {
// blend with white // blend with white
@@ -91,11 +91,11 @@ static wxColor wxStepColour(const wxColor& c, int ialpha)
bg = 0.0; bg = 0.0;
alpha = 1.0 + alpha; // 0 = transparent fg; 1 = opaque fg alpha = 1.0 + alpha; // 0 = transparent fg; 1 = opaque fg
} }
r = wxBlendColour(r, bg, alpha); r = wxBlendColour(r, bg, alpha);
g = wxBlendColour(g, bg, alpha); g = wxBlendColour(g, bg, alpha);
b = wxBlendColour(b, bg, alpha); b = wxBlendColour(b, bg, alpha);
return wxColour((unsigned char)r, (unsigned char)g, (unsigned char)b); return wxColour((unsigned char)r, (unsigned char)g, (unsigned char)b);
} }
@@ -114,7 +114,7 @@ public:
{ {
m_search = search; m_search = search;
m_defaultFG = GetForegroundColour(); m_defaultFG = GetForegroundColour();
// remove the default minsize, the searchctrl will have one instead // remove the default minsize, the searchctrl will have one instead
SetSizeHints(wxDefaultCoord,wxDefaultCoord); SetSizeHints(wxDefaultCoord,wxDefaultCoord);
} }
@@ -125,15 +125,15 @@ public:
{ {
ChangeValue(wxEmptyString); ChangeValue(wxEmptyString);
} }
m_descriptiveText = text; m_descriptiveText = text;
} }
wxString GetDescriptiveText() const wxString GetDescriptiveText() const
{ {
return m_descriptiveText; return m_descriptiveText;
} }
protected: protected:
void OnText(wxCommandEvent& eventText) void OnText(wxCommandEvent& eventText)
{ {
@@ -178,12 +178,12 @@ protected:
SetForegroundColour(m_defaultFG); SetForegroundColour(m_defaultFG);
} }
} }
private: private:
wxSearchCtrl* m_search; wxSearchCtrl* m_search;
wxString m_descriptiveText; wxString m_descriptiveText;
wxColour m_defaultFG; wxColour m_defaultFG;
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
}; };
@@ -315,22 +315,29 @@ bool wxSearchCtrl::Create(wxWindow *parent, wxWindowID id,
const wxValidator& validator, const wxValidator& validator,
const wxString& name) const wxString& name)
{ {
// force border style for more native appearance
style &= ~wxBORDER_MASK;
#ifdef __WXGTK__ #ifdef __WXGTK__
if ( !wxTextCtrlBase::Create(parent, id, pos, size, wxSUNKEN_BORDER | style, validator, name) ) style |= wxBORDER_SUNKEN;
#else #else
if ( !wxTextCtrlBase::Create(parent, id, pos, size, wxSIMPLE_BORDER | style, validator, name) ) style |= wxBORDER_SIMPLE;
#endif #endif
if ( !wxTextCtrlBase::Create(parent, id, pos, size, style, validator, name) )
{ {
return false; return false;
} }
m_text = new wxSearchTextCtrl(this, value, style & ~wxBORDER_MASK); m_text = new wxSearchTextCtrl(this, value, style & ~wxBORDER_MASK);
m_text->SetDescriptiveText(_("Search")); m_text->SetDescriptiveText(_("Search"));
wxSize sizeText = m_text->GetBestSize(); wxSize sizeText = m_text->GetBestSize();
m_searchButton = new wxSearchButton(this,wxEVT_COMMAND_SEARCHCTRL_SEARCH_BTN,m_searchBitmap); m_searchButton = new wxSearchButton(this,
m_cancelButton = new wxSearchButton(this,wxEVT_COMMAND_SEARCHCTRL_CANCEL_BTN,m_cancelBitmap); wxEVT_COMMAND_SEARCHCTRL_SEARCH_BTN,
m_searchBitmap);
m_cancelButton = new wxSearchButton(this,
wxEVT_COMMAND_SEARCHCTRL_CANCEL_BTN,
m_cancelBitmap);
SetForegroundColour( m_text->GetForegroundColour() ); SetForegroundColour( m_text->GetForegroundColour() );
m_searchButton->SetForegroundColour( m_text->GetForegroundColour() ); m_searchButton->SetForegroundColour( m_text->GetForegroundColour() );
@@ -382,7 +389,7 @@ void wxSearchCtrl::SetMenu( wxMenu* menu )
} }
} }
wxRect rect = GetRect(); wxRect rect = GetRect();
LayoutControls(0, 0, rect.GetWidth(), rect.GetHeight()); LayoutControls(0, 0, rect.GetWidth(), rect.GetHeight());
} }
wxMenu* wxSearchCtrl::GetMenu() wxMenu* wxSearchCtrl::GetMenu()
@@ -482,7 +489,7 @@ void wxSearchCtrl::LayoutControls(int x, int y, int width, int height)
{ {
if ( !m_text ) if ( !m_text )
return; return;
wxSize sizeText = m_text->GetBestSize(); wxSize sizeText = m_text->GetBestSize();
// make room for the search menu & clear button // make room for the search menu & clear button
int horizontalBorder = ( sizeText.y - sizeText.y * 14 / 21 ) / 2; int horizontalBorder = ( sizeText.y - sizeText.y * 14 / 21 ) / 2;
@@ -520,9 +527,9 @@ void wxSearchCtrl::LayoutControls(int x, int y, int width, int height)
// position the subcontrols inside the client area // position the subcontrols inside the client area
m_searchButton->SetSize(x, y + ICON_OFFSET - 1, sizeSearch.x, height); m_searchButton->SetSize(x, y + ICON_OFFSET - 1, sizeSearch.x, height);
m_text->SetSize( x + sizeSearch.x + searchMargin, m_text->SetSize( x + sizeSearch.x + searchMargin,
y + ICON_OFFSET - BORDER, y + ICON_OFFSET - BORDER,
textWidth, textWidth,
height); height);
m_cancelButton->SetSize(x + sizeSearch.x + searchMargin + textWidth + cancelMargin, m_cancelButton->SetSize(x + sizeSearch.x + searchMargin + textWidth + cancelMargin,
y + ICON_OFFSET - 1, sizeCancel.x, height); y + ICON_OFFSET - 1, sizeCancel.x, height);
@@ -989,7 +996,7 @@ wxBitmap wxSearchCtrl::RenderSearchBitmap( int x, int y, bool renderDrop )
mem.DrawPolygon(WXSIZEOF(dropPolygon),dropPolygon,multiplier*triangleX,multiplier*triangleY); mem.DrawPolygon(WXSIZEOF(dropPolygon),dropPolygon,multiplier*triangleX,multiplier*triangleY);
} }
mem.SelectObject(wxNullBitmap); mem.SelectObject(wxNullBitmap);
//=============================================================================== //===============================================================================
// end drawing code // end drawing code
//=============================================================================== //===============================================================================