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:
parent
1b4651028a
commit
e4606ed9d0
@ -250,6 +250,7 @@ public:
|
||||
|
||||
// return the bitmaps to use for combobox button
|
||||
virtual void GetComboBitmaps(wxBitmap *bmpNormal,
|
||||
wxBitmap *bmpFocus,
|
||||
wxBitmap *bmpPressed,
|
||||
wxBitmap *bmpDisabled) = 0;
|
||||
|
||||
@ -572,9 +573,11 @@ public:
|
||||
{ m_renderer->DrawMenuSeparator(dc, y, geomInfo); }
|
||||
#endif
|
||||
virtual void GetComboBitmaps(wxBitmap *bmpNormal,
|
||||
wxBitmap *bmpFocus,
|
||||
wxBitmap *bmpPressed,
|
||||
wxBitmap *bmpDisabled)
|
||||
{ m_renderer->GetComboBitmaps(bmpNormal, bmpPressed, bmpDisabled); }
|
||||
{ m_renderer->GetComboBitmaps(bmpNormal, bmpFocus,
|
||||
bmpPressed, bmpDisabled); }
|
||||
|
||||
virtual void AdjustSize(wxSize *size, const wxWindow *window)
|
||||
{ m_renderer->AdjustSize(size, window); }
|
||||
|
@ -10,7 +10,7 @@ static char *magick[] = {
|
||||
"+ c #808000",
|
||||
"@ c #000080",
|
||||
"# c #808080",
|
||||
"$ c #c0c0c0",
|
||||
"$ c none",
|
||||
"% c Red",
|
||||
"& c Green",
|
||||
"* c Yellow",
|
||||
|
@ -9,7 +9,7 @@ static char *button_xpm[] = {
|
||||
"O c #000000",
|
||||
"+ c #808000",
|
||||
"@ c #000080",
|
||||
"# c #c0c0c0",
|
||||
"# c none",
|
||||
"$ c #808080",
|
||||
"% c Red",
|
||||
"& c Green",
|
||||
|
@ -9,7 +9,7 @@ static char *checkbox_xpm[] = {
|
||||
"O c #000000",
|
||||
"+ c #808000",
|
||||
"@ c #000080",
|
||||
"# c #c0c0c0",
|
||||
"# c none",
|
||||
"$ c #808080",
|
||||
"% c Red",
|
||||
"& c Green",
|
||||
|
@ -9,7 +9,7 @@ static char *combobox_xpm[] = {
|
||||
"O c #000000",
|
||||
"+ c #808000",
|
||||
"@ c #000080",
|
||||
"# c #c0c0c0",
|
||||
"# c none",
|
||||
"$ c #808080",
|
||||
"% c Red",
|
||||
"& c Green",
|
||||
|
@ -9,7 +9,7 @@ static char *gauge_xpm[] = {
|
||||
"O c #000000",
|
||||
"+ c #808000",
|
||||
"@ c #000080",
|
||||
"# c #c0c0c0",
|
||||
"# c none",
|
||||
"$ c #808080",
|
||||
"% c Red",
|
||||
"& c Green",
|
||||
|
@ -9,7 +9,7 @@ static char *listbox_xpm[] = {
|
||||
"O c #000000",
|
||||
"+ c #808000",
|
||||
"@ c #000080",
|
||||
"# c #c0c0c0",
|
||||
"# c none",
|
||||
"$ c #808080",
|
||||
"% c Red",
|
||||
"& c Green",
|
||||
|
@ -9,7 +9,7 @@ static char *notebook_xpm[] = {
|
||||
"O c #000000",
|
||||
"+ c #808000",
|
||||
"@ c #000080",
|
||||
"# c #c0c0c0",
|
||||
"# c none",
|
||||
"$ c #808080",
|
||||
"% c Red",
|
||||
"& c Green",
|
||||
|
@ -9,7 +9,7 @@ static char *radio_xpm[] = {
|
||||
"O c #000000",
|
||||
"+ c #808000",
|
||||
"@ c #000080",
|
||||
"# c #c0c0c0",
|
||||
"# c none",
|
||||
"$ c #808080",
|
||||
"% c Red",
|
||||
"& c Green",
|
||||
|
@ -9,7 +9,7 @@ static char *magick[] = {
|
||||
"O c #000000",
|
||||
"+ c #808000",
|
||||
"@ c #000080",
|
||||
"# c #c0c0c0",
|
||||
"# c none",
|
||||
"$ c #808080",
|
||||
"% c Red",
|
||||
"& c Green",
|
||||
|
@ -9,7 +9,7 @@ static char *slider_xpm[] = {
|
||||
"O c #000000",
|
||||
"+ c #808000",
|
||||
"@ c #000080",
|
||||
"# c #c0c0c0",
|
||||
"# c none",
|
||||
"$ c #808080",
|
||||
"% c Red",
|
||||
"& c Green",
|
||||
|
@ -9,7 +9,7 @@ static char *statbox_xpm[] = {
|
||||
"O c #000000",
|
||||
"+ c #808000",
|
||||
"@ c #000080",
|
||||
"# c #c0c0c0",
|
||||
"# c none",
|
||||
"$ c #808080",
|
||||
"% c Red",
|
||||
"& c Green",
|
||||
|
@ -9,7 +9,7 @@ static char *stattext_xpm[] = {
|
||||
"O c #000000",
|
||||
"+ c #808000",
|
||||
"@ c #000080",
|
||||
"# c #c0c0c0",
|
||||
"# c none",
|
||||
"$ c #808080",
|
||||
"% c Red",
|
||||
"& c Green",
|
||||
|
@ -9,7 +9,7 @@ static char *text_xpm[] = {
|
||||
"O c #000000",
|
||||
"+ c #808000",
|
||||
"@ c #000080",
|
||||
"# c #c0c0c0",
|
||||
"# c none",
|
||||
"$ c #808080",
|
||||
"% c Red",
|
||||
"& c Green",
|
||||
|
@ -187,10 +187,17 @@ void wxPopupTransientWindow::Popup(wxWindow *winFocus)
|
||||
m_child = this;
|
||||
}
|
||||
|
||||
// we can't capture mouse before the window is shown in wxGTL
|
||||
#ifdef __WXGTK__
|
||||
Show();
|
||||
#endif
|
||||
|
||||
m_child->CaptureMouse();
|
||||
m_child->PushEventHandler(new wxPopupWindowHandler(this));
|
||||
|
||||
#ifndef __WXGTK__
|
||||
Show();
|
||||
#endif
|
||||
|
||||
m_focus = winFocus ? winFocus : this;
|
||||
m_focus->PushEventHandler(new wxPopupFocusHandler(this));
|
||||
|
@ -3743,15 +3743,13 @@ void wxWindowGTK::CaptureMouse()
|
||||
{
|
||||
wxCHECK_RET( m_widget != NULL, wxT("invalid window") );
|
||||
|
||||
wxCHECK_RET( g_captureWindow == NULL, wxT("CaptureMouse called twice") );
|
||||
|
||||
GdkWindow *window = (GdkWindow*) NULL;
|
||||
if (m_wxwindow)
|
||||
window = GTK_PIZZA(m_wxwindow)->bin_window;
|
||||
else
|
||||
window = GetConnectWidget()->window;
|
||||
|
||||
if (!window) return;
|
||||
wxCHECK_RET( window, _T("CaptureMouse() failed") );
|
||||
|
||||
wxCursor* cursor = & m_cursor;
|
||||
if (!cursor->Ok())
|
||||
@ -3774,7 +3772,7 @@ void wxWindowGTK::ReleaseMouse()
|
||||
{
|
||||
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;
|
||||
if (m_wxwindow)
|
||||
|
@ -3743,15 +3743,13 @@ void wxWindowGTK::CaptureMouse()
|
||||
{
|
||||
wxCHECK_RET( m_widget != NULL, wxT("invalid window") );
|
||||
|
||||
wxCHECK_RET( g_captureWindow == NULL, wxT("CaptureMouse called twice") );
|
||||
|
||||
GdkWindow *window = (GdkWindow*) NULL;
|
||||
if (m_wxwindow)
|
||||
window = GTK_PIZZA(m_wxwindow)->bin_window;
|
||||
else
|
||||
window = GetConnectWidget()->window;
|
||||
|
||||
if (!window) return;
|
||||
wxCHECK_RET( window, _T("CaptureMouse() failed") );
|
||||
|
||||
wxCursor* cursor = & m_cursor;
|
||||
if (!cursor->Ok())
|
||||
@ -3774,7 +3772,7 @@ void wxWindowGTK::ReleaseMouse()
|
||||
{
|
||||
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;
|
||||
if (m_wxwindow)
|
||||
|
@ -152,7 +152,11 @@ wxSize wxButton::DoGetBestClientSize() const
|
||||
|
||||
void wxButton::DoDraw(wxControlRenderer *renderer)
|
||||
{
|
||||
if ( !(GetWindowStyle() & wxBORDER_NONE) )
|
||||
{
|
||||
renderer->DrawButtonBorder();
|
||||
}
|
||||
|
||||
renderer->DrawLabel(m_bitmap, m_marginBmpX, m_marginBmpY);
|
||||
}
|
||||
|
||||
|
@ -76,25 +76,35 @@ public:
|
||||
wxComboButton(wxComboControl *combo)
|
||||
: wxBitmapButton(combo->GetParent(), -1, wxNullBitmap,
|
||||
wxDefaultPosition, wxDefaultSize,
|
||||
wxBORDER_NONE)
|
||||
wxBORDER_NONE | wxBU_EXACTFIT)
|
||||
{
|
||||
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);
|
||||
SetBitmapFocus(bmpNormal);
|
||||
SetBitmapSelected(bmpPressed);
|
||||
SetBitmapDisabled(bmpDisabled);
|
||||
SetBitmapFocus(bmpFocus.Ok() ? bmpFocus : bmpNormal);
|
||||
SetBitmapSelected(bmpPressed.Ok() ? bmpPressed : bmpNormal);
|
||||
SetBitmapDisabled(bmpDisabled.Ok() ? bmpDisabled : bmpNormal);
|
||||
|
||||
SetSize(bmpNormal.GetWidth(), bmpNormal.GetHeight());
|
||||
SetBestSize(wxDefaultSize);
|
||||
}
|
||||
|
||||
protected:
|
||||
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:
|
||||
wxComboControl *m_combo;
|
||||
@ -241,7 +251,8 @@ bool wxComboControl::Create(wxWindow *parent,
|
||||
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
|
||||
// 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;
|
||||
height -= rectBorders.y + rectBorders.height;
|
||||
|
||||
wxSize sizeBtn = m_btn->GetSize();
|
||||
wxSize sizeBtn = m_btn->GetBestSize();
|
||||
|
||||
wxCoord wText = width - sizeBtn.x;
|
||||
m_text->SetSize(x, y, wText, height);
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include "wx/dcmemory.h"
|
||||
#include "wx/window.h"
|
||||
|
||||
#include "wx/bmpbuttn.h"
|
||||
#include "wx/button.h"
|
||||
#include "wx/checkbox.h"
|
||||
#include "wx/listbox.h"
|
||||
@ -52,7 +53,7 @@
|
||||
// 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
|
||||
@ -857,7 +858,7 @@ void wxGTKRenderer::DrawBorder(wxDC& dc,
|
||||
switch ( border )
|
||||
{
|
||||
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);
|
||||
DrawShadedRect(dc, &rect, m_penBlack, m_penLightGrey);
|
||||
@ -865,24 +866,33 @@ void wxGTKRenderer::DrawBorder(wxDC& dc,
|
||||
break;
|
||||
|
||||
case wxBORDER_STATIC:
|
||||
for ( width = 0; width < BORDER_THICKNESS / 2; width++ )
|
||||
{
|
||||
DrawShadedRect(dc, &rect, m_penDarkGrey, m_penHighlight);
|
||||
}
|
||||
break;
|
||||
|
||||
case wxBORDER_RAISED:
|
||||
for ( width = 0; width < BORDER_THICKNESS; width++ )
|
||||
for ( width = 0; width < BORDER_THICKNESS / 2; width++ )
|
||||
{
|
||||
DrawRaisedBorder(dc, &rect);
|
||||
}
|
||||
break;
|
||||
|
||||
case wxBORDER_DOUBLE:
|
||||
for ( width = 0; width < BORDER_THICKNESS / 3; width++ )
|
||||
{
|
||||
DrawShadedRect(dc, &rect, m_penLightGrey, m_penBlack);
|
||||
DrawShadedRect(dc, &rect, m_penHighlight, m_penDarkGrey);
|
||||
DrawRect(dc, &rect, m_penLightGrey);
|
||||
}
|
||||
break;
|
||||
|
||||
case wxBORDER_SIMPLE:
|
||||
for ( width = 0; width < BORDER_THICKNESS; width++ )
|
||||
{
|
||||
DrawRect(dc, &rect, m_penBlack);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -910,11 +920,11 @@ wxRect wxGTKRenderer::GetBorderDimensions(wxBorder border) const
|
||||
|
||||
case wxBORDER_SIMPLE:
|
||||
case wxBORDER_STATIC:
|
||||
width = 1;
|
||||
width = BORDER_THICKNESS;
|
||||
break;
|
||||
|
||||
case wxBORDER_DOUBLE:
|
||||
width = 3;
|
||||
width = 3*BORDER_THICKNESS;
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -954,6 +964,8 @@ void wxGTKRenderer::DrawTextBorder(wxDC& dc,
|
||||
{
|
||||
wxRect rect = rectOrig;
|
||||
|
||||
for ( size_t width = 0; width < BORDER_THICKNESS / 2; width++ )
|
||||
{
|
||||
if ( flags & wxCONTROL_FOCUSED )
|
||||
{
|
||||
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_penBlack, m_penHighlight);
|
||||
}
|
||||
}
|
||||
|
||||
if ( rectIn )
|
||||
*rectIn = rect;
|
||||
@ -980,9 +993,13 @@ void wxGTKRenderer::DrawButtonBorder(wxDC& dc,
|
||||
{
|
||||
// button pressed: draw a black border around it and an inward shade
|
||||
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_penBlack, m_penDarkGrey);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// button not pressed
|
||||
@ -999,11 +1016,14 @@ void wxGTKRenderer::DrawButtonBorder(wxDC& dc,
|
||||
}
|
||||
|
||||
// now draw a normal button
|
||||
for ( size_t width = 0; width < BORDER_THICKNESS / 2; width++ )
|
||||
{
|
||||
DrawShadedRect(dc, &rect, m_penHighlight, m_penBlack);
|
||||
DrawAntiShadedRect(dc, &rect,
|
||||
wxPen(GetBackgroundColour(flags), 0, wxSOLID),
|
||||
m_penDarkGrey);
|
||||
}
|
||||
}
|
||||
|
||||
if ( rectIn )
|
||||
{
|
||||
@ -2280,6 +2300,14 @@ int wxGTKRenderer::PixelToScrollbar(const wxScrollBar *scrollbar,
|
||||
|
||||
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 ( !(window->GetWindowStyle() & wxBU_EXACTFIT) )
|
||||
@ -2293,8 +2321,9 @@ void wxGTKRenderer::AdjustSize(wxSize *size, const wxWindow *window)
|
||||
// button border width
|
||||
size->y += 4;
|
||||
}
|
||||
}
|
||||
else if ( wxDynamicCast(window, wxScrollBar) )
|
||||
} else
|
||||
#endif wxUSE_BUTTON
|
||||
if ( wxDynamicCast(window, wxScrollBar) )
|
||||
{
|
||||
// we only set the width of vert scrollbars and height of the
|
||||
// horizontal ones
|
||||
|
Loading…
Reference in New Issue
Block a user