Merge pull request #95 from TcT2k/collpane_enhancement
Improve wxCollapsiblePane appearance Provide native look under MSW and improve the generic appearance (which is now also used under OS X) as well.
This commit is contained in:
97
include/wx/collheaderctrl.h
Normal file
97
include/wx/collheaderctrl.h
Normal file
@@ -0,0 +1,97 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/collheaderctrl.h
|
||||
// Purpose: wxCollapsibleHeaderCtrl
|
||||
// Author: Tobias Taschner
|
||||
// Created: 2015-09-19
|
||||
// Copyright: (c) 2015 wxWidgets development team
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_COLLAPSIBLEHEADER_CTRL_H_
|
||||
#define _WX_COLLAPSIBLEHEADER_CTRL_H_
|
||||
|
||||
#include "wx/defs.h"
|
||||
|
||||
#if wxUSE_COLLPANE
|
||||
|
||||
#include "wx/control.h"
|
||||
|
||||
// class name
|
||||
extern WXDLLIMPEXP_DATA_CORE(const char) wxCollapsibleHeaderCtrlNameStr[];
|
||||
|
||||
//
|
||||
// wxGenericCollapsibleHeaderCtrl
|
||||
//
|
||||
|
||||
class wxCollapsibleHeaderCtrlBase : public wxControl
|
||||
{
|
||||
public:
|
||||
wxCollapsibleHeaderCtrlBase() { }
|
||||
|
||||
wxCollapsibleHeaderCtrlBase(wxWindow *parent,
|
||||
wxWindowID id,
|
||||
const wxString& label,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = wxBORDER_NONE,
|
||||
const wxValidator& validator = wxDefaultValidator,
|
||||
const wxString& name = wxCollapsibleHeaderCtrlNameStr)
|
||||
{
|
||||
Create(parent, id, label, pos, size, style, validator, name);
|
||||
}
|
||||
|
||||
bool Create(wxWindow *parent,
|
||||
wxWindowID id,
|
||||
const wxString& label,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = wxBORDER_NONE,
|
||||
const wxValidator& validator = wxDefaultValidator,
|
||||
const wxString& name = wxCollapsibleHeaderCtrlNameStr);
|
||||
|
||||
virtual void SetCollapsed(bool collapsed = true) = 0;
|
||||
|
||||
virtual bool IsCollapsed() const = 0;
|
||||
|
||||
private:
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(wxCollapsibleHeaderCtrlBase);
|
||||
};
|
||||
|
||||
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COLLAPSIBLEHEADER_CHANGED, wxCommandEvent);
|
||||
|
||||
#define wxCollapsibleHeaderChangedHandler(func) \
|
||||
wxEVENT_HANDLER_CAST(wxCommandEventFunction, func)
|
||||
|
||||
#define EVT_COLLAPSIBLEHEADER_CHANGED(id, fn) \
|
||||
wx__DECLARE_EVT1(wxEVT_COLLAPSIBLEHEADER_CHANGED, id, wxCollapsibleHeaderChangedHandler(fn))
|
||||
|
||||
// There currently only is the native implementation, use for all ports
|
||||
|
||||
#include "wx/generic/collheaderctrl.h"
|
||||
|
||||
class wxCollapsibleHeaderCtrl : public wxGenericCollapsibleHeaderCtrl
|
||||
{
|
||||
public:
|
||||
wxCollapsibleHeaderCtrl() { }
|
||||
|
||||
wxCollapsibleHeaderCtrl(wxWindow *parent,
|
||||
wxWindowID id,
|
||||
const wxString& label,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = wxBORDER_NONE,
|
||||
const wxValidator& validator = wxDefaultValidator,
|
||||
const wxString& name = wxCollapsibleHeaderCtrlNameStr)
|
||||
{
|
||||
Create(parent, id, label, pos, size, style, validator, name);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(wxCollapsibleHeaderCtrl);
|
||||
};
|
||||
|
||||
#endif // wxUSE_COLLPANE
|
||||
|
||||
#endif // _WX_COLLAPSIBLEHEADER_CTRL_H_
|
82
include/wx/generic/collheaderctrl.h
Normal file
82
include/wx/generic/collheaderctrl.h
Normal file
@@ -0,0 +1,82 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/generic/collheaderctrl.h
|
||||
// Purpose: wxGenericCollapsibleHeaderCtrl
|
||||
// Author: Tobias Taschner
|
||||
// Created: 2015-09-19
|
||||
// Copyright: (c) 2015 wxWidgets development team
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_GENERIC_COLLAPSIBLEHEADER_CTRL_H_
|
||||
#define _WX_GENERIC_COLLAPSIBLEHEADER_CTRL_H_
|
||||
|
||||
class wxGenericCollapsibleHeaderCtrl : public wxCollapsibleHeaderCtrlBase
|
||||
{
|
||||
public:
|
||||
wxGenericCollapsibleHeaderCtrl() { Init(); }
|
||||
|
||||
wxGenericCollapsibleHeaderCtrl(wxWindow *parent,
|
||||
wxWindowID id,
|
||||
const wxString& label,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = wxBORDER_NONE,
|
||||
const wxValidator& validator = wxDefaultValidator,
|
||||
const wxString& name = wxCollapsibleHeaderCtrlNameStr)
|
||||
{
|
||||
Init();
|
||||
|
||||
Create(parent, id, label, pos, size, style, validator, name);
|
||||
}
|
||||
|
||||
bool Create(wxWindow *parent,
|
||||
wxWindowID id,
|
||||
const wxString& label,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = wxBORDER_NONE,
|
||||
const wxValidator& validator = wxDefaultValidator,
|
||||
const wxString& name = wxCollapsibleHeaderCtrlNameStr);
|
||||
|
||||
virtual void SetCollapsed(bool collapsed = true) wxOVERRIDE;
|
||||
|
||||
virtual bool IsCollapsed() const wxOVERRIDE
|
||||
{ return m_collapsed; }
|
||||
|
||||
protected:
|
||||
|
||||
virtual wxSize DoGetBestClientSize() const wxOVERRIDE;
|
||||
|
||||
private:
|
||||
bool m_collapsed;
|
||||
bool m_inWindow;
|
||||
bool m_mouseDown;
|
||||
|
||||
void Init();
|
||||
|
||||
void OnPaint(wxPaintEvent& event);
|
||||
|
||||
// Handle set/kill focus events (invalidate for painting focus rect)
|
||||
void OnFocus(wxFocusEvent& event);
|
||||
|
||||
// Handle click
|
||||
void OnLeftUp(wxMouseEvent& event);
|
||||
|
||||
// Handle pressed state
|
||||
void OnLeftDown(wxMouseEvent& event);
|
||||
|
||||
// Handle current state
|
||||
void OnEnterWindow(wxMouseEvent& event);
|
||||
|
||||
void OnLeaveWindow(wxMouseEvent& event);
|
||||
|
||||
// Toggle on space
|
||||
void OnChar(wxKeyEvent& event);
|
||||
|
||||
void DoSetCollapsed(bool collapsed);
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(wxGenericCollapsibleHeaderCtrl);
|
||||
};
|
||||
|
||||
|
||||
#endif // _WX_GENERIC_COLLAPSIBLEHEADER_CTRL_H_
|
@@ -12,11 +12,8 @@
|
||||
#define _WX_COLLAPSABLE_PANE_H_GENERIC_
|
||||
|
||||
// forward declared
|
||||
class WXDLLIMPEXP_FWD_CORE wxButton;
|
||||
class WXDLLIMPEXP_FWD_CORE wxCollapsibleHeaderCtrl;
|
||||
class WXDLLIMPEXP_FWD_CORE wxStaticLine;
|
||||
#if defined( __WXMAC__ ) && !defined(__WXUNIVERSAL__)
|
||||
class WXDLLIMPEXP_FWD_CORE wxDisclosureTriangle;
|
||||
#endif
|
||||
|
||||
#include "wx/containr.h"
|
||||
|
||||
@@ -63,8 +60,7 @@ public:
|
||||
{ return m_pPane==NULL || !m_pPane->IsShown(); }
|
||||
virtual wxWindow *GetPane() const
|
||||
{ return m_pPane; }
|
||||
virtual wxString GetLabel() const
|
||||
{ return m_strLabel; }
|
||||
virtual wxString GetLabel() const;
|
||||
|
||||
virtual bool Layout();
|
||||
|
||||
@@ -80,22 +76,14 @@ protected:
|
||||
// overridden methods
|
||||
virtual wxSize DoGetBestSize() const;
|
||||
|
||||
wxString GetBtnLabel() const;
|
||||
int GetBorder() const;
|
||||
|
||||
// child controls
|
||||
#if defined( __WXMAC__ ) && !defined(__WXUNIVERSAL__)
|
||||
wxDisclosureTriangle *m_pButton;
|
||||
#else
|
||||
wxButton *m_pButton;
|
||||
#endif
|
||||
wxCollapsibleHeaderCtrl *m_pButton;
|
||||
wxStaticLine *m_pStaticLine;
|
||||
wxWindow *m_pPane;
|
||||
wxSizer *m_sz;
|
||||
|
||||
// the button label without ">>" or "<<"
|
||||
wxString m_strLabel;
|
||||
|
||||
private:
|
||||
void Init();
|
||||
|
||||
|
@@ -56,40 +56,4 @@ protected:
|
||||
wxDECLARE_DYNAMIC_CLASS(wxButton);
|
||||
};
|
||||
|
||||
// OS X specific class, not part of public wx API
|
||||
class WXDLLIMPEXP_CORE wxDisclosureTriangle : public wxControl
|
||||
{
|
||||
public:
|
||||
wxDisclosureTriangle(wxWindow *parent,
|
||||
wxWindowID id,
|
||||
const wxString& label = wxEmptyString,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = wxBORDER_NONE,
|
||||
const wxValidator& validator = wxDefaultValidator,
|
||||
const wxString& name = wxButtonNameStr)
|
||||
{
|
||||
Create(parent, id, label, pos, size, style, validator, name);
|
||||
}
|
||||
|
||||
bool Create(wxWindow *parent,
|
||||
wxWindowID id,
|
||||
const wxString& label = wxEmptyString,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = wxBORDER_NONE,
|
||||
const wxValidator& validator = wxDefaultValidator,
|
||||
const wxString& name = wxButtonNameStr);
|
||||
|
||||
void SetOpen( bool open );
|
||||
bool IsOpen() const;
|
||||
|
||||
// osx specific event handling common for all osx-ports
|
||||
|
||||
virtual bool OSXHandleClicked( double timestampsec );
|
||||
|
||||
protected:
|
||||
virtual wxSize DoGetBestSize() const ;
|
||||
};
|
||||
|
||||
#endif // _WX_OSX_BUTTON_H_
|
||||
|
@@ -260,6 +260,17 @@ public:
|
||||
const wxRect& rect,
|
||||
int flags = 0) = 0;
|
||||
|
||||
// draw collapse button
|
||||
//
|
||||
// flags may use wxCONTROL_CHECKED, wxCONTROL_UNDETERMINED and wxCONTROL_CURRENT
|
||||
virtual void DrawCollapseButton(wxWindow *win,
|
||||
wxDC& dc,
|
||||
const wxRect& rect,
|
||||
int flags = 0) = 0;
|
||||
|
||||
// Returns the default size of a collapse button
|
||||
virtual wxSize GetCollapseButtonSize(wxWindow *win, wxDC& dc) = 0;
|
||||
|
||||
// draw rectangle indicating that an item in e.g. a list control
|
||||
// has been selected or focused
|
||||
//
|
||||
@@ -470,6 +481,15 @@ public:
|
||||
int flags = 0)
|
||||
{ m_rendererNative.DrawPushButton( win, dc, rect, flags ); }
|
||||
|
||||
virtual void DrawCollapseButton(wxWindow *win,
|
||||
wxDC& dc,
|
||||
const wxRect& rect,
|
||||
int flags = 0)
|
||||
{ m_rendererNative.DrawCollapseButton(win, dc, rect, flags); }
|
||||
|
||||
virtual wxSize GetCollapseButtonSize(wxWindow *win, wxDC& dc)
|
||||
{ return m_rendererNative.GetCollapseButtonSize(win, dc); }
|
||||
|
||||
virtual void DrawItemSelectionRect(wxWindow *win,
|
||||
wxDC& dc,
|
||||
const wxRect& rect,
|
||||
|
Reference in New Issue
Block a user