wxComboBox appearance fixes, looks fine now but doesn't really work under GTK

yet


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@10945 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2001-07-10 15:07:52 +00:00
parent 1b4651028a
commit e4606ed9d0
20 changed files with 781 additions and 731 deletions

View File

@@ -250,6 +250,7 @@ public:
// return the bitmaps to use for combobox button // return the bitmaps to use for combobox button
virtual void GetComboBitmaps(wxBitmap *bmpNormal, virtual void GetComboBitmaps(wxBitmap *bmpNormal,
wxBitmap *bmpFocus,
wxBitmap *bmpPressed, wxBitmap *bmpPressed,
wxBitmap *bmpDisabled) = 0; wxBitmap *bmpDisabled) = 0;
@@ -572,9 +573,11 @@ public:
{ m_renderer->DrawMenuSeparator(dc, y, geomInfo); } { m_renderer->DrawMenuSeparator(dc, y, geomInfo); }
#endif #endif
virtual void GetComboBitmaps(wxBitmap *bmpNormal, virtual void GetComboBitmaps(wxBitmap *bmpNormal,
wxBitmap *bmpFocus,
wxBitmap *bmpPressed, wxBitmap *bmpPressed,
wxBitmap *bmpDisabled) wxBitmap *bmpDisabled)
{ m_renderer->GetComboBitmaps(bmpNormal, bmpPressed, bmpDisabled); } { m_renderer->GetComboBitmaps(bmpNormal, bmpFocus,
bmpPressed, bmpDisabled); }
virtual void AdjustSize(wxSize *size, const wxWindow *window) virtual void AdjustSize(wxSize *size, const wxWindow *window)
{ m_renderer->AdjustSize(size, window); } { m_renderer->AdjustSize(size, window); }

View File

@@ -10,7 +10,7 @@ static char *magick[] = {
"+ c #808000", "+ c #808000",
"@ c #000080", "@ c #000080",
"# c #808080", "# c #808080",
"$ c #c0c0c0", "$ c none",
"% c Red", "% c Red",
"& c Green", "& c Green",
"* c Yellow", "* c Yellow",

View File

@@ -9,7 +9,7 @@ static char *button_xpm[] = {
"O c #000000", "O c #000000",
"+ c #808000", "+ c #808000",
"@ c #000080", "@ c #000080",
"# c #c0c0c0", "# c none",
"$ c #808080", "$ c #808080",
"% c Red", "% c Red",
"& c Green", "& c Green",

View File

@@ -9,7 +9,7 @@ static char *checkbox_xpm[] = {
"O c #000000", "O c #000000",
"+ c #808000", "+ c #808000",
"@ c #000080", "@ c #000080",
"# c #c0c0c0", "# c none",
"$ c #808080", "$ c #808080",
"% c Red", "% c Red",
"& c Green", "& c Green",

View File

@@ -9,7 +9,7 @@ static char *combobox_xpm[] = {
"O c #000000", "O c #000000",
"+ c #808000", "+ c #808000",
"@ c #000080", "@ c #000080",
"# c #c0c0c0", "# c none",
"$ c #808080", "$ c #808080",
"% c Red", "% c Red",
"& c Green", "& c Green",

View File

@@ -9,7 +9,7 @@ static char *gauge_xpm[] = {
"O c #000000", "O c #000000",
"+ c #808000", "+ c #808000",
"@ c #000080", "@ c #000080",
"# c #c0c0c0", "# c none",
"$ c #808080", "$ c #808080",
"% c Red", "% c Red",
"& c Green", "& c Green",

View File

@@ -9,7 +9,7 @@ static char *listbox_xpm[] = {
"O c #000000", "O c #000000",
"+ c #808000", "+ c #808000",
"@ c #000080", "@ c #000080",
"# c #c0c0c0", "# c none",
"$ c #808080", "$ c #808080",
"% c Red", "% c Red",
"& c Green", "& c Green",

View File

@@ -9,7 +9,7 @@ static char *notebook_xpm[] = {
"O c #000000", "O c #000000",
"+ c #808000", "+ c #808000",
"@ c #000080", "@ c #000080",
"# c #c0c0c0", "# c none",
"$ c #808080", "$ c #808080",
"% c Red", "% c Red",
"& c Green", "& c Green",

View File

@@ -9,7 +9,7 @@ static char *radio_xpm[] = {
"O c #000000", "O c #000000",
"+ c #808000", "+ c #808000",
"@ c #000080", "@ c #000080",
"# c #c0c0c0", "# c none",
"$ c #808080", "$ c #808080",
"% c Red", "% c Red",
"& c Green", "& c Green",

View File

@@ -9,7 +9,7 @@ static char *magick[] = {
"O c #000000", "O c #000000",
"+ c #808000", "+ c #808000",
"@ c #000080", "@ c #000080",
"# c #c0c0c0", "# c none",
"$ c #808080", "$ c #808080",
"% c Red", "% c Red",
"& c Green", "& c Green",

View File

@@ -9,7 +9,7 @@ static char *slider_xpm[] = {
"O c #000000", "O c #000000",
"+ c #808000", "+ c #808000",
"@ c #000080", "@ c #000080",
"# c #c0c0c0", "# c none",
"$ c #808080", "$ c #808080",
"% c Red", "% c Red",
"& c Green", "& c Green",

View File

@@ -9,7 +9,7 @@ static char *statbox_xpm[] = {
"O c #000000", "O c #000000",
"+ c #808000", "+ c #808000",
"@ c #000080", "@ c #000080",
"# c #c0c0c0", "# c none",
"$ c #808080", "$ c #808080",
"% c Red", "% c Red",
"& c Green", "& c Green",

View File

@@ -9,7 +9,7 @@ static char *stattext_xpm[] = {
"O c #000000", "O c #000000",
"+ c #808000", "+ c #808000",
"@ c #000080", "@ c #000080",
"# c #c0c0c0", "# c none",
"$ c #808080", "$ c #808080",
"% c Red", "% c Red",
"& c Green", "& c Green",

View File

@@ -9,7 +9,7 @@ static char *text_xpm[] = {
"O c #000000", "O c #000000",
"+ c #808000", "+ c #808000",
"@ c #000080", "@ c #000080",
"# c #c0c0c0", "# c none",
"$ c #808080", "$ c #808080",
"% c Red", "% c Red",
"& c Green", "& c Green",

View File

@@ -187,10 +187,17 @@ void wxPopupTransientWindow::Popup(wxWindow *winFocus)
m_child = this; m_child = this;
} }
// we can't capture mouse before the window is shown in wxGTL
#ifdef __WXGTK__
Show();
#endif
m_child->CaptureMouse(); m_child->CaptureMouse();
m_child->PushEventHandler(new wxPopupWindowHandler(this)); m_child->PushEventHandler(new wxPopupWindowHandler(this));
#ifndef __WXGTK__
Show(); Show();
#endif
m_focus = winFocus ? winFocus : this; m_focus = winFocus ? winFocus : this;
m_focus->PushEventHandler(new wxPopupFocusHandler(this)); m_focus->PushEventHandler(new wxPopupFocusHandler(this));

View File

@@ -3743,15 +3743,13 @@ void wxWindowGTK::CaptureMouse()
{ {
wxCHECK_RET( m_widget != NULL, wxT("invalid window") ); wxCHECK_RET( m_widget != NULL, wxT("invalid window") );
wxCHECK_RET( g_captureWindow == NULL, wxT("CaptureMouse called twice") );
GdkWindow *window = (GdkWindow*) NULL; GdkWindow *window = (GdkWindow*) NULL;
if (m_wxwindow) if (m_wxwindow)
window = GTK_PIZZA(m_wxwindow)->bin_window; window = GTK_PIZZA(m_wxwindow)->bin_window;
else else
window = GetConnectWidget()->window; window = GetConnectWidget()->window;
if (!window) return; wxCHECK_RET( window, _T("CaptureMouse() failed") );
wxCursor* cursor = & m_cursor; wxCursor* cursor = & m_cursor;
if (!cursor->Ok()) if (!cursor->Ok())
@@ -3774,7 +3772,7 @@ void wxWindowGTK::ReleaseMouse()
{ {
wxCHECK_RET( m_widget != NULL, wxT("invalid window") ); wxCHECK_RET( m_widget != NULL, wxT("invalid window") );
wxCHECK_RET( g_captureWindow, wxT("ReleaseMouse called twice") ); wxCHECK_RET( g_captureWindow, wxT("can't release mouse - not captured") );
GdkWindow *window = (GdkWindow*) NULL; GdkWindow *window = (GdkWindow*) NULL;
if (m_wxwindow) if (m_wxwindow)

View File

@@ -3743,15 +3743,13 @@ void wxWindowGTK::CaptureMouse()
{ {
wxCHECK_RET( m_widget != NULL, wxT("invalid window") ); wxCHECK_RET( m_widget != NULL, wxT("invalid window") );
wxCHECK_RET( g_captureWindow == NULL, wxT("CaptureMouse called twice") );
GdkWindow *window = (GdkWindow*) NULL; GdkWindow *window = (GdkWindow*) NULL;
if (m_wxwindow) if (m_wxwindow)
window = GTK_PIZZA(m_wxwindow)->bin_window; window = GTK_PIZZA(m_wxwindow)->bin_window;
else else
window = GetConnectWidget()->window; window = GetConnectWidget()->window;
if (!window) return; wxCHECK_RET( window, _T("CaptureMouse() failed") );
wxCursor* cursor = & m_cursor; wxCursor* cursor = & m_cursor;
if (!cursor->Ok()) if (!cursor->Ok())
@@ -3774,7 +3772,7 @@ void wxWindowGTK::ReleaseMouse()
{ {
wxCHECK_RET( m_widget != NULL, wxT("invalid window") ); wxCHECK_RET( m_widget != NULL, wxT("invalid window") );
wxCHECK_RET( g_captureWindow, wxT("ReleaseMouse called twice") ); wxCHECK_RET( g_captureWindow, wxT("can't release mouse - not captured") );
GdkWindow *window = (GdkWindow*) NULL; GdkWindow *window = (GdkWindow*) NULL;
if (m_wxwindow) if (m_wxwindow)

View File

@@ -152,7 +152,11 @@ wxSize wxButton::DoGetBestClientSize() const
void wxButton::DoDraw(wxControlRenderer *renderer) void wxButton::DoDraw(wxControlRenderer *renderer)
{ {
if ( !(GetWindowStyle() & wxBORDER_NONE) )
{
renderer->DrawButtonBorder(); renderer->DrawButtonBorder();
}
renderer->DrawLabel(m_bitmap, m_marginBmpX, m_marginBmpY); renderer->DrawLabel(m_bitmap, m_marginBmpX, m_marginBmpY);
} }

View File

@@ -76,25 +76,35 @@ public:
wxComboButton(wxComboControl *combo) wxComboButton(wxComboControl *combo)
: wxBitmapButton(combo->GetParent(), -1, wxNullBitmap, : wxBitmapButton(combo->GetParent(), -1, wxNullBitmap,
wxDefaultPosition, wxDefaultSize, wxDefaultPosition, wxDefaultSize,
wxBORDER_NONE) wxBORDER_NONE | wxBU_EXACTFIT)
{ {
m_combo = combo; m_combo = combo;
wxBitmap bmpNormal, bmpPressed, bmpDisabled; wxBitmap bmpNormal, bmpFocus, bmpPressed, bmpDisabled;
GetRenderer()->GetComboBitmaps(&bmpNormal,
&bmpFocus,
&bmpPressed,
&bmpDisabled);
GetRenderer()->GetComboBitmaps(&bmpNormal, &bmpPressed, &bmpDisabled);
SetBitmapLabel(bmpNormal); SetBitmapLabel(bmpNormal);
SetBitmapFocus(bmpNormal); SetBitmapFocus(bmpFocus.Ok() ? bmpFocus : bmpNormal);
SetBitmapSelected(bmpPressed); SetBitmapSelected(bmpPressed.Ok() ? bmpPressed : bmpNormal);
SetBitmapDisabled(bmpDisabled); SetBitmapDisabled(bmpDisabled.Ok() ? bmpDisabled : bmpNormal);
SetSize(bmpNormal.GetWidth(), bmpNormal.GetHeight()); SetBestSize(wxDefaultSize);
} }
protected: protected:
void OnButton(wxCommandEvent& event) { m_combo->ShowPopup(); } void OnButton(wxCommandEvent& event) { m_combo->ShowPopup(); }
virtual wxSize DoGetBestSize() const { return GetSize(); } virtual wxSize DoGetBestClientSize() const
{
const wxBitmap& bmp = GetBitmapLabel();
return wxSize(bmp.GetWidth(), bmp.GetHeight());
}
private: private:
wxComboControl *m_combo; wxComboControl *m_combo;
@@ -241,7 +251,8 @@ bool wxComboControl::Create(wxWindow *parent,
m_heightPopup = size.y - DoGetBestSize().y; m_heightPopup = size.y - DoGetBestSize().y;
} }
DoSetSize(pos.x, pos.y, size.x, size.y); SetBestSize(size);
Move(pos);
// create the popup window immediately here to allow creating the controls // create the popup window immediately here to allow creating the controls
// with parent == GetPopupWindow() from the derived class ctor // with parent == GetPopupWindow() from the derived class ctor
@@ -300,7 +311,7 @@ void wxComboControl::DoMoveWindow(int x, int y, int width, int height)
width -= rectBorders.x + rectBorders.width; width -= rectBorders.x + rectBorders.width;
height -= rectBorders.y + rectBorders.height; height -= rectBorders.y + rectBorders.height;
wxSize sizeBtn = m_btn->GetSize(); wxSize sizeBtn = m_btn->GetBestSize();
wxCoord wText = width - sizeBtn.x; wxCoord wText = width - sizeBtn.x;
m_text->SetSize(x, y, wText, height); m_text->SetSize(x, y, wText, height);

View File

@@ -30,6 +30,7 @@
#include "wx/dcmemory.h" #include "wx/dcmemory.h"
#include "wx/window.h" #include "wx/window.h"
#include "wx/bmpbuttn.h"
#include "wx/button.h" #include "wx/button.h"
#include "wx/checkbox.h" #include "wx/checkbox.h"
#include "wx/listbox.h" #include "wx/listbox.h"
@@ -52,7 +53,7 @@
// constants (to be removed, for testing only) // constants (to be removed, for testing only)
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
static const size_t BORDER_THICKNESS = 10; static const size_t BORDER_THICKNESS = 2;
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxGTKRenderer: draw the GUI elements in GTK style // wxGTKRenderer: draw the GUI elements in GTK style
@@ -857,7 +858,7 @@ void wxGTKRenderer::DrawBorder(wxDC& dc,
switch ( border ) switch ( border )
{ {
case wxBORDER_SUNKEN: case wxBORDER_SUNKEN:
for ( width = 0; width < BORDER_THICKNESS; width++ ) for ( width = 0; width < BORDER_THICKNESS / 2; width++ )
{ {
DrawAntiShadedRect(dc, &rect, m_penDarkGrey, m_penHighlight); DrawAntiShadedRect(dc, &rect, m_penDarkGrey, m_penHighlight);
DrawShadedRect(dc, &rect, m_penBlack, m_penLightGrey); DrawShadedRect(dc, &rect, m_penBlack, m_penLightGrey);
@@ -865,24 +866,33 @@ void wxGTKRenderer::DrawBorder(wxDC& dc,
break; break;
case wxBORDER_STATIC: case wxBORDER_STATIC:
for ( width = 0; width < BORDER_THICKNESS / 2; width++ )
{
DrawShadedRect(dc, &rect, m_penDarkGrey, m_penHighlight); DrawShadedRect(dc, &rect, m_penDarkGrey, m_penHighlight);
}
break; break;
case wxBORDER_RAISED: case wxBORDER_RAISED:
for ( width = 0; width < BORDER_THICKNESS; width++ ) for ( width = 0; width < BORDER_THICKNESS / 2; width++ )
{ {
DrawRaisedBorder(dc, &rect); DrawRaisedBorder(dc, &rect);
} }
break; break;
case wxBORDER_DOUBLE: case wxBORDER_DOUBLE:
for ( width = 0; width < BORDER_THICKNESS / 3; width++ )
{
DrawShadedRect(dc, &rect, m_penLightGrey, m_penBlack); DrawShadedRect(dc, &rect, m_penLightGrey, m_penBlack);
DrawShadedRect(dc, &rect, m_penHighlight, m_penDarkGrey); DrawShadedRect(dc, &rect, m_penHighlight, m_penDarkGrey);
DrawRect(dc, &rect, m_penLightGrey); DrawRect(dc, &rect, m_penLightGrey);
}
break; break;
case wxBORDER_SIMPLE: case wxBORDER_SIMPLE:
for ( width = 0; width < BORDER_THICKNESS; width++ )
{
DrawRect(dc, &rect, m_penBlack); DrawRect(dc, &rect, m_penBlack);
}
break; break;
default: default:
@@ -910,11 +920,11 @@ wxRect wxGTKRenderer::GetBorderDimensions(wxBorder border) const
case wxBORDER_SIMPLE: case wxBORDER_SIMPLE:
case wxBORDER_STATIC: case wxBORDER_STATIC:
width = 1; width = BORDER_THICKNESS;
break; break;
case wxBORDER_DOUBLE: case wxBORDER_DOUBLE:
width = 3; width = 3*BORDER_THICKNESS;
break; break;
default: default:
@@ -954,6 +964,8 @@ void wxGTKRenderer::DrawTextBorder(wxDC& dc,
{ {
wxRect rect = rectOrig; wxRect rect = rectOrig;
for ( size_t width = 0; width < BORDER_THICKNESS / 2; width++ )
{
if ( flags & wxCONTROL_FOCUSED ) if ( flags & wxCONTROL_FOCUSED )
{ {
DrawRect(dc, &rect, m_penBlack); DrawRect(dc, &rect, m_penBlack);
@@ -964,6 +976,7 @@ void wxGTKRenderer::DrawTextBorder(wxDC& dc,
DrawAntiShadedRect(dc, &rect, m_penDarkGrey, m_penHighlight); DrawAntiShadedRect(dc, &rect, m_penDarkGrey, m_penHighlight);
DrawAntiShadedRect(dc, &rect, m_penBlack, m_penHighlight); DrawAntiShadedRect(dc, &rect, m_penBlack, m_penHighlight);
} }
}
if ( rectIn ) if ( rectIn )
*rectIn = rect; *rectIn = rect;
@@ -980,9 +993,13 @@ void wxGTKRenderer::DrawButtonBorder(wxDC& dc,
{ {
// button pressed: draw a black border around it and an inward shade // button pressed: draw a black border around it and an inward shade
DrawRect(dc, &rect, m_penBlack); DrawRect(dc, &rect, m_penBlack);
for ( size_t width = 0; width < BORDER_THICKNESS / 2; width++ )
{
DrawAntiShadedRect(dc, &rect, m_penDarkGrey, m_penHighlight); DrawAntiShadedRect(dc, &rect, m_penDarkGrey, m_penHighlight);
DrawAntiShadedRect(dc, &rect, m_penBlack, m_penDarkGrey); DrawAntiShadedRect(dc, &rect, m_penBlack, m_penDarkGrey);
} }
}
else else
{ {
// button not pressed // button not pressed
@@ -999,11 +1016,14 @@ void wxGTKRenderer::DrawButtonBorder(wxDC& dc,
} }
// now draw a normal button // now draw a normal button
for ( size_t width = 0; width < BORDER_THICKNESS / 2; width++ )
{
DrawShadedRect(dc, &rect, m_penHighlight, m_penBlack); DrawShadedRect(dc, &rect, m_penHighlight, m_penBlack);
DrawAntiShadedRect(dc, &rect, DrawAntiShadedRect(dc, &rect,
wxPen(GetBackgroundColour(flags), 0, wxSOLID), wxPen(GetBackgroundColour(flags), 0, wxSOLID),
m_penDarkGrey); m_penDarkGrey);
} }
}
if ( rectIn ) if ( rectIn )
{ {
@@ -2280,6 +2300,14 @@ int wxGTKRenderer::PixelToScrollbar(const wxScrollBar *scrollbar,
void wxGTKRenderer::AdjustSize(wxSize *size, const wxWindow *window) void wxGTKRenderer::AdjustSize(wxSize *size, const wxWindow *window)
{ {
#if wxUSE_BMPBUTTON
if ( wxDynamicCast(window, wxBitmapButton) )
{
size->x += 4;
size->y += 4;
} else
#endif // wxUSE_BMPBUTTON
#if wxUSE_BUTTON
if ( wxDynamicCast(window, wxButton) ) if ( wxDynamicCast(window, wxButton) )
{ {
if ( !(window->GetWindowStyle() & wxBU_EXACTFIT) ) if ( !(window->GetWindowStyle() & wxBU_EXACTFIT) )
@@ -2293,8 +2321,9 @@ void wxGTKRenderer::AdjustSize(wxSize *size, const wxWindow *window)
// button border width // button border width
size->y += 4; size->y += 4;
} }
} } else
else if ( wxDynamicCast(window, wxScrollBar) ) #endif wxUSE_BUTTON
if ( wxDynamicCast(window, wxScrollBar) )
{ {
// we only set the width of vert scrollbars and height of the // we only set the width of vert scrollbars and height of the
// horizontal ones // horizontal ones