2008-12-03 16:53:10 -05:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: wx/msw/headerctrl.h
|
|
|
|
// Purpose: wxMSW native wxHeaderCtrl
|
|
|
|
// Author: Vadim Zeitlin
|
|
|
|
// Created: 2008-12-01
|
|
|
|
// RCS-ID: $Id$
|
|
|
|
// Copyright: (c) 2008 Vadim Zeitlin <vadim@wxwidgets.org>
|
|
|
|
// Licence: wxWindows licence
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef _WX_MSW_HEADERCTRL_H_
|
|
|
|
#define _WX_MSW_HEADERCTRL_H_
|
|
|
|
|
|
|
|
class WXDLLIMPEXP_FWD_CORE wxImageList;
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// 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();
|
|
|
|
|
2008-12-05 17:11:27 -05:00
|
|
|
|
2008-12-03 16:53:10 -05:00
|
|
|
private:
|
|
|
|
// implement base class pure virtuals
|
2008-12-07 09:47:55 -05:00
|
|
|
virtual void DoSetCount(unsigned int count);
|
2008-12-03 16:53:10 -05:00
|
|
|
virtual unsigned int DoGetCount() const;
|
2008-12-07 09:47:55 -05:00
|
|
|
virtual void DoUpdate(unsigned int idx);
|
|
|
|
|
2008-12-05 17:43:37 -05:00
|
|
|
virtual void DoScrollHorz(int dx);
|
2008-12-03 16:53:10 -05:00
|
|
|
|
2008-12-10 10:56:11 -05:00
|
|
|
virtual void DoSetColumnsOrder(const wxArrayInt& order);
|
|
|
|
virtual wxArrayInt DoGetColumnsOrder() const;
|
|
|
|
|
2008-12-03 16:53:10 -05:00
|
|
|
// override wxWindow methods which must be implemented by a new control
|
|
|
|
virtual wxSize DoGetBestSize() const;
|
2008-12-11 17:06:55 -05:00
|
|
|
virtual void DoSetSize(int x, int y,
|
|
|
|
int width, int height,
|
|
|
|
int sizeFlags = wxSIZE_AUTO);
|
2008-12-03 16:53:10 -05:00
|
|
|
|
|
|
|
// override MSW-specific methods needed for new control
|
|
|
|
virtual WXDWORD MSWGetStyle(long style, WXDWORD *exstyle) const;
|
2008-12-07 19:57:53 -05:00
|
|
|
virtual bool MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result);
|
2008-12-03 16:53:10 -05:00
|
|
|
|
|
|
|
// common part of all ctors
|
|
|
|
void Init();
|
|
|
|
|
2008-12-14 17:06:58 -05:00
|
|
|
// wrapper around Header_InsertItem(): insert the item using information
|
|
|
|
// from the given column at the given index
|
|
|
|
void DoInsertItem(const wxHeaderColumn& col, unsigned int idx);
|
|
|
|
|
|
|
|
// get the number of currently visible items: this is also the total number
|
|
|
|
// of items contained in the native control
|
|
|
|
int GetShownColumnsCount() const;
|
|
|
|
|
|
|
|
// due to the discrepancy for the hidden columns which we know about but
|
|
|
|
// the native control does not, there can be a difference between the
|
|
|
|
// column indices we use and the ones used by the native control; these
|
|
|
|
// functions translate between them
|
|
|
|
//
|
|
|
|
// notice that MSWToNativeIdx() shouldn't be called for hidden columns and
|
|
|
|
// MSWFromNativeIdx() always returns an index of a visible column
|
|
|
|
int MSWToNativeIdx(int idx);
|
|
|
|
int MSWFromNativeIdx(int item);
|
|
|
|
|
|
|
|
// this is the same as above but for order, not index
|
2008-12-14 17:54:34 -05:00
|
|
|
int MSWToNativeOrder(int order);
|
2008-12-14 17:06:58 -05:00
|
|
|
int MSWFromNativeOrder(int order);
|
2008-12-07 09:47:55 -05:00
|
|
|
|
2008-12-08 09:40:42 -05:00
|
|
|
// get the event type corresponding to a click or double click event
|
|
|
|
// (depending on dblclk value) with the specified (using MSW convention)
|
|
|
|
// mouse button
|
|
|
|
wxEventType GetClickEventType(bool dblclk, int button);
|
2008-12-07 19:57:53 -05:00
|
|
|
|
2008-12-07 09:47:55 -05:00
|
|
|
|
2008-12-14 17:06:58 -05:00
|
|
|
// the number of columns in the control, including the hidden ones (not
|
|
|
|
// taken into account by the native control, see comment in DoGetCount())
|
|
|
|
unsigned int m_numColumns;
|
|
|
|
|
|
|
|
// this is a lookup table allowing us to check whether the column with the
|
|
|
|
// given index is currently shown in the native control, in which case the
|
|
|
|
// value of this array element with this index is 0, or hidden
|
|
|
|
//
|
|
|
|
// notice that this may be different from GetColumn(idx).IsHidden() and in
|
|
|
|
// fact we need this array precisely because it will be different from it
|
|
|
|
// in DoUpdate() when the column hidden flag gets toggled and we need it to
|
|
|
|
// handle this transition correctly
|
|
|
|
wxArrayInt m_isHidden;
|
|
|
|
|
|
|
|
// the order of our columns: this array contains the index of the column
|
|
|
|
// shown at the position n as the n-th element
|
|
|
|
//
|
|
|
|
// this is necessary only to handle the hidden columns: the native control
|
|
|
|
// doesn't know about them and so we can't use Header_GetOrderArray()
|
|
|
|
wxArrayInt m_colIndices;
|
|
|
|
|
2008-12-03 16:53:10 -05:00
|
|
|
// the image list: initially NULL, created on demand
|
|
|
|
wxImageList *m_imageList;
|
|
|
|
|
2008-12-11 17:06:55 -05:00
|
|
|
// the offset of the window used to emulate scrolling it
|
|
|
|
int m_scrollOffset;
|
|
|
|
|
2009-02-08 06:45:59 -05:00
|
|
|
wxDECLARE_NO_COPY_CLASS(wxHeaderCtrl);
|
2008-12-03 16:53:10 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // _WX_MSW_HEADERCTRL_H_
|
|
|
|
|