Skip to content

Commit 76efdb8

Browse files
committed
Make divider object respond to show/hide
1 parent 7ed5550 commit 76efdb8

1 file changed

Lines changed: 26 additions & 23 deletions

File tree

src/uiobjects.cpp

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -278,38 +278,41 @@ class wxUIDividerObject : public wxUIObject
278278
AddProperty( "Bold", new wxUIProperty( true ) );
279279
Property("Width").Set( 300 );
280280
Property("Height").Set( 16 );
281+
Show(true);
281282
}
282283
virtual wxString GetTypeName() { return "Divider"; }
283284
virtual wxUIObject *Duplicate() { wxUIObject *o = new wxUIDividerObject; o->Copy( this ); return o; }
284285
virtual bool IsNativeObject() { return false; }
285286
virtual bool DrawDottedOutline() { return false; }
286287
virtual void Draw( wxWindow *win, wxDC &dc, const wxRect &geom )
287288
{
288-
wxSize tsz( 10, 10 ); // text extents
289-
wxString capt = Property("Caption").GetString();
290-
if (!capt.IsEmpty() )
291-
{
292-
wxFont font( *wxNORMAL_FONT );
293-
if ( Property("Bold").GetBoolean() ) font.SetWeight( wxFONTWEIGHT_BOLD );
294-
dc.SetFont( font );
295-
tsz = dc.GetTextExtent( capt );
296-
}
297-
298-
dc.SetPen( wxPen( Property("Colour").GetColour() ) );
299-
bool horiz = (Property("Orientation").GetInteger() == 0);
300-
if ( horiz ) dc.DrawLine( geom.x, geom.y+1+tsz.y/2, geom.x+geom.width, geom.y+1+tsz.y/2 );
301-
else dc.DrawLine( geom.x+4, geom.y, geom.x+4, geom.y+geom.height );
302-
303-
if ( !capt.IsEmpty() )
304-
{
305-
if ( horiz )
289+
if (IsVisible()) {
290+
wxSize tsz(10, 10); // text extents
291+
wxString capt = Property("Caption").GetString();
292+
if (!capt.IsEmpty())
306293
{
307-
dc.SetBrush( wxBrush( win->GetBackgroundColour() ) );
308-
dc.SetPen( *wxTRANSPARENT_PEN );
309-
dc.DrawRectangle(geom.x+5, geom.y, tsz.x+2, tsz.y+1);
294+
wxFont font(*wxNORMAL_FONT);
295+
if (Property("Bold").GetBoolean()) font.SetWeight(wxFONTWEIGHT_BOLD);
296+
dc.SetFont(font);
297+
tsz = dc.GetTextExtent(capt);
298+
}
299+
300+
dc.SetPen(wxPen(Property("Colour").GetColour()));
301+
bool horiz = (Property("Orientation").GetInteger() == 0);
302+
if (horiz) dc.DrawLine(geom.x, geom.y + 1 + tsz.y / 2, geom.x + geom.width, geom.y + 1 + tsz.y / 2);
303+
else dc.DrawLine(geom.x + 4, geom.y, geom.x + 4, geom.y + geom.height);
304+
305+
if (!capt.IsEmpty())
306+
{
307+
if (horiz)
308+
{
309+
dc.SetBrush(wxBrush(win->GetBackgroundColour()));
310+
dc.SetPen(*wxTRANSPARENT_PEN);
311+
dc.DrawRectangle(geom.x + 5, geom.y, tsz.x + 2, tsz.y + 1);
312+
}
313+
dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNTEXT));
314+
dc.DrawText(capt, geom.x + 6, geom.y);
310315
}
311-
dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNTEXT));
312-
dc.DrawText( capt, geom.x+6, geom.y );
313316
}
314317
}
315318
};

0 commit comments

Comments
 (0)