File: treelist.h

package info (click to toggle)
libwx-perl 1%3A0.9932-9
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 5,300 kB
  • sloc: cpp: 11,064; perl: 8,603; ansic: 711; makefile: 53
file content (298 lines) | stat: -rw-r--r-- 8,658 bytes parent folder | download | duplicates (3)
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
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
%module{Wx};
///////////////////////////////////////////////////////////////////////////////
// Name:        interface/wx/treelist.h
// Purpose:     wxTreeListCtrl class documentation
// Author:      Vadim Zeitlin
// Created:     2011-08-17
// SVN-ID:      $Id$
// Copyright:   (c) 2011 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence:     wxWindows licence
///////////////////////////////////////////////////////////////////////////////

#if WXPERL_W_VERSION_GE( 2, 9, 3 )

#include <wx/treelist.h>

%typemap{wxTreeListItem}{reference};
%typemap{wxTreeListCtrl*}{simple};
%typemap{wxCheckBoxState}{simple};
%typemap{wxAlignment}{simple};
%typemap{wxClientData*}{parsed}{%wxPliUserDataCD*%};

%loadplugin{build::Wx::XSP::Overload};
%loadplugin{build::Wx::XSP::Virtual};
%loadplugin{build::Wx::XSP::Enum};
%loadplugin{build::Wx::XSP::Event};


%VirtualTypeMap{
    %Name{%wxTreeListCtrl*%};
    %ConvertReturn{%(wxTreeListCtrl*)wxPli_sv_2_object( aTHX_ ret, "Wx::TreeListCtrl" )%};
    %TypeChar{%O%};
    %Arguments{%%s%};
};

%VirtualTypeMap{
    %Name{%wxTreeListItem%};
    %ConvertReturn{%*(wxTreeListItem*)wxPli_sv_2_object( aTHX_ ret, "Wx::TreeListItem" )%};
    %TypeChar{%o%};
    %Arguments{%&%s, "Wx::TreeListItem"%};
};


%name{Wx::TreeListItem} class wxTreeListItem
{
public:

%{
static void
wxTreeListItem::CLONE()
  CODE:
    wxPli_thread_sv_clone( aTHX_ CLASS, (wxPliCloneSV)wxPli_detach_object );
%}

    /* wxTreeListItem(); no constructor = no objects are deleteable */
    
    ~wxTreeListItem()
        %code%{  wxPli_thread_sv_unregister( aTHX_ "Wx::TreeListItem", THIS, ST(0) ); %};

    bool IsOk() const;
};

%name{Wx::TreeListItemComparator} class wxTreeListItemComparator
{

public:
  
    wxTreeListItemComparator();
    
    virtual int Compare(wxTreeListCtrl* treelist, unsigned column, wxTreeListItem first, wxTreeListItem second) = 0 %Virtual{pure};

};

enum
{
    wxTL_SINGLE         = 0x0000,       // This is the default anyhow.
    wxTL_MULTIPLE       = 0x0001,       // Allow multiple selection.
    wxTL_CHECKBOX       = 0x0002,       // Show checkboxes in the first column.
    wxTL_3STATE         = 0x0004,       // Allow 3rd state in checkboxes.
    wxTL_USER_3STATE    = 0x0008,       // Allow user to set 3rd state.
    wxTL_NO_HEADER      = 0x0010,
    wxTL_STYLE_MASK     = 0x000F,
    wxTL_DEFAULT_STYLE  = wxTL_SINGLE
};

%Event{%EVT_TREELIST_SELECTION_CHANGED(id, func)%}
      {wxEVT_COMMAND_TREELIST_SELECTION_CHANGED};
%Event{%EVT_TREELIST_ITEM_EXPANDING(id, func)%}
      {wxEVT_COMMAND_TREELIST_ITEM_EXPANDING};
%Event{%EVT_TREELIST_ITEM_EXPANDED(id, func)%}
      {wxEVT_COMMAND_TREELIST_ITEM_EXPANDED};
%Event{%EVT_TREELIST_ITEM_CHECKED(id, func)%}
      {wxEVT_COMMAND_TREELIST_ITEM_CHECKED};
%Event{%EVT_TREELIST_ITEM_ACTIVATED(id, func)%}
      {wxEVT_COMMAND_TREELIST_ITEM_ACTIVATED};
%Event{%EVT_TREELIST_ITEM_CONTEXT_MENU(id, func)%}
      {wxEVT_COMMAND_TREELIST_ITEM_CONTEXT_MENU};
%Event{%EVT_TREELIST_COLUMN_SORTED(id, func)%}
      {wxEVT_COMMAND_TREELIST_COLUMN_SORTED};

%name{Wx::TreeListCtrl} class wxTreeListCtrl : public %name{Wx::Window} wxWindow
{
public:
    
    %name{newDefault} wxTreeListCtrl() %Overload
        %postcall{% wxPli_create_evthandler( aTHX_ RETVAL, CLASS ); %};

    %name{newFull} wxTreeListCtrl(wxWindow* parent,
                   wxWindowID id,
                   const wxPoint& pos = wxDefaultPosition,
                   const wxSize& size = wxDefaultSize,
                   long style = wxTL_DEFAULT_STYLE,
                   const wxString& name = wxTreeListCtrlNameStr) %Overload
        %postcall{% wxPli_create_evthandler( aTHX_ RETVAL, CLASS ); %};

    bool Create(wxWindow* parent,
                wxWindowID id,
                const wxPoint& pos = wxDefaultPosition,
                const wxSize& size = wxDefaultSize,
                long style = wxTL_DEFAULT_STYLE,
                const wxString& name = wxTreeListCtrlNameStr);

%{

void
wxTreeListCtrl::AssignImageList( imagelist )
    wxImageList* imagelist
  CODE:
    wxPli_object_set_deleteable( aTHX_ ST(1), false );
    THIS->AssignImageList( imagelist );

    
wxImageList*
wxTreeListCtrl::GetImageList()
  OUTPUT:
    RETVAL
  CLEANUP:
    wxPli_object_set_deleteable( aTHX_ ST(0), false );

%}

    void SetImageList(wxImageList* imageList);

    int AppendColumn(const wxString& title,
                     int width = wxCOL_WIDTH_AUTOSIZE,
                     wxAlignment align = wxALIGN_LEFT,
                     int flags = wxCOL_RESIZABLE);

    unsigned GetColumnCount() const;

    bool DeleteColumn(unsigned col);

    void ClearColumns();

    void SetColumnWidth(unsigned col, int width);

    int GetColumnWidth(unsigned col) const;

    int WidthFor(const wxString& text) const;

    wxTreeListItem AppendItem(wxTreeListItem parent,
                              const wxString& text,
                              int imageClosed = -1,
                              int imageOpened = -1,
                              wxPliUserDataCD *data = NULL);

    wxTreeListItem InsertItem(wxTreeListItem parent,
                              wxTreeListItem previous,
                              const wxString& text,
                              int imageClosed = -1,
                              int imageOpened = -1,
                              wxPliUserDataCD *data = NULL);

    wxTreeListItem PrependItem(wxTreeListItem parent,
                               const wxString& text,
                               int imageClosed = -1,
                               int imageOpened = -1,
                               wxPliUserDataCD *data = NULL);

    void DeleteItem(wxTreeListItem item);

    void DeleteAllItems();

    wxTreeListItem GetRootItem() const;

    wxTreeListItem GetItemParent(wxTreeListItem item) const;

    wxTreeListItem GetFirstChild(wxTreeListItem item) const;

    wxTreeListItem GetNextSibling(wxTreeListItem item) const;

    wxTreeListItem GetFirstItem() const;

    wxTreeListItem GetNextItem(wxTreeListItem item) const;

    const wxString& GetItemText(wxTreeListItem item, unsigned col = 0) const;

    void SetItemText(wxTreeListItem item, unsigned col, const wxString& text);

    void SetItemText(wxTreeListItem item, const wxString& text);

    void SetItemImage(wxTreeListItem item, int closed, int opened = -1);
 
    wxPliUserDataCD *GetItemData( wxTreeListItem item ) const
      %code{% RETVAL = (wxPliUserDataCD*) THIS->GetItemData( *item ); %};   

    void SetItemData(wxTreeListItem item, wxPliUserDataCD *data);

    void Expand(wxTreeListItem item);

    void Collapse(wxTreeListItem item);

    bool IsExpanded(wxTreeListItem item) const;

    wxTreeListItem GetSelection() const;

%{

void
wxTreeListCtrl::GetSelections()
  PREINIT:
    wxTreeListItems selections;
  PPCODE:
    size_t num = THIS->GetSelections( selections );
    EXTEND( SP, (IV)num );
    for( size_t i = 0; i < num; ++i )
    {
        PUSHs( wxPli_non_object_2_sv( aTHX_ sv_newmortal(),
                                      new wxTreeListItem( selections[i] ),
                                      "Wx::TreeListItem" ) );
    }    
%}

    void Select(wxTreeListItem item);
    
    void Unselect(wxTreeListItem item);

    bool IsSelected(wxTreeListItem item) const;

    void SelectAll();

    void UnselectAll();

    void CheckItem(wxTreeListItem item, wxCheckBoxState state = wxCHK_CHECKED);

    void CheckItemRecursively(wxTreeListItem item,
                              wxCheckBoxState state = wxCHK_CHECKED);

    void UncheckItem(wxTreeListItem item);

    void UpdateItemParentStateRecursively(wxTreeListItem item);

    wxCheckBoxState GetCheckedState(wxTreeListItem item) const;

    bool AreAllChildrenInState(wxTreeListItem item,
                               wxCheckBoxState state) const;

    void SetSortColumn(unsigned col, bool ascendingOrder = true);
    
%{
void
wxTreeListCtrl::GetSortColumn()
  PREINIT:
    unsigned col;
    bool ascendingOrder;
    bool issorted;
  PPCODE:
    issorted = THIS->GetSortColumn( &col, &ascendingOrder );
    EXTEND( SP, 2 );
    if( issorted )
    {
        PUSHs( sv_2mortal( newSVuv( col ) ) );
        PUSHs( sv_2mortal( newSViv( ascendingOrder ) ) );
    }
    else {
        PUSHs( sv_newmortal() );
        PUSHs( sv_newmortal() );
    }

%}

    void SetItemComparator(wxTreeListItemComparator* comparator);

    wxWindow* GetView() const;

};

%name{Wx::TreeListEvent} class wxTreeListEvent : public %name{Wx::NotifyEvent} wxNotifyEvent
{
public:
   
    wxTreeListItem GetItem() const;

    wxCheckBoxState GetOldCheckedState() const;

    unsigned GetColumn() const;
};

#endif