/usr/include/wx-3.0/wx/rearrangectrl.h is in wx3.0-headers 3.0.0-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 | ///////////////////////////////////////////////////////////////////////////////
// Name: wx/rearrangectrl.h
// Purpose: various controls for rearranging the items interactively
// Author: Vadim Zeitlin
// Created: 2008-12-15
// Copyright: (c) 2008 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_REARRANGECTRL_H_
#define _WX_REARRANGECTRL_H_
#include "wx/checklst.h"
#if wxUSE_REARRANGECTRL
#include "wx/panel.h"
#include "wx/dialog.h"
#include "wx/arrstr.h"
extern WXDLLIMPEXP_DATA_CORE(const char) wxRearrangeListNameStr[];
extern WXDLLIMPEXP_DATA_CORE(const char) wxRearrangeDialogNameStr[];
// ----------------------------------------------------------------------------
// wxRearrangeList: a (check) list box allowing to move items around
// ----------------------------------------------------------------------------
// This class works allows to change the order of the items shown in it as well
// as to check or uncheck them individually. The data structure used to allow
// this is the order array which contains the items indices indexed by their
// position with an added twist that the unchecked items are represented by the
// bitwise complement of the corresponding index (for any architecture using
// two's complement for negative numbers representation (i.e. just about any at
// all) this means that a checked item N is represented by -N-1 in unchecked
// state).
//
// So, for example, the array order [1 -3 0] used in conjunction with the items
// array ["first", "second", "third"] means that the items are displayed in the
// order "second", "third", "first" and the "third" item is unchecked while the
// other two are checked.
class WXDLLIMPEXP_CORE wxRearrangeList : public wxCheckListBox
{
public:
// ctors and such
// --------------
// default ctor, call Create() later
wxRearrangeList() { }
// ctor creating the control, the arguments are the same as for
// wxCheckListBox except for the extra order array which defines the
// (initial) display order of the items as well as their statuses, see the
// description above
wxRearrangeList(wxWindow *parent,
wxWindowID id,
const wxPoint& pos,
const wxSize& size,
const wxArrayInt& order,
const wxArrayString& items,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxRearrangeListNameStr)
{
Create(parent, id, pos, size, order, items, style, validator, name);
}
// Create() function takes the same parameters as the base class one and
// the order array determining the initial display order
bool Create(wxWindow *parent,
wxWindowID id,
const wxPoint& pos,
const wxSize& size,
const wxArrayInt& order,
const wxArrayString& items,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxRearrangeListNameStr);
// items order
// -----------
// get the current items order; the returned array uses the same convention
// as the one passed to the ctor
const wxArrayInt& GetCurrentOrder() const { return m_order; }
// return true if the current item can be moved up or down (i.e. just that
// it's not the first or the last one)
bool CanMoveCurrentUp() const;
bool CanMoveCurrentDown() const;
// move the current item one position up or down, return true if it was moved
// or false if the current item was the first/last one and so nothing was done
bool MoveCurrentUp();
bool MoveCurrentDown();
private:
// swap two items at the given positions in the listbox
void Swap(int pos1, int pos2);
// event handler for item checking/unchecking
void OnCheck(wxCommandEvent& event);
// the current order array
wxArrayInt m_order;
DECLARE_EVENT_TABLE()
wxDECLARE_NO_COPY_CLASS(wxRearrangeList);
};
// ----------------------------------------------------------------------------
// wxRearrangeCtrl: composite control containing a wxRearrangeList and buttons
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxRearrangeCtrl : public wxPanel
{
public:
// ctors/Create function are the same as for wxRearrangeList
wxRearrangeCtrl()
{
Init();
}
wxRearrangeCtrl(wxWindow *parent,
wxWindowID id,
const wxPoint& pos,
const wxSize& size,
const wxArrayInt& order,
const wxArrayString& items,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxRearrangeListNameStr)
{
Init();
Create(parent, id, pos, size, order, items, style, validator, name);
}
bool Create(wxWindow *parent,
wxWindowID id,
const wxPoint& pos,
const wxSize& size,
const wxArrayInt& order,
const wxArrayString& items,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxRearrangeListNameStr);
// get the underlying listbox
wxRearrangeList *GetList() const { return m_list; }
private:
// common part of all ctors
void Init();
// event handlers for the buttons
void OnUpdateButtonUI(wxUpdateUIEvent& event);
void OnButton(wxCommandEvent& event);
wxRearrangeList *m_list;
DECLARE_EVENT_TABLE()
wxDECLARE_NO_COPY_CLASS(wxRearrangeCtrl);
};
// ----------------------------------------------------------------------------
// wxRearrangeDialog: dialog containing a wxRearrangeCtrl
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxRearrangeDialog : public wxDialog
{
public:
// default ctor, use Create() later
wxRearrangeDialog() { Init(); }
// ctor for the dialog: message is shown inside the dialog itself, order
// and items are passed to wxRearrangeList used internally
wxRearrangeDialog(wxWindow *parent,
const wxString& message,
const wxString& title,
const wxArrayInt& order,
const wxArrayString& items,
const wxPoint& pos = wxDefaultPosition,
const wxString& name = wxRearrangeDialogNameStr)
{
Init();
Create(parent, message, title, order, items, pos, name);
}
bool Create(wxWindow *parent,
const wxString& message,
const wxString& title,
const wxArrayInt& order,
const wxArrayString& items,
const wxPoint& pos = wxDefaultPosition,
const wxString& name = wxRearrangeDialogNameStr);
// methods for the dialog customization
// add extra contents to the dialog below the wxRearrangeCtrl part: the
// given window (usually a wxPanel containing more control inside it) must
// have the dialog as its parent and will be inserted into it at the right
// place by this method
void AddExtraControls(wxWindow *win);
// return the wxRearrangeList control used by the dialog
wxRearrangeList *GetList() const;
// get the order of items after it was modified by the user
wxArrayInt GetOrder() const;
private:
// common part of all ctors
void Init() { m_ctrl = NULL; }
wxRearrangeCtrl *m_ctrl;
wxDECLARE_NO_COPY_CLASS(wxRearrangeDialog);
};
#endif // wxUSE_REARRANGECTRL
#endif // _WX_REARRANGECTRL_H_
|