2008-12-05 22:44:54 +00:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: wx/generic/headerctrlg.h
|
|
|
|
// Purpose: Generic wxHeaderCtrl implementation
|
|
|
|
// Author: Vadim Zeitlin
|
|
|
|
// Created: 2008-12-01
|
|
|
|
// RCS-ID: $Id$
|
|
|
|
// Copyright: (c) 2008 Vadim Zeitlin <vadim@wxwidgets.org>
|
|
|
|
// Licence: wxWindows licence
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef _WX_GENERIC_HEADERCTRLG_H_
|
|
|
|
#define _WX_GENERIC_HEADERCTRLG_H_
|
|
|
|
|
|
|
|
#include "wx/event.h"
|
|
|
|
#include "wx/vector.h"
|
2008-12-08 14:40:42 +00:00
|
|
|
#include "wx/overlay.h"
|
2008-12-05 22:44:54 +00:00
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// wxHeaderCtrl
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class WXDLLIMPEXP_CORE wxHeaderCtrl : public wxHeaderCtrlBase
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxHeaderCtrl()
|
|
|
|
{
|
|
|
|
Init();
|
|
|
|
}
|
|
|
|
|
|
|
|
wxHeaderCtrl(wxWindow *parent,
|
|
|
|
wxWindowID id = wxID_ANY,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
|
|
|
long style = wxHD_DEFAULT_STYLE,
|
|
|
|
const wxString& name = wxHeaderCtrlNameStr)
|
|
|
|
{
|
|
|
|
Init();
|
|
|
|
|
|
|
|
Create(parent, id, pos, size, style, name);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Create(wxWindow *parent,
|
|
|
|
wxWindowID id = wxID_ANY,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
|
|
|
long style = wxHD_DEFAULT_STYLE,
|
|
|
|
const wxString& name = wxHeaderCtrlNameStr);
|
|
|
|
|
|
|
|
virtual ~wxHeaderCtrl();
|
|
|
|
|
|
|
|
private:
|
|
|
|
// implement base class pure virtuals
|
2008-12-07 16:00:10 +00:00
|
|
|
virtual void DoSetCount(unsigned int count);
|
2008-12-05 22:44:54 +00:00
|
|
|
virtual unsigned int DoGetCount() const;
|
2008-12-07 16:00:10 +00:00
|
|
|
virtual void DoUpdate(unsigned int idx);
|
|
|
|
|
2008-12-05 22:44:54 +00:00
|
|
|
virtual void DoScrollHorz(int dx);
|
|
|
|
|
2008-12-10 16:09:58 +00:00
|
|
|
virtual void DoSetColumnsOrder(const wxArrayInt& order);
|
|
|
|
virtual wxArrayInt DoGetColumnsOrder() const;
|
|
|
|
|
2008-12-05 22:44:54 +00:00
|
|
|
// override wxWindow methods which must be implemented by a new control
|
|
|
|
virtual wxSize DoGetBestSize() const;
|
|
|
|
|
|
|
|
// common part of all ctors
|
|
|
|
void Init();
|
|
|
|
|
|
|
|
// event handlers
|
|
|
|
void OnPaint(wxPaintEvent& event);
|
|
|
|
void OnMouse(wxMouseEvent& event);
|
2008-12-08 16:30:09 +00:00
|
|
|
void OnKeyDown(wxKeyEvent& event);
|
2008-12-08 14:40:42 +00:00
|
|
|
void OnCaptureLost(wxMouseCaptureLostEvent& event);
|
2008-12-05 22:44:54 +00:00
|
|
|
|
2008-12-11 00:49:34 +00:00
|
|
|
// move the column with given idx at given position (this doesn't generate
|
|
|
|
// any events but does refresh the display)
|
|
|
|
void DoMoveCol(unsigned int idx, unsigned int pos);
|
|
|
|
|
2008-12-08 15:11:21 +00:00
|
|
|
// return the horizontal start position of the given column in physical
|
|
|
|
// coordinates
|
2008-12-05 22:44:54 +00:00
|
|
|
int GetColStart(unsigned int idx) const;
|
|
|
|
|
2008-12-11 00:49:34 +00:00
|
|
|
// and the end position
|
|
|
|
int GetColEnd(unsigned int idx) const;
|
|
|
|
|
2008-12-08 12:15:17 +00:00
|
|
|
// refresh the given column [only]; idx must be valid
|
2008-12-05 22:44:54 +00:00
|
|
|
void RefreshCol(unsigned int idx);
|
|
|
|
|
2008-12-08 12:15:17 +00:00
|
|
|
// refresh the given column if idx is valid
|
|
|
|
void RefreshColIfNotNone(unsigned int idx);
|
|
|
|
|
2008-12-05 22:44:54 +00:00
|
|
|
// refresh all the controls starting from (and including) the given one
|
|
|
|
void RefreshColsAfter(unsigned int idx);
|
|
|
|
|
2008-12-08 00:57:53 +00:00
|
|
|
// 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)
|
2008-12-11 00:49:34 +00:00
|
|
|
unsigned int FindColumnAtPoint(int x, bool *onSeparator = NULL) const;
|
2008-12-08 16:30:09 +00:00
|
|
|
|
|
|
|
// return true if a drag resizing operation is currently in progress
|
|
|
|
bool IsResizing() const;
|
2008-12-08 00:57:53 +00:00
|
|
|
|
2008-12-11 00:49:34 +00:00
|
|
|
// return true if a drag reordering operation is currently in progress
|
|
|
|
bool IsReordering() const;
|
|
|
|
|
|
|
|
// return true if any drag operation is currently in progress
|
|
|
|
bool IsDragging() const { return IsResizing() || IsReordering(); }
|
|
|
|
|
2008-12-08 14:40:42 +00:00
|
|
|
// end any drag operation currently in progress (resizing or reordering)
|
|
|
|
void EndDragging();
|
|
|
|
|
2008-12-11 00:49:34 +00:00
|
|
|
// cancel the drag operation currently in progress and generate an event
|
|
|
|
// about it
|
|
|
|
void CancelDragging();
|
|
|
|
|
2008-12-08 17:33:03 +00:00
|
|
|
// start (if m_colBeingResized is -1) or continue resizing the column
|
|
|
|
//
|
|
|
|
// this generates wxEVT_COMMAND_HEADER_BEGIN_RESIZE/RESIZING events and can
|
|
|
|
// cancel the operation if the user handler decides so
|
|
|
|
void StartOrContinueResizing(unsigned int col, int xPhysical);
|
|
|
|
|
|
|
|
// end the resizing operation currently in progress and generate an event
|
|
|
|
// about it with its cancelled flag set if xPhysical is -1
|
|
|
|
void EndResizing(int xPhysical);
|
|
|
|
|
2008-12-11 00:49:34 +00:00
|
|
|
// same functions as above but for column moving/reordering instead of
|
|
|
|
// resizing
|
|
|
|
void StartReordering(unsigned int col, int xPhysical);
|
2008-12-14 23:12:30 +00:00
|
|
|
|
|
|
|
// returns true if we did drag the column somewhere else or false if we
|
|
|
|
// didn't really move it -- in this case we consider that no reordering
|
|
|
|
// took place and that a normal column click event should be generated
|
|
|
|
bool EndReordering(int xPhysical);
|
2008-12-11 00:49:34 +00:00
|
|
|
|
2008-12-08 17:33:03 +00:00
|
|
|
// constrain the given position to be larger than the start position of the
|
|
|
|
// given column plus its minimal width and return the effective width
|
|
|
|
int ConstrainByMinWidth(unsigned int col, int& xPhysical);
|
2008-12-08 14:40:42 +00:00
|
|
|
|
2008-12-11 00:49:34 +00:00
|
|
|
// update the information displayed while a column is being moved around
|
|
|
|
void UpdateReorderingMarker(int xPhysical);
|
|
|
|
|
|
|
|
// clear any overlaid markers
|
|
|
|
void ClearMarkers();
|
|
|
|
|
2008-12-08 00:57:53 +00:00
|
|
|
|
2008-12-07 16:00:10 +00:00
|
|
|
// number of columns in the control currently
|
|
|
|
unsigned int m_numColumns;
|
|
|
|
|
2008-12-05 22:44:54 +00:00
|
|
|
// index of the column under mouse or -1 if none
|
|
|
|
unsigned int m_hover;
|
|
|
|
|
2008-12-08 14:40:42 +00:00
|
|
|
// the column being resized or -1 if there is no resizing operation in
|
|
|
|
// progress
|
|
|
|
unsigned int m_colBeingResized;
|
|
|
|
|
2008-12-11 00:49:34 +00:00
|
|
|
// the column being moved or -1 if there is no reordering operation in
|
|
|
|
// progress
|
|
|
|
unsigned int m_colBeingReordered;
|
|
|
|
|
|
|
|
// the distance from the start of m_colBeingReordered and the mouse
|
|
|
|
// position when the user started to drag it
|
|
|
|
int m_dragOffset;
|
|
|
|
|
2008-12-05 22:44:54 +00:00
|
|
|
// the horizontal scroll offset
|
|
|
|
int m_scrollOffset;
|
|
|
|
|
2008-12-08 14:40:42 +00:00
|
|
|
// the overlay display used during the dragging operations
|
|
|
|
wxOverlay m_overlay;
|
|
|
|
|
2008-12-10 16:09:58 +00:00
|
|
|
// the indices of the column appearing at the given position on the display
|
|
|
|
// (its size is always m_numColumns)
|
|
|
|
wxArrayInt m_colIndices;
|
|
|
|
|
2008-12-05 22:44:54 +00:00
|
|
|
|
|
|
|
DECLARE_EVENT_TABLE()
|
2009-02-08 11:45:59 +00:00
|
|
|
wxDECLARE_NO_COPY_CLASS(wxHeaderCtrl);
|
2008-12-05 22:44:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // _WX_GENERIC_HEADERCTRLG_H_
|
|
|
|
|