KiCad PCB EDA Suite
WX_COLLAPSIBLE_PANE_HEADER Class Reference

A header control for WX_COLLAPSIBLE_PANE Looks like a static text with a unicode arrow prepended to show the state Takes the same space as a static text. More...

#include <collapsible_pane.h>

Inheritance diagram for WX_COLLAPSIBLE_PANE_HEADER:

Public Member Functions

 WX_COLLAPSIBLE_PANE_HEADER ()
 
 WX_COLLAPSIBLE_PANE_HEADER (wxWindow *aParent, wxWindowID aId, const wxString &aLabel, const wxPoint &aPos=wxDefaultPosition, const wxSize &aSize=wxDefaultSize, long aStyle=wxBORDER_NONE, const wxValidator &aValidator=wxDefaultValidator, const wxString &aName=wxT("COLLAPSIBLE_PANE_HEADER"))
 
bool Create (wxWindow *aParent, wxWindowID aId, const wxString &aLabel, const wxPoint &aPos=wxDefaultPosition, const wxSize &aSize=wxDefaultSize, long aStyle=wxBORDER_NONE, const wxValidator &aValidator=wxDefaultValidator, const wxString &aName=wxT("COLLAPSIBLE_PANE_HEADER"))
 
void SetCollapsed (bool aCollapsed=true)
 
bool IsCollapsed () const
 

Protected Member Functions

wxSize DoGetBestClientSize () const override
 

Private Member Functions

void init ()
 
void onPaint (wxPaintEvent &aEvent)
 
void onFocus (wxFocusEvent &aEvent)
 
void onEnterWindow (wxMouseEvent &aEvent)
 
void onLeaveWindow (wxMouseEvent &aEvent)
 
void onLeftUp (wxMouseEvent &aEvent)
 
void onChar (wxKeyEvent &aEvent)
 
void doSetCollapsed (bool aCollapsed)
 

Private Attributes

wxString m_label
 
bool m_collapsed
 
bool m_inWindow
 
wxBitmap m_iconRight
 
wxBitmap m_iconDown
 

Detailed Description

A header control for WX_COLLAPSIBLE_PANE Looks like a static text with a unicode arrow prepended to show the state Takes the same space as a static text.

This is similar to the wxCollapsiblePane on GTK.

Definition at line 34 of file collapsible_pane.h.

Constructor & Destructor Documentation

◆ WX_COLLAPSIBLE_PANE_HEADER() [1/2]

WX_COLLAPSIBLE_PANE_HEADER::WX_COLLAPSIBLE_PANE_HEADER ( )
inline

Definition at line 37 of file collapsible_pane.h.

38  {
39  init();
40  }

References init().

◆ WX_COLLAPSIBLE_PANE_HEADER() [2/2]

WX_COLLAPSIBLE_PANE_HEADER::WX_COLLAPSIBLE_PANE_HEADER ( wxWindow *  aParent,
wxWindowID  aId,
const wxString &  aLabel,
const wxPoint &  aPos = wxDefaultPosition,
const wxSize &  aSize = wxDefaultSize,
long  aStyle = wxBORDER_NONE,
const wxValidator &  aValidator = wxDefaultValidator,
const wxString &  aName = wxT( "COLLAPSIBLE_PANE_HEADER" ) 
)
inline

Definition at line 42 of file collapsible_pane.h.

47  {
48  init();
49 
50  Create( aParent, aId, aLabel, aPos, aSize, aStyle, aValidator, aName );
51  }
bool Create(wxWindow *aParent, wxWindowID aId, const wxString &aLabel, const wxPoint &aPos=wxDefaultPosition, const wxSize &aSize=wxDefaultSize, long aStyle=wxBORDER_NONE, const wxValidator &aValidator=wxDefaultValidator, const wxString &aName=wxT("COLLAPSIBLE_PANE_HEADER"))

References Create(), and init().

Member Function Documentation

◆ Create()

bool WX_COLLAPSIBLE_PANE_HEADER::Create ( wxWindow *  aParent,
wxWindowID  aId,
const wxString &  aLabel,
const wxPoint &  aPos = wxDefaultPosition,
const wxSize &  aSize = wxDefaultSize,
long  aStyle = wxBORDER_NONE,
const wxValidator &  aValidator = wxDefaultValidator,
const wxString &  aName = wxT( "COLLAPSIBLE_PANE_HEADER" ) 
)

Definition at line 210 of file collapsible_pane.cpp.

213 {
214  if ( !wxControl::Create( aParent, aId, aPos, aSize, aStyle, aValidator, aName ) )
215  return false;
216 
219 
220  SetLabel( aLabel );
221 
222  Bind( wxEVT_PAINT, &WX_COLLAPSIBLE_PANE_HEADER::onPaint, this );
223  Bind( wxEVT_SET_FOCUS, &WX_COLLAPSIBLE_PANE_HEADER::onFocus, this );
224  Bind( wxEVT_KILL_FOCUS, &WX_COLLAPSIBLE_PANE_HEADER::onFocus, this );
225  Bind( wxEVT_ENTER_WINDOW, &WX_COLLAPSIBLE_PANE_HEADER::onEnterWindow, this);
226  Bind( wxEVT_LEAVE_WINDOW, &WX_COLLAPSIBLE_PANE_HEADER::onLeaveWindow, this);
227  Bind( wxEVT_LEFT_UP, &WX_COLLAPSIBLE_PANE_HEADER::onLeftUp, this );
228  Bind( wxEVT_CHAR, &WX_COLLAPSIBLE_PANE_HEADER::onChar, this );
229 
230  return true;
231 }
void onFocus(wxFocusEvent &aEvent)
const BITMAP_OPAQUE triangle_down_xpm[1]
void onEnterWindow(wxMouseEvent &aEvent)
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Construct a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:82
const BITMAP_OPAQUE triangle_right_xpm[1]
void onPaint(wxPaintEvent &aEvent)
void onLeaveWindow(wxMouseEvent &aEvent)
void onChar(wxKeyEvent &aEvent)
void onLeftUp(wxMouseEvent &aEvent)

References KiBitmap(), m_iconDown, m_iconRight, onChar(), onEnterWindow(), onFocus(), onLeaveWindow(), onLeftUp(), onPaint(), triangle_down_xpm, and triangle_right_xpm.

Referenced by WX_COLLAPSIBLE_PANE_HEADER().

◆ DoGetBestClientSize()

wxSize WX_COLLAPSIBLE_PANE_HEADER::DoGetBestClientSize ( ) const
overrideprotected

Definition at line 251 of file collapsible_pane.cpp.

252 {
253  WX_COLLAPSIBLE_PANE_HEADER* self = const_cast<WX_COLLAPSIBLE_PANE_HEADER*>( this );
254 
255  // The code here parallels that of OnPaint() -- except without drawing.
256  wxClientDC dc( self );
257  wxString text;
258 
259  wxControl::FindAccelIndex( GetLabel(), &text );
260 
261  wxSize size = dc.GetTextExtent( text );
262 
263  // Reserve space for icon
264  size.x += m_iconRight.GetWidth();
265  size.y = std::max( size.y, m_iconRight.GetHeight() );
266 
267 #ifdef __WXMSW__
268  size.IncBy( GetSystemMetrics( SM_CXFOCUSBORDER ),
269  GetSystemMetrics( SM_CYFOCUSBORDER ) );
270 #endif // __WXMSW__
271 
272  return size;
273 }
A header control for WX_COLLAPSIBLE_PANE Looks like a static text with a unicode arrow prepended to s...

References m_iconRight.

◆ doSetCollapsed()

void WX_COLLAPSIBLE_PANE_HEADER::doSetCollapsed ( bool  aCollapsed)
private

Definition at line 241 of file collapsible_pane.cpp.

242 {
243  SetCollapsed( aCollapsed );
244 
245  wxCommandEvent evt( WX_COLLAPSIBLE_PANE_HEADER_CHANGED, GetId() );
246  evt.SetEventObject( this );
247  ProcessEvent( evt );
248 }
void SetCollapsed(bool aCollapsed=true)

References SetCollapsed().

Referenced by onChar(), and onLeftUp().

◆ init()

void WX_COLLAPSIBLE_PANE_HEADER::init ( )
private

Definition at line 203 of file collapsible_pane.cpp.

204 {
205  m_collapsed = true;
206  m_inWindow = false;
207 }

References m_collapsed, and m_inWindow.

Referenced by WX_COLLAPSIBLE_PANE_HEADER().

◆ IsCollapsed()

bool WX_COLLAPSIBLE_PANE_HEADER::IsCollapsed ( ) const
inline

Definition at line 61 of file collapsible_pane.h.

62  {
63  return m_collapsed;
64  }

References m_collapsed.

◆ onChar()

void WX_COLLAPSIBLE_PANE_HEADER::onChar ( wxKeyEvent &  aEvent)
private

Definition at line 354 of file collapsible_pane.cpp.

355 {
356  switch( aEvent.GetKeyCode() )
357  {
358  case WXK_SPACE:
359  case WXK_RETURN:
361  break;
362 
363  default:
364  aEvent.Skip();
365  break;
366  }
367 }
void doSetCollapsed(bool aCollapsed)

References doSetCollapsed(), and m_collapsed.

Referenced by Create().

◆ onEnterWindow()

void WX_COLLAPSIBLE_PANE_HEADER::onEnterWindow ( wxMouseEvent &  aEvent)
private

Definition at line 331 of file collapsible_pane.cpp.

332 {
333  m_inWindow = true;
334  Refresh();
335  aEvent.Skip();
336 }
void Refresh()
Update the board display after modifying it by a python script (note: it is automatically called by a...

References m_inWindow, and Refresh().

Referenced by Create().

◆ onFocus()

void WX_COLLAPSIBLE_PANE_HEADER::onFocus ( wxFocusEvent &  aEvent)
private

Definition at line 324 of file collapsible_pane.cpp.

325 {
326  Refresh();
327  aEvent.Skip();
328 }
void Refresh()
Update the board display after modifying it by a python script (note: it is automatically called by a...

References Refresh().

Referenced by Create().

◆ onLeaveWindow()

void WX_COLLAPSIBLE_PANE_HEADER::onLeaveWindow ( wxMouseEvent &  aEvent)
private

Definition at line 339 of file collapsible_pane.cpp.

340 {
341  m_inWindow = false;
342  Refresh();
343  aEvent.Skip();
344 }
void Refresh()
Update the board display after modifying it by a python script (note: it is automatically called by a...

References m_inWindow, and Refresh().

Referenced by Create().

◆ onLeftUp()

void WX_COLLAPSIBLE_PANE_HEADER::onLeftUp ( wxMouseEvent &  aEvent)
private

Definition at line 347 of file collapsible_pane.cpp.

348 {
350  aEvent.Skip();
351 }
void doSetCollapsed(bool aCollapsed)

References doSetCollapsed(), and m_collapsed.

Referenced by Create().

◆ onPaint()

void WX_COLLAPSIBLE_PANE_HEADER::onPaint ( wxPaintEvent &  aEvent)
private

Definition at line 276 of file collapsible_pane.cpp.

277 {
278  wxPaintDC dc( this );
279  wxRect rect( wxPoint( 0, 0 ), GetClientSize() );
280 
281 #ifdef __WXMSW__
282  wxBrush brush = dc.GetBrush();
283  brush.SetColour( GetParent()->GetBackgroundColour() );
284  dc.SetBrush( brush );
285  dc.SetPen( *wxTRANSPARENT_PEN );
286  dc.DrawRectangle( rect );
287 #endif
288 
289  wxString text;
290  int indexAccel = wxControl::FindAccelIndex( GetLabel(), &text );
291 
292  wxSize textSize = dc.GetTextExtent( text );
293  wxRect textRect( wxPoint( m_iconRight.GetWidth(), 0 ), textSize );
294  textRect = textRect.CenterIn( rect, wxVERTICAL );
295 
296  wxBitmap* icon = m_collapsed ? &m_iconRight : &m_iconDown;
297 
298  if( m_inWindow )
299  {
300  dc.SetTextForeground( wxSystemColour::wxSYS_COLOUR_HOTLIGHT );
301  dc.DrawBitmap( icon->ConvertToDisabled( 200 ), wxPoint( 0, 0 ) );
302  }
303  else
304  {
305  dc.DrawBitmap( *icon, wxPoint( 0, 0 ) );
306  }
307 
308  dc.DrawLabel( text, textRect, wxALIGN_CENTER_VERTICAL, indexAccel );
309 
310 #ifdef __WXMSW__
311  int flags = 0;
312 
313  if( m_inWindow )
314  flags |= wxCONTROL_CURRENT;
315 
316  int focusSize = GetSystemMetrics( SM_CXFOCUSBORDER );
317 
318  if( HasFocus() )
319  wxRendererNative::Get().DrawFocusRect( this, dc, textRect.Inflate( focusSize ), flags );
320 #endif
321 }

References m_collapsed, m_iconDown, m_iconRight, and m_inWindow.

Referenced by Create().

◆ SetCollapsed()

void WX_COLLAPSIBLE_PANE_HEADER::SetCollapsed ( bool  aCollapsed = true)

Definition at line 234 of file collapsible_pane.cpp.

235 {
236  m_collapsed = aCollapsed;
237  Refresh();
238 }
void Refresh()
Update the board display after modifying it by a python script (note: it is automatically called by a...

References m_collapsed, and Refresh().

Referenced by WX_COLLAPSIBLE_PANE::Collapse(), and doSetCollapsed().

Member Data Documentation

◆ m_collapsed

bool WX_COLLAPSIBLE_PANE_HEADER::m_collapsed
private

Definition at line 72 of file collapsible_pane.h.

Referenced by init(), IsCollapsed(), onChar(), onLeftUp(), onPaint(), and SetCollapsed().

◆ m_iconDown

wxBitmap WX_COLLAPSIBLE_PANE_HEADER::m_iconDown
private

Definition at line 75 of file collapsible_pane.h.

Referenced by Create(), and onPaint().

◆ m_iconRight

wxBitmap WX_COLLAPSIBLE_PANE_HEADER::m_iconRight
private

Definition at line 74 of file collapsible_pane.h.

Referenced by Create(), DoGetBestClientSize(), and onPaint().

◆ m_inWindow

bool WX_COLLAPSIBLE_PANE_HEADER::m_inWindow
private

Definition at line 73 of file collapsible_pane.h.

Referenced by init(), onEnterWindow(), onLeaveWindow(), and onPaint().

◆ m_label

wxString WX_COLLAPSIBLE_PANE_HEADER::m_label
private

Definition at line 71 of file collapsible_pane.h.


The documentation for this class was generated from the following files: