Add wxRenderer::DrawCheckButton for use inside
wxDataViewCtrl. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@38794 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -170,6 +170,15 @@ public:
|
|||||||
const wxRect& rect,
|
const wxRect& rect,
|
||||||
int flags = 0) = 0;
|
int flags = 0) = 0;
|
||||||
|
|
||||||
|
|
||||||
|
// draw check button
|
||||||
|
//
|
||||||
|
// flags may use wxCONTROL_CHECKED, wxCONTROL_UNDETERMINED and wxCONTROL_CURRENT
|
||||||
|
virtual void DrawCheckButton(wxWindow *win,
|
||||||
|
wxDC& dc,
|
||||||
|
const wxRect& rect,
|
||||||
|
int flags = 0) = 0;
|
||||||
|
|
||||||
// geometry functions
|
// geometry functions
|
||||||
// ------------------
|
// ------------------
|
||||||
|
|
||||||
@@ -272,6 +281,12 @@ public:
|
|||||||
int flags = 0)
|
int flags = 0)
|
||||||
{ m_rendererNative.DrawDropArrow(win, dc, rect, flags); }
|
{ m_rendererNative.DrawDropArrow(win, dc, rect, flags); }
|
||||||
|
|
||||||
|
virtual void DrawCheckButton(wxWindow *win,
|
||||||
|
wxDC& dc,
|
||||||
|
const wxRect& rect,
|
||||||
|
int flags = 0 )
|
||||||
|
{ m_rendererNative.DrawCheckButton( win, dc, rect, flags ); }
|
||||||
|
|
||||||
virtual wxSplitterRenderParams GetSplitterParams(const wxWindow *win)
|
virtual wxSplitterRenderParams GetSplitterParams(const wxWindow *win)
|
||||||
{ return m_rendererNative.GetSplitterParams(win); }
|
{ return m_rendererNative.GetSplitterParams(win); }
|
||||||
|
|
||||||
|
@@ -315,26 +315,23 @@ bool wxDataViewToggleCell::Render( wxRect cell, wxDC *dc, int WXUNUSED(state) )
|
|||||||
{
|
{
|
||||||
// User wxRenderer here
|
// User wxRenderer here
|
||||||
|
|
||||||
if (GetMode() == wxDATAVIEW_CELL_ACTIVATABLE)
|
|
||||||
dc->SetPen( *wxBLACK_PEN );
|
|
||||||
else
|
|
||||||
dc->SetPen( *wxGREY_PEN );
|
|
||||||
dc->SetBrush( *wxTRANSPARENT_BRUSH );
|
|
||||||
wxRect rect;
|
wxRect rect;
|
||||||
rect.x = cell.x + cell.width/2 - 10;
|
rect.x = cell.x + cell.width/2 - 10;
|
||||||
rect.width = 20;
|
rect.width = 20;
|
||||||
rect.y = cell.y + cell.height/2 - 10;
|
rect.y = cell.y + cell.height/2 - 10;
|
||||||
rect.height = 20;
|
rect.height = 20;
|
||||||
dc->DrawRectangle( rect );
|
|
||||||
|
int flags = 0;
|
||||||
if (m_toggle)
|
if (m_toggle)
|
||||||
{
|
flags |= wxCONTROL_CHECKED;
|
||||||
rect.x += 2;
|
if (GetMode() != wxDATAVIEW_CELL_ACTIVATABLE)
|
||||||
rect.y += 2;
|
flags |= wxCONTROL_DISABLED;
|
||||||
rect.width -= 4;
|
|
||||||
rect.height -= 4;
|
wxRendererNative::Get().DrawCheckButton(
|
||||||
dc->DrawLine( rect.x, rect.y, rect.x+rect.width, rect.y+rect.height );
|
GetOwner()->GetOwner(),
|
||||||
dc->DrawLine( rect.x+rect.width, rect.y, rect.x, rect.y+rect.height );
|
*dc,
|
||||||
}
|
rect,
|
||||||
|
flags );
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@@ -78,6 +78,11 @@ public:
|
|||||||
const wxRect& rect,
|
const wxRect& rect,
|
||||||
int flags = 0);
|
int flags = 0);
|
||||||
|
|
||||||
|
virtual void DrawCheckButton(wxWindow *win,
|
||||||
|
wxDC& dc,
|
||||||
|
const wxRect& rect,
|
||||||
|
int flags = 0);
|
||||||
|
|
||||||
virtual wxSplitterRenderParams GetSplitterParams(const wxWindow *win);
|
virtual wxSplitterRenderParams GetSplitterParams(const wxWindow *win);
|
||||||
|
|
||||||
virtual wxRendererVersion GetVersion() const
|
virtual wxRendererVersion GetVersion() const
|
||||||
@@ -395,6 +400,30 @@ wxRendererGeneric::DrawDropArrow(wxWindow *win,
|
|||||||
dc.DrawPolygon(WXSIZEOF(pt), pt, rect.x, rect.y);
|
dc.DrawPolygon(WXSIZEOF(pt), pt, rect.x, rect.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
wxRendererGeneric::DrawCheckButton(wxWindow *win,
|
||||||
|
wxDC& dc,
|
||||||
|
const wxRect& rect,
|
||||||
|
int flags)
|
||||||
|
{
|
||||||
|
if (flags & wxCONTROL_DISABLED)
|
||||||
|
dc.SetPen( *wxGREY_PEN );
|
||||||
|
else
|
||||||
|
dc.SetPen( *wxBLACK_PEN );
|
||||||
|
dc.SetBrush( *wxTRANSPARENT_BRUSH );
|
||||||
|
wxRect my_rect = rect;
|
||||||
|
dc.DrawRectangle( my_rect );
|
||||||
|
if (flags & wxCONTROL_CHECKED)
|
||||||
|
{
|
||||||
|
my_rect.x += 2;
|
||||||
|
my_rect.y += 2;
|
||||||
|
my_rect.width -= 4;
|
||||||
|
my_rect.height -= 4;
|
||||||
|
dc.DrawLine( my_rect.x, my_rect.y, my_rect.x+my_rect.width, my_rect.y+my_rect.height );
|
||||||
|
dc.DrawLine( my_rect.x+my_rect.width, my_rect.y, my_rect.x, my_rect.y+my_rect.height );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// A module to allow cleanup of generic renderer.
|
// A module to allow cleanup of generic renderer.
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
@@ -78,6 +78,11 @@ public:
|
|||||||
const wxRect& rect,
|
const wxRect& rect,
|
||||||
int flags = 0);
|
int flags = 0);
|
||||||
|
|
||||||
|
virtual void DrawCheckButton(wxWindow *win,
|
||||||
|
wxDC& dc,
|
||||||
|
const wxRect& rect,
|
||||||
|
int flags = 0);
|
||||||
|
|
||||||
virtual wxSplitterRenderParams GetSplitterParams(const wxWindow *win);
|
virtual wxSplitterRenderParams GetSplitterParams(const wxWindow *win);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -88,6 +93,9 @@ private:
|
|||||||
|
|
||||||
// used by DrawTreeItemButton()
|
// used by DrawTreeItemButton()
|
||||||
static GtkWidget *GetTreeWidget();
|
static GtkWidget *GetTreeWidget();
|
||||||
|
|
||||||
|
// used by DrawCheckButton()
|
||||||
|
static GtkWidget *GetCheckButtonWidget();
|
||||||
};
|
};
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
@@ -124,6 +132,24 @@ wxRendererGTK::GetButtonWidget()
|
|||||||
return s_button;
|
return s_button;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GtkWidget *
|
||||||
|
wxRendererGTK::GetCheckButtonWidget()
|
||||||
|
{
|
||||||
|
static GtkWidget *s_button = NULL;
|
||||||
|
static GtkWidget *s_window = NULL;
|
||||||
|
|
||||||
|
if ( !s_button )
|
||||||
|
{
|
||||||
|
s_window = gtk_window_new( GTK_WINDOW_POPUP );
|
||||||
|
gtk_widget_realize( s_window );
|
||||||
|
s_button = gtk_check_button_new();
|
||||||
|
gtk_container_add( GTK_CONTAINER(s_window), s_button );
|
||||||
|
gtk_widget_realize( s_button );
|
||||||
|
}
|
||||||
|
|
||||||
|
return s_button;
|
||||||
|
}
|
||||||
|
|
||||||
GtkWidget *
|
GtkWidget *
|
||||||
wxRendererGTK::GetTreeWidget()
|
wxRendererGTK::GetTreeWidget()
|
||||||
{
|
{
|
||||||
@@ -431,3 +457,38 @@ wxRendererGTK::DrawComboBoxDropButton(wxWindow *win,
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
wxRendererGTK::DrawCheckButton(wxWindow *win,
|
||||||
|
wxDC& dc,
|
||||||
|
const wxRect& rect,
|
||||||
|
int flags )
|
||||||
|
{
|
||||||
|
GtkWidget *button = GetCheckButtonWidget();
|
||||||
|
|
||||||
|
// for reason why we do this, see DrawDropArrow
|
||||||
|
wxWindowDC& wdc = (wxWindowDC&)dc;
|
||||||
|
wxASSERT ( wdc.IsKindOf(CLASSINFO(wxWindowDC)) );
|
||||||
|
|
||||||
|
GtkStateType state;
|
||||||
|
|
||||||
|
if ( flags & wxCONTROL_PRESSED )
|
||||||
|
state = GTK_STATE_ACTIVE;
|
||||||
|
else if ( flags & wxCONTROL_DISABLED )
|
||||||
|
state = GTK_STATE_INSENSITIVE;
|
||||||
|
else if ( flags & wxCONTROL_CURRENT )
|
||||||
|
state = GTK_STATE_PRELIGHT;
|
||||||
|
else
|
||||||
|
state = GTK_STATE_NORMAL;
|
||||||
|
|
||||||
|
gtk_paint_check
|
||||||
|
(
|
||||||
|
button->style,
|
||||||
|
wdc.m_window,
|
||||||
|
state,
|
||||||
|
flags & wxCONTROL_CHECKED ? GTK_SHADOW_IN : GTK_SHADOW_OUT,
|
||||||
|
NULL,
|
||||||
|
button,
|
||||||
|
"cellcheck",
|
||||||
|
rect.x, rect.y, 13, 13
|
||||||
|
);
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user