implement click events in wxHeaderCtrl

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@57178 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2008-12-08 00:57:53 +00:00
parent ef52f19e6a
commit fa3d4aaf0f
8 changed files with 328 additions and 12 deletions

View File

@@ -74,6 +74,14 @@ private:
// refresh all the controls starting from (and including) the given one
void RefreshColsAfter(unsigned int idx);
// return the column at the given position or -1 if it is beyond the
// rightmost column and put true into onSeparator output parameter if the
// position is near the divider at the right end of this column (notice
// that this means that we return column 0 even if the position is over
// column 1 but close enough to the divider separating it from column 0)
int FindColumnAtPos(int x, bool& onSeparator) const;
// number of columns in the control currently
unsigned int m_numColumns;

View File

@@ -120,7 +120,7 @@ private:
// control, see wxHeaderCtrlSimple for a standalone version
// ----------------------------------------------------------------------------
#if defined(__WXMSW__) && !defined(__WXUNIVERSAL__)
#if 0// defined(__WXMSW__) && !defined(__WXUNIVERSAL__)
#include "wx/msw/headerctrl.h"
#else
#define wxHAS_GENERIC_HEADERCTRL
@@ -236,4 +236,61 @@ private:
DECLARE_NO_COPY_CLASS(wxHeaderCtrlSimple)
};
// ----------------------------------------------------------------------------
// wxHeaderCtrl events
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxHeaderCtrlEvent : public wxNotifyEvent
{
public:
wxHeaderCtrlEvent(wxEventType commandType = wxEVT_NULL, int winid = 0)
: wxNotifyEvent(commandType, winid)
{
}
wxHeaderCtrlEvent(const wxHeaderCtrlEvent& event)
: wxNotifyEvent(event),
m_col(event.m_col)
{
}
int GetColumn() const { return m_col; }
void SetColumn(int col) { m_col = col; }
virtual wxEvent *Clone() const { return new wxHeaderCtrlEvent(*this); }
protected:
// the column affected by the event
int m_col;
private:
DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxHeaderCtrlEvent)
};
extern WXDLLIMPEXP_ADV const wxEventType wxEVT_COMMAND_HEADER_CLICK;
extern WXDLLIMPEXP_ADV const wxEventType wxEVT_COMMAND_HEADER_RIGHT_CLICK;
extern WXDLLIMPEXP_ADV const wxEventType wxEVT_COMMAND_HEADER_MIDDLE_CLICK;
extern WXDLLIMPEXP_ADV const wxEventType wxEVT_COMMAND_HEADER_DCLICK;
extern WXDLLIMPEXP_ADV const wxEventType wxEVT_COMMAND_HEADER_RIGHT_DCLICK;
extern WXDLLIMPEXP_ADV const wxEventType wxEVT_COMMAND_HEADER_MIDDLE_DCLICK;
typedef void (wxEvtHandler::*wxHeaderCtrlEventFunction)(wxHeaderCtrlEvent&);
#define wxHeaderCtrlEventHandler(func) \
(wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent( \
wxHeaderCtrlEventFunction, &func)
#define wx__DECLARE_HEADER_EVT(evt, id, fn) \
wx__DECLARE_EVT1(wxEVT_COMMAND_HEADER_ ## evt, id, wxHeaderCtrlEventHandler(fn))
#define EVT_HEADER_CLICK(id, fn) wx__DECLARE_HEADER_EVT(CLICK, id, fn)
#define EVT_HEADER_RIGHT_CLICK(id, fn) wx__DECLARE_HEADER_EVT(RIGHT_CLICK, id, fn)
#define EVT_HEADER_MIDDLE_CLICK(id, fn) wx__DECLARE_HEADER_EVT(MIDDLE_CLICK, id, fn)
#define EVT_HEADER_DCLICK(id, fn) wx__DECLARE_HEADER_EVT(DCLICK, id, fn)
#define EVT_HEADER_RIGHT_DCLICK(id, fn) wx__DECLARE_HEADER_EVT(RIGHT_DCLICK, id, fn)
#define EVT_HEADER_MIDDLE_DCLICK(id, fn) wx__DECLARE_HEADER_EVT(MIDDLE_DCLICK, id, fn)
#endif // _WX_HEADERCTRL_H_

View File

@@ -60,6 +60,7 @@ private:
// override MSW-specific methods needed for new control
virtual WXDWORD MSWGetStyle(long style, WXDWORD *exstyle) const;
virtual bool MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result);
// common part of all ctors
void Init();
@@ -70,6 +71,10 @@ private:
enum Operation { Set, Insert };
void DoSetOrInsertItem(Operation oper, unsigned int idx);
// send a click or double click event (depending on dblclk value) for the
// click with the given button on the given item
bool SendClickEvent(bool dblclk, unsigned int idx, int button);
// the image list: initially NULL, created on demand
wxImageList *m_imageList;