add wxRenderer::GetCheckBoxSize(); refactor wxGTK code to avoid duplication (#9642)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@54934 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
979a73474c
commit
e8759560f8
20
Makefile.in
20
Makefile.in
@ -4240,6 +4240,7 @@ COND_TOOLKIT_GTK_TOOLKIT_VERSION_2___LOWLEVEL_SRC_OBJECTS = \
|
||||
monodll_minifram.o \
|
||||
monodll_pen.o \
|
||||
monodll_popupwin.o \
|
||||
monodll_private.o \
|
||||
monodll_region.o \
|
||||
monodll_renderer.o \
|
||||
monodll_settings.o \
|
||||
@ -5105,6 +5106,7 @@ COND_TOOLKIT_GTK_TOOLKIT_VERSION_2___LOWLEVEL_SRC_OBJECTS_1 = \
|
||||
monodll_minifram.o \
|
||||
monodll_pen.o \
|
||||
monodll_popupwin.o \
|
||||
monodll_private.o \
|
||||
monodll_region.o \
|
||||
monodll_renderer.o \
|
||||
monodll_settings.o \
|
||||
@ -6138,6 +6140,7 @@ COND_TOOLKIT_GTK_TOOLKIT_VERSION_2___LOWLEVEL_SRC_OBJECTS_2 = \
|
||||
monolib_minifram.o \
|
||||
monolib_pen.o \
|
||||
monolib_popupwin.o \
|
||||
monolib_private.o \
|
||||
monolib_region.o \
|
||||
monolib_renderer.o \
|
||||
monolib_settings.o \
|
||||
@ -7004,6 +7007,7 @@ COND_TOOLKIT_GTK_TOOLKIT_VERSION_2___LOWLEVEL_SRC_OBJECTS_3 = \
|
||||
monolib_minifram.o \
|
||||
monolib_pen.o \
|
||||
monolib_popupwin.o \
|
||||
monolib_private.o \
|
||||
monolib_region.o \
|
||||
monolib_renderer.o \
|
||||
monolib_settings.o \
|
||||
@ -8298,6 +8302,7 @@ COND_TOOLKIT_GTK_TOOLKIT_VERSION_2___LOWLEVEL_SRC_OBJECTS_4 = \
|
||||
coredll_minifram.o \
|
||||
coredll_pen.o \
|
||||
coredll_popupwin.o \
|
||||
coredll_private.o \
|
||||
coredll_region.o \
|
||||
coredll_renderer.o \
|
||||
coredll_settings.o \
|
||||
@ -9164,6 +9169,7 @@ COND_TOOLKIT_GTK_TOOLKIT_VERSION_2___LOWLEVEL_SRC_OBJECTS_5 = \
|
||||
coredll_minifram.o \
|
||||
coredll_pen.o \
|
||||
coredll_popupwin.o \
|
||||
coredll_private.o \
|
||||
coredll_region.o \
|
||||
coredll_renderer.o \
|
||||
coredll_settings.o \
|
||||
@ -9795,6 +9801,7 @@ COND_TOOLKIT_GTK_TOOLKIT_VERSION_2___LOWLEVEL_SRC_OBJECTS_6 = \
|
||||
corelib_minifram.o \
|
||||
corelib_pen.o \
|
||||
corelib_popupwin.o \
|
||||
corelib_private.o \
|
||||
corelib_region.o \
|
||||
corelib_renderer.o \
|
||||
corelib_settings.o \
|
||||
@ -10661,6 +10668,7 @@ COND_TOOLKIT_GTK_TOOLKIT_VERSION_2___LOWLEVEL_SRC_OBJECTS_7 = \
|
||||
corelib_minifram.o \
|
||||
corelib_pen.o \
|
||||
corelib_popupwin.o \
|
||||
corelib_private.o \
|
||||
corelib_region.o \
|
||||
corelib_renderer.o \
|
||||
corelib_settings.o \
|
||||
@ -15653,6 +15661,9 @@ monodll_sound_sdl.o: $(srcdir)/src/unix/sound_sdl.cpp $(MONODLL_ODEP)
|
||||
@COND_TOOLKIT_PM_USE_GUI_1_WXUNIV_0@monodll_popupwin.o: $(srcdir)/src/os2/popupwin.cpp $(MONODLL_ODEP)
|
||||
@COND_TOOLKIT_PM_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/os2/popupwin.cpp
|
||||
|
||||
@COND_TOOLKIT_GTK_TOOLKIT_VERSION_2_USE_GUI_1@monodll_private.o: $(srcdir)/src/gtk/private.cpp $(MONODLL_ODEP)
|
||||
@COND_TOOLKIT_GTK_TOOLKIT_VERSION_2_USE_GUI_1@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/gtk/private.cpp
|
||||
|
||||
@COND_TOOLKIT_GTK_TOOLKIT_VERSION_2_USE_GUI_1@monodll_region.o: $(srcdir)/src/gtk/region.cpp $(MONODLL_ODEP)
|
||||
@COND_TOOLKIT_GTK_TOOLKIT_VERSION_2_USE_GUI_1@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/gtk/region.cpp
|
||||
|
||||
@ -20141,6 +20152,9 @@ monolib_sound_sdl.o: $(srcdir)/src/unix/sound_sdl.cpp $(MONOLIB_ODEP)
|
||||
@COND_TOOLKIT_PM_USE_GUI_1_WXUNIV_0@monolib_popupwin.o: $(srcdir)/src/os2/popupwin.cpp $(MONOLIB_ODEP)
|
||||
@COND_TOOLKIT_PM_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/os2/popupwin.cpp
|
||||
|
||||
@COND_TOOLKIT_GTK_TOOLKIT_VERSION_2_USE_GUI_1@monolib_private.o: $(srcdir)/src/gtk/private.cpp $(MONOLIB_ODEP)
|
||||
@COND_TOOLKIT_GTK_TOOLKIT_VERSION_2_USE_GUI_1@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/gtk/private.cpp
|
||||
|
||||
@COND_TOOLKIT_GTK_TOOLKIT_VERSION_2_USE_GUI_1@monolib_region.o: $(srcdir)/src/gtk/region.cpp $(MONOLIB_ODEP)
|
||||
@COND_TOOLKIT_GTK_TOOLKIT_VERSION_2_USE_GUI_1@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/gtk/region.cpp
|
||||
|
||||
@ -25121,6 +25135,9 @@ coredll_win32.o: $(srcdir)/src/univ/themes/win32.cpp $(COREDLL_ODEP)
|
||||
@COND_TOOLKIT_PM_USE_GUI_1_WXUNIV_0@coredll_popupwin.o: $(srcdir)/src/os2/popupwin.cpp $(COREDLL_ODEP)
|
||||
@COND_TOOLKIT_PM_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/os2/popupwin.cpp
|
||||
|
||||
@COND_TOOLKIT_GTK_TOOLKIT_VERSION_2_USE_GUI_1@coredll_private.o: $(srcdir)/src/gtk/private.cpp $(COREDLL_ODEP)
|
||||
@COND_TOOLKIT_GTK_TOOLKIT_VERSION_2_USE_GUI_1@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/gtk/private.cpp
|
||||
|
||||
@COND_TOOLKIT_GTK_TOOLKIT_VERSION_2_USE_GUI_1@coredll_region.o: $(srcdir)/src/gtk/region.cpp $(COREDLL_ODEP)
|
||||
@COND_TOOLKIT_GTK_TOOLKIT_VERSION_2_USE_GUI_1@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/gtk/region.cpp
|
||||
|
||||
@ -28193,6 +28210,9 @@ corelib_win32.o: $(srcdir)/src/univ/themes/win32.cpp $(CORELIB_ODEP)
|
||||
@COND_TOOLKIT_PM_USE_GUI_1_WXUNIV_0@corelib_popupwin.o: $(srcdir)/src/os2/popupwin.cpp $(CORELIB_ODEP)
|
||||
@COND_TOOLKIT_PM_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/os2/popupwin.cpp
|
||||
|
||||
@COND_TOOLKIT_GTK_TOOLKIT_VERSION_2_USE_GUI_1@corelib_private.o: $(srcdir)/src/gtk/private.cpp $(CORELIB_ODEP)
|
||||
@COND_TOOLKIT_GTK_TOOLKIT_VERSION_2_USE_GUI_1@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/gtk/private.cpp
|
||||
|
||||
@COND_TOOLKIT_GTK_TOOLKIT_VERSION_2_USE_GUI_1@corelib_region.o: $(srcdir)/src/gtk/region.cpp $(CORELIB_ODEP)
|
||||
@COND_TOOLKIT_GTK_TOOLKIT_VERSION_2_USE_GUI_1@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/gtk/region.cpp
|
||||
|
||||
|
@ -997,6 +997,7 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file!
|
||||
src/gtk/minifram.cpp
|
||||
src/gtk/pen.cpp
|
||||
src/gtk/popupwin.cpp
|
||||
src/gtk/private.cpp
|
||||
src/gtk/region.cpp
|
||||
src/gtk/renderer.cpp
|
||||
src/gtk/settings.cpp
|
||||
|
@ -104,5 +104,27 @@ void gtk_window_set_policy (GtkWindow *window,
|
||||
|
||||
} // extern "C"
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// various private helper functions
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
namespace wxGTKPrivate
|
||||
{
|
||||
|
||||
// these functions create the GTK widgets of the specified types which can then
|
||||
// used to retrieve their styles, pass them to drawing functions &c
|
||||
//
|
||||
// the returned widgets shouldn't be destroyed, this is done automatically on
|
||||
// shutdown
|
||||
GtkWidget *GetButtonWidget();
|
||||
GtkWidget *GetCheckButtonWidget();
|
||||
GtkWidget *GetEntryWidget();
|
||||
GtkWidget *GetHeaderButtonWidget();
|
||||
GtkWidget *GetSplitterWidget();
|
||||
GtkWidget *GetTreeWidget();
|
||||
|
||||
} // wxGTKPrivate
|
||||
|
||||
#endif // _WX_GTK_PRIVATE_H_
|
||||
|
||||
|
@ -28,7 +28,7 @@
|
||||
class WXDLLIMPEXP_FWD_CORE wxDC;
|
||||
class WXDLLIMPEXP_FWD_CORE wxWindow;
|
||||
|
||||
#include "wx/gdicmn.h" // for wxPoint
|
||||
#include "wx/gdicmn.h" // for wxPoint, wxSize
|
||||
#include "wx/colour.h"
|
||||
#include "wx/font.h"
|
||||
#include "wx/bitmap.h"
|
||||
@ -227,6 +227,9 @@ public:
|
||||
const wxRect& rect,
|
||||
int flags = 0) = 0;
|
||||
|
||||
// Returns the default size of a check box.
|
||||
virtual wxSize GetCheckBoxSize(wxWindow *win) = 0;
|
||||
|
||||
// draw blank button
|
||||
//
|
||||
// flags may use wxCONTROL_PRESSED, wxCONTROL_CURRENT and wxCONTROL_ISDEFAULT
|
||||
@ -373,6 +376,9 @@ public:
|
||||
int flags = 0 )
|
||||
{ m_rendererNative.DrawCheckBox( win, dc, rect, flags ); }
|
||||
|
||||
virtual wxSize GetCheckBoxSize(wxWindow *win)
|
||||
{ return m_rendererNative.GetCheckBoxSize(win); }
|
||||
|
||||
virtual void DrawPushButton(wxWindow *win,
|
||||
wxDC& dc,
|
||||
const wxRect& rect,
|
||||
|
@ -211,6 +211,8 @@ public:
|
||||
virtual void DrawCheckBox(wxWindow *win, wxDC& dc,
|
||||
const wxRect& rect, int flags = 0 );
|
||||
|
||||
virtual wxSize GetCheckBoxSize(wxWindow *win);
|
||||
|
||||
virtual void DrawPushButton(wxWindow *win, wxDC& dc,
|
||||
const wxRect& rect, int flags = 0 );
|
||||
|
||||
@ -286,7 +288,7 @@ public:
|
||||
~wxRendererNative();
|
||||
|
||||
/**
|
||||
Draw a check box (used by wxDataViewCtrl).
|
||||
Draw a check box.
|
||||
|
||||
@a flags may have the @c wxCONTROL_CHECKED, @c wxCONTROL_CURRENT or
|
||||
@c wxCONTROL_UNDETERMINED bit set, see @ref wxCONTROL_FLAGS.
|
||||
@ -427,6 +429,11 @@ public:
|
||||
*/
|
||||
static wxRendererNative GetGeneric();
|
||||
|
||||
/**
|
||||
Returns the size of a check box.
|
||||
*/
|
||||
virtual wxSize GetCheckBoxSize(wxWindow *win);
|
||||
|
||||
/**
|
||||
Returns the height of a header button, either a fixed platform height if
|
||||
available, or a
|
||||
|
@ -98,6 +98,8 @@ public:
|
||||
const wxRect& rect,
|
||||
int flags = 0);
|
||||
|
||||
virtual wxSize GetCheckBoxSize(wxWindow *win);
|
||||
|
||||
virtual void DrawPushButton(wxWindow *win,
|
||||
wxDC& dc,
|
||||
const wxRect& rect,
|
||||
@ -618,6 +620,11 @@ wxRendererGeneric::DrawCheckBox(wxWindow *WXUNUSED(win),
|
||||
}
|
||||
}
|
||||
|
||||
wxSize wxRendererGeneric::GetCheckBoxSize(wxWindow *WXUNUSED(win))
|
||||
{
|
||||
return wxSize(16, 16);
|
||||
}
|
||||
|
||||
void
|
||||
wxRendererGeneric::DrawPushButton(wxWindow *win,
|
||||
wxDC& dc,
|
||||
|
169
src/gtk/private.cpp
Normal file
169
src/gtk/private.cpp
Normal file
@ -0,0 +1,169 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: src/gtk/private.cpp
|
||||
// Purpose: implementation of wxGTK private functions
|
||||
// Author: Marcin Malich
|
||||
// Modified by:
|
||||
// Created: 28.06.2008
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 2008 Marcin Malich <me@malcom.pl>
|
||||
// License: wxWindows licence
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// ============================================================================
|
||||
// declarations
|
||||
// ============================================================================
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// headers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// for compilers that support precompilation, includes "wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/module.h"
|
||||
#endif
|
||||
|
||||
#include "wx/gtk/private.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxGTKPrivate functions implementation
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
namespace wxGTKPrivate
|
||||
{
|
||||
|
||||
static GtkWidget *gs_container = NULL;
|
||||
|
||||
static GtkContainer* GetContainer()
|
||||
{
|
||||
if ( gs_container == NULL )
|
||||
{
|
||||
GtkWidget* window = gtk_window_new(GTK_WINDOW_POPUP);
|
||||
gs_container = gtk_fixed_new();
|
||||
gtk_container_add(GTK_CONTAINER(window), gs_container);
|
||||
}
|
||||
return GTK_CONTAINER(gs_container);
|
||||
}
|
||||
|
||||
GtkWidget *GetButtonWidget()
|
||||
{
|
||||
static GtkWidget *s_button = NULL;
|
||||
|
||||
if ( !s_button )
|
||||
{
|
||||
s_button = gtk_button_new();
|
||||
gtk_container_add(GetContainer(), s_button);
|
||||
gtk_widget_realize(s_button);
|
||||
}
|
||||
|
||||
return s_button;
|
||||
}
|
||||
|
||||
GtkWidget *GetCheckButtonWidget()
|
||||
{
|
||||
static GtkWidget *s_button = NULL;
|
||||
|
||||
if ( !s_button )
|
||||
{
|
||||
s_button = gtk_check_button_new();
|
||||
gtk_container_add(GetContainer(), s_button);
|
||||
gtk_widget_realize(s_button);
|
||||
}
|
||||
|
||||
return s_button;
|
||||
}
|
||||
|
||||
GtkWidget *GetEntryWidget()
|
||||
{
|
||||
static GtkWidget *s_entry = NULL;
|
||||
|
||||
if ( !s_entry )
|
||||
{
|
||||
s_entry = gtk_entry_new();
|
||||
gtk_container_add(GetContainer(), s_entry);
|
||||
gtk_widget_realize(s_entry);
|
||||
}
|
||||
|
||||
return s_entry;
|
||||
}
|
||||
|
||||
// This one just gets the button used by the column header. Although it's
|
||||
// still a gtk_button the themes will typically differentiate and draw them
|
||||
// differently if the button is in a treeview.
|
||||
GtkWidget *GetHeaderButtonWidget()
|
||||
{
|
||||
static GtkWidget *s_button = NULL;
|
||||
|
||||
if ( !s_button )
|
||||
{
|
||||
// Get the dummy tree widget, give it a column, and then use the
|
||||
// widget in the column header for the rendering code.
|
||||
GtkWidget* treewidget = GetTreeWidget();
|
||||
GtkTreeViewColumn *column = gtk_tree_view_column_new();
|
||||
gtk_tree_view_append_column(GTK_TREE_VIEW(treewidget), column);
|
||||
s_button = column->button;
|
||||
}
|
||||
|
||||
return s_button;
|
||||
}
|
||||
|
||||
GtkWidget* GetSplitterWidget()
|
||||
{
|
||||
static GtkWidget* widget;
|
||||
|
||||
if (widget == NULL)
|
||||
{
|
||||
widget = gtk_vpaned_new();
|
||||
gtk_container_add(GetContainer(), widget);
|
||||
gtk_widget_realize(widget);
|
||||
}
|
||||
|
||||
return widget;
|
||||
}
|
||||
|
||||
GtkWidget *GetTreeWidget()
|
||||
{
|
||||
static GtkWidget *s_tree = NULL;
|
||||
|
||||
if ( !s_tree )
|
||||
{
|
||||
s_tree = gtk_tree_view_new();
|
||||
gtk_container_add(GetContainer(), s_tree);
|
||||
gtk_widget_realize(s_tree);
|
||||
}
|
||||
|
||||
return s_tree;
|
||||
}
|
||||
|
||||
|
||||
// Module for destroying created widgets
|
||||
class WidgetsCleanupModule : public wxModule
|
||||
{
|
||||
public:
|
||||
virtual bool OnInit()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual void OnExit()
|
||||
{
|
||||
if ( gs_container )
|
||||
{
|
||||
GtkWidget* parent = gtk_widget_get_parent(gs_container);
|
||||
gtk_widget_destroy(parent);
|
||||
}
|
||||
}
|
||||
|
||||
DECLARE_DYNAMIC_CLASS(WidgetsCleanupModule)
|
||||
};
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS(WidgetsCleanupModule, wxModule)
|
||||
|
||||
static WidgetsCleanupModule gs_widgetsCleanupModule;
|
||||
|
||||
} // wxGTKPrivate namespace
|
@ -34,6 +34,7 @@
|
||||
#endif
|
||||
|
||||
#include "wx/gtk/dc.h"
|
||||
#include "wx/gtk/private.h"
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
@ -96,58 +97,15 @@ public:
|
||||
|
||||
virtual void DrawFocusRect(wxWindow* win, wxDC& dc, const wxRect& rect, int flags = 0);
|
||||
|
||||
virtual wxSize GetCheckBoxSize(wxWindow *win);
|
||||
|
||||
virtual wxSplitterRenderParams GetSplitterParams(const wxWindow *win);
|
||||
|
||||
class Module;
|
||||
friend class Module;
|
||||
|
||||
private:
|
||||
// used by DrawPushButton and DrawDropArrow
|
||||
static GtkWidget *GetButtonWidget();
|
||||
|
||||
// used by DrawTreeItemButton()
|
||||
static GtkWidget *GetTreeWidget();
|
||||
|
||||
// used by DrawCheckBox()
|
||||
static GtkWidget *GetCheckButtonWidget();
|
||||
|
||||
// Used by DrawHeaderButton
|
||||
static GtkWidget *GetHeaderButtonWidget();
|
||||
|
||||
static GtkWidget* GetSplitterWidget();
|
||||
|
||||
// container for created widgets
|
||||
static GtkContainer* GetContainer();
|
||||
static GtkWidget* ms_container;
|
||||
};
|
||||
|
||||
// Module for destroying created widgets
|
||||
class wxRendererGTK::Module: public wxModule
|
||||
{
|
||||
public:
|
||||
virtual bool OnInit()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
virtual void OnExit()
|
||||
{
|
||||
if (wxRendererGTK::ms_container)
|
||||
{
|
||||
GtkWidget* parent =
|
||||
gtk_widget_get_parent(wxRendererGTK::ms_container);
|
||||
gtk_widget_destroy(parent);
|
||||
}
|
||||
}
|
||||
DECLARE_DYNAMIC_CLASS(wxRendererGTK::Module)
|
||||
};
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxRendererGTK::Module, wxModule)
|
||||
|
||||
// ============================================================================
|
||||
// implementation
|
||||
// ============================================================================
|
||||
|
||||
GtkWidget* wxRendererGTK::ms_container;
|
||||
|
||||
/* static */
|
||||
wxRendererNative& wxRendererNative::GetDefault()
|
||||
{
|
||||
@ -156,117 +114,6 @@ wxRendererNative& wxRendererNative::GetDefault()
|
||||
return s_rendererGTK;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// helper functions
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
GtkContainer* wxRendererGTK::GetContainer()
|
||||
{
|
||||
if (ms_container == NULL)
|
||||
{
|
||||
GtkWidget* window = gtk_window_new(GTK_WINDOW_POPUP);
|
||||
ms_container = gtk_fixed_new();
|
||||
gtk_container_add(GTK_CONTAINER(window), ms_container);
|
||||
}
|
||||
return GTK_CONTAINER(ms_container);
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
wxRendererGTK::GetButtonWidget()
|
||||
{
|
||||
static GtkWidget *s_button = NULL;
|
||||
|
||||
if ( !s_button )
|
||||
{
|
||||
s_button = gtk_button_new();
|
||||
gtk_container_add(GetContainer(), s_button);
|
||||
gtk_widget_realize( s_button );
|
||||
}
|
||||
|
||||
return s_button;
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
wxRendererGTK::GetCheckButtonWidget()
|
||||
{
|
||||
static GtkWidget *s_button = NULL;
|
||||
|
||||
if ( !s_button )
|
||||
{
|
||||
s_button = gtk_check_button_new();
|
||||
gtk_container_add(GetContainer(), s_button);
|
||||
gtk_widget_realize( s_button );
|
||||
}
|
||||
|
||||
return s_button;
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
wxRendererGTK::GetTreeWidget()
|
||||
{
|
||||
static GtkWidget *s_tree = NULL;
|
||||
|
||||
if ( !s_tree )
|
||||
{
|
||||
s_tree = gtk_tree_view_new();
|
||||
gtk_container_add(GetContainer(), s_tree);
|
||||
gtk_widget_realize( s_tree );
|
||||
}
|
||||
|
||||
return s_tree;
|
||||
}
|
||||
|
||||
// used elsewhere
|
||||
GtkWidget *GetEntryWidget()
|
||||
{
|
||||
static GtkWidget *s_entry = NULL;
|
||||
static GtkWidget *s_window = NULL;
|
||||
|
||||
if ( !s_entry )
|
||||
{
|
||||
s_window = gtk_window_new( GTK_WINDOW_POPUP );
|
||||
gtk_widget_realize( s_window );
|
||||
s_entry = gtk_entry_new();
|
||||
gtk_container_add( GTK_CONTAINER(s_window), s_entry );
|
||||
gtk_widget_realize( s_entry );
|
||||
}
|
||||
|
||||
return s_entry;
|
||||
}
|
||||
|
||||
// This one just gets the button used by the column header. Although it's
|
||||
// still a gtk_button the themes will typically differentiate and draw them
|
||||
// differently if the button is in a treeview.
|
||||
GtkWidget *
|
||||
wxRendererGTK::GetHeaderButtonWidget()
|
||||
{
|
||||
static GtkWidget *s_button = NULL;
|
||||
|
||||
if ( !s_button )
|
||||
{
|
||||
// Get the dummy tree widget, give it a column, and then use the
|
||||
// widget in the column header for the rendering code.
|
||||
GtkWidget* treewidget = GetTreeWidget();
|
||||
GtkTreeViewColumn* column = gtk_tree_view_column_new();
|
||||
gtk_tree_view_append_column(GTK_TREE_VIEW(treewidget), column);
|
||||
s_button = column->button;
|
||||
}
|
||||
|
||||
return s_button;
|
||||
}
|
||||
|
||||
GtkWidget* wxRendererGTK::GetSplitterWidget()
|
||||
{
|
||||
static GtkWidget* widget;
|
||||
if (widget == NULL)
|
||||
{
|
||||
widget = gtk_vpaned_new();
|
||||
gtk_container_add(GetContainer(), widget);
|
||||
gtk_widget_realize(widget);
|
||||
}
|
||||
return widget;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// list/tree controls drawing
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -280,7 +127,7 @@ wxRendererGTK::DrawHeaderButton(wxWindow *win,
|
||||
wxHeaderButtonParams* params)
|
||||
{
|
||||
|
||||
GtkWidget *button = GetHeaderButtonWidget();
|
||||
GtkWidget *button = wxGTKPrivate::GetHeaderButtonWidget();
|
||||
|
||||
GdkWindow* gdk_window = NULL;
|
||||
#if wxUSE_NEW_DC
|
||||
@ -327,7 +174,7 @@ void
|
||||
wxRendererGTK::DrawTreeItemButton(wxWindow* win,
|
||||
wxDC& dc, const wxRect& rect, int flags)
|
||||
{
|
||||
GtkWidget *tree = GetTreeWidget();
|
||||
GtkWidget *tree = wxGTKPrivate::GetTreeWidget();
|
||||
|
||||
GdkWindow* gdk_window = NULL;
|
||||
#if wxUSE_NEW_DC
|
||||
@ -387,7 +234,7 @@ wxRendererGTK::GetSplitterParams(const wxWindow *WXUNUSED(win))
|
||||
// we don't draw any border, hence 0 for the second field
|
||||
return wxSplitterRenderParams
|
||||
(
|
||||
GetGtkSplitterFullSize(GetSplitterWidget()),
|
||||
GetGtkSplitterFullSize(wxGTKPrivate::GetSplitterWidget()),
|
||||
0,
|
||||
true // hot sensitive
|
||||
);
|
||||
@ -428,7 +275,7 @@ wxRendererGTK::DrawSplitterSash(wxWindow *win,
|
||||
wxASSERT_MSG( gdk_window,
|
||||
wxT("cannot use wxRendererNative on wxDC of this type") );
|
||||
|
||||
wxCoord full_size = GetGtkSplitterFullSize(GetSplitterWidget());
|
||||
wxCoord full_size = GetGtkSplitterFullSize(wxGTKPrivate::GetSplitterWidget());
|
||||
|
||||
// are we drawing vertical or horizontal splitter?
|
||||
const bool isVert = orient == wxVERTICAL;
|
||||
@ -477,7 +324,7 @@ wxRendererGTK::DrawDropArrow(wxWindow *WXUNUSED(win),
|
||||
const wxRect& rect,
|
||||
int flags)
|
||||
{
|
||||
GtkWidget *button = GetButtonWidget();
|
||||
GtkWidget *button = wxGTKPrivate::GetButtonWidget();
|
||||
|
||||
// If we give GTK_PIZZA(win->m_wxwindow)->bin_window as
|
||||
// a window for gtk_paint_xxx function, then it won't
|
||||
@ -546,13 +393,26 @@ wxRendererGTK::DrawComboBoxDropButton(wxWindow *win,
|
||||
DrawDropArrow(win,dc,rect);
|
||||
}
|
||||
|
||||
wxSize
|
||||
wxRendererGTK::GetCheckBoxSize(wxWindow *WXUNUSED(win))
|
||||
{
|
||||
gint indicator_size, indicator_spacing;
|
||||
gtk_widget_style_get(wxGTKPrivate::GetCheckButtonWidget(),
|
||||
"indicator_size", &indicator_size,
|
||||
"indicator_spacing", &indicator_spacing,
|
||||
NULL);
|
||||
|
||||
int size = indicator_size + indicator_spacing * 2;
|
||||
return wxSize(size, size);
|
||||
}
|
||||
|
||||
void
|
||||
wxRendererGTK::DrawCheckBox(wxWindow *WXUNUSED(win),
|
||||
wxDC& dc,
|
||||
const wxRect& rect,
|
||||
int flags )
|
||||
{
|
||||
GtkWidget *button = GetCheckButtonWidget();
|
||||
GtkWidget *button = wxGTKPrivate::GetCheckButtonWidget();
|
||||
|
||||
GdkWindow* gdk_window = NULL;
|
||||
#if wxUSE_NEW_DC
|
||||
@ -566,6 +426,12 @@ wxRendererGTK::DrawCheckBox(wxWindow *WXUNUSED(win),
|
||||
wxASSERT_MSG( gdk_window,
|
||||
wxT("cannot use wxRendererNative on wxDC of this type") );
|
||||
|
||||
gint indicator_size, indicator_spacing;
|
||||
gtk_widget_style_get(button,
|
||||
"indicator_size", &indicator_size,
|
||||
"indicator_spacing", &indicator_spacing,
|
||||
NULL);
|
||||
|
||||
GtkStateType state;
|
||||
|
||||
if ( flags & wxCONTROL_PRESSED )
|
||||
@ -586,9 +452,9 @@ wxRendererGTK::DrawCheckBox(wxWindow *WXUNUSED(win),
|
||||
NULL,
|
||||
button,
|
||||
"cellcheck",
|
||||
dc.LogicalToDeviceX(rect.x)+2,
|
||||
dc.LogicalToDeviceY(rect.y)+3,
|
||||
13, 13
|
||||
dc.LogicalToDeviceX(rect.x) + indicator_spacing,
|
||||
dc.LogicalToDeviceY(rect.y) + indicator_spacing,
|
||||
indicator_size, indicator_size
|
||||
);
|
||||
}
|
||||
|
||||
@ -598,7 +464,7 @@ wxRendererGTK::DrawPushButton(wxWindow *WXUNUSED(win),
|
||||
const wxRect& rect,
|
||||
int flags)
|
||||
{
|
||||
GtkWidget *button = GetButtonWidget();
|
||||
GtkWidget *button = wxGTKPrivate::GetButtonWidget();
|
||||
|
||||
GdkWindow* gdk_window = NULL;
|
||||
#if wxUSE_NEW_DC
|
||||
|
@ -8,6 +8,7 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "wx/defs.h"
|
||||
#include "wx/gtk/private.h"
|
||||
#include "wx/gtk/private/win_gtk.h"
|
||||
|
||||
/*
|
||||
@ -382,8 +383,6 @@ void wxPizza::scroll(int dx, int dy)
|
||||
}
|
||||
}
|
||||
|
||||
extern GtkWidget *GetEntryWidget();
|
||||
|
||||
void wxPizza::get_border_widths(int& x, int& y)
|
||||
{
|
||||
x = y = 0;
|
||||
@ -391,7 +390,7 @@ void wxPizza::get_border_widths(int& x, int& y)
|
||||
x = y = 1;
|
||||
else if (m_border_style)
|
||||
{
|
||||
GtkWidget *entry_widget = GetEntryWidget();
|
||||
GtkWidget *entry_widget = wxGTKPrivate::GetEntryWidget();
|
||||
if (entry_widget->style)
|
||||
{
|
||||
x = entry_widget->style->xthickness;
|
||||
|
@ -301,8 +301,6 @@ gtk_window_expose_callback( GtkWidget* widget,
|
||||
|
||||
#ifndef __WXUNIVERSAL__
|
||||
|
||||
GtkWidget* GetEntryWidget();
|
||||
|
||||
extern "C" {
|
||||
static gboolean
|
||||
expose_event_border(GtkWidget* widget, GdkEventExpose* gdk_event, wxWindow* win)
|
||||
@ -343,7 +341,7 @@ expose_event_border(GtkWidget* widget, GdkEventExpose* gdk_event, wxWindow* win)
|
||||
// for scrollable ones
|
||||
detail = "viewport";
|
||||
|
||||
GtkWidget* styleWidget = GetEntryWidget();
|
||||
GtkWidget* styleWidget = wxGTKPrivate::GetEntryWidget();
|
||||
gtk_paint_shadow(
|
||||
styleWidget->style, gdk_event->window, GTK_STATE_NORMAL,
|
||||
shadow, NULL, styleWidget, detail, x, y, w, h);
|
||||
|
@ -122,6 +122,8 @@ public:
|
||||
const wxRect& rect,
|
||||
int flags = 0);
|
||||
|
||||
virtual wxSize GetCheckBoxSize(wxWindow *win);
|
||||
|
||||
virtual int GetHeaderButtonHeight(wxWindow *win);
|
||||
|
||||
private:
|
||||
@ -295,6 +297,12 @@ void wxRendererMSW::DrawFocusRect(wxWindow * WXUNUSED(win),
|
||||
::DrawFocusRect(GetHdcOf(*((wxMSWDCImpl*)dc.GetImpl())), &rc);
|
||||
}
|
||||
|
||||
wxSize wxRendererMSW::GetCheckBoxSize(wxWindow * WXUNUSED(win))
|
||||
{
|
||||
return wxSize(::GetSystemMetrics(SM_CXMENUCHECK),
|
||||
::GetSystemMetrics(SM_CYMENUCHECK));
|
||||
}
|
||||
|
||||
int wxRendererMSW::GetHeaderButtonHeight(wxWindow * WXUNUSED(win))
|
||||
{
|
||||
// some "reasonable" value returned in case of error, it doesn't really
|
||||
@ -560,7 +568,7 @@ wxRendererXP::DrawItemSelectionRect(wxWindow *win,
|
||||
dc.SetBrush(brush);
|
||||
dc.SetPen(*wxTRANSPARENT_PEN);
|
||||
dc.DrawRectangle( rect );
|
||||
|
||||
|
||||
if ((flags & wxCONTROL_FOCUSED) && (flags & wxCONTROL_CURRENT))
|
||||
DrawFocusRect( win, dc, rect, flags );
|
||||
}
|
||||
|
@ -62,6 +62,8 @@ public:
|
||||
const wxRect& rect,
|
||||
int flags = 0);
|
||||
|
||||
virtual wxSize GetCheckBoxSize(wxWindow* win);
|
||||
|
||||
virtual void DrawComboBoxDropButton(wxWindow *win,
|
||||
wxDC& dc,
|
||||
const wxRect& rect,
|
||||
@ -344,6 +346,27 @@ wxRendererMac::DrawCheckBox(wxWindow *win,
|
||||
kThemeCheckBox, kThemeAdornmentNone);
|
||||
}
|
||||
|
||||
wxSize wxRendererMac::GetCheckBoxSize(wxWindow* WXUNUSED(win))
|
||||
{
|
||||
wxSize size;
|
||||
SInt32 width, height;
|
||||
OSStatus errStatus;
|
||||
|
||||
errStatus = GetThemeMetric(kThemeMetricCheckBoxWidth, &width);
|
||||
if (errStatus == noErr)
|
||||
{
|
||||
size.SetWidth(width);
|
||||
}
|
||||
|
||||
errStatus = GetThemeMetric(kThemeMetricCheckBoxHeight, &height);
|
||||
if (errStatus == noErr)
|
||||
{
|
||||
size.SetHeight(height);
|
||||
}
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
void
|
||||
wxRendererMac::DrawComboBoxDropButton(wxWindow *win,
|
||||
wxDC& dc,
|
||||
@ -405,4 +428,3 @@ wxRendererMac::DrawFocusRect(wxWindow* win, wxDC& dc, const wxRect& rect, int fl
|
||||
|
||||
HIThemeDrawFocusRect( &cgrect , true , cgContext , kHIThemeOrientationNormal ) ;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user