~brian-sidebotham/wxwidgets-cmake/wxpython-2.9.4

« back to all changes in this revision

Viewing changes to wxPython/src/combo.i

  • Committer: Brian Sidebotham
  • Date: 2013-08-03 14:30:08 UTC
  • Revision ID: brian.sidebotham@gmail.com-20130803143008-c7806tkych1tp6fc
Initial import into Bazaar

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/////////////////////////////////////////////////////////////////////////////
 
2
// Name:        combo.i
 
3
// Purpose:     SWIG interface for the owner-drawn combobox classes
 
4
//
 
5
// Author:      Robin Dunn
 
6
//
 
7
// Created:     11-Nov-2006
 
8
// RCS-ID:      $Id: combo.i 68064 2011-06-27 21:31:30Z RD $
 
9
// Copyright:   (c) 2006 by Total Control Software
 
10
// Licence:     wxWindows license
 
11
/////////////////////////////////////////////////////////////////////////////
 
12
 
 
13
%define DOCSTRING
 
14
"ComboCtrl class that can have any type of popup widget, and also an
 
15
owner-drawn combobox control."
 
16
%enddef
 
17
 
 
18
%module(package="wx", docstring=DOCSTRING) combo
 
19
 
 
20
%{
 
21
#include "wx/wxPython/wxPython.h"
 
22
#include "wx/wxPython/pyclasses.h"
 
23
 
 
24
#include "wx/wxPython/pytree.h"
 
25
typedef wxTreeCtrl wxPyTreeCtrl;
 
26
        
 
27
#include <wx/combo.h>
 
28
#include <wx/odcombo.h>
 
29
%}
 
30
 
 
31
//---------------------------------------------------------------------------
 
32
 
 
33
%import windows.i
 
34
%import controls.i
 
35
%pythoncode { wx = _core }
 
36
%pythoncode { __docfilter__ = wx.__DocFilter(globals()) }
 
37
 
 
38
//---------------------------------------------------------------------------
 
39
%newgroup
 
40
 
 
41
MAKE_CONST_WXSTRING_NOSWIG(ComboBoxNameStr);
 
42
MAKE_CONST_WXSTRING_NOSWIG(EmptyString);
 
43
 
 
44
%{
 
45
    const wxArrayString wxPyEmptyStringArray;
 
46
%}
 
47
 
 
48
 
 
49
enum {
 
50
    // Button is preferred outside the border (GTK style)
 
51
    wxCC_BUTTON_OUTSIDE_BORDER      = 0x0001,
 
52
    // Show popup on mouse up instead of mouse down (which is the Windows style)
 
53
    wxCC_POPUP_ON_MOUSE_UP          = 0x0002,
 
54
    // All text is not automatically selected on click
 
55
    wxCC_NO_TEXT_AUTO_SELECT        = 0x0004,
 
56
    // Drop-button stays down as long as popup is displayed.    
 
57
    wxCC_BUTTON_STAYS_DOWN          = 0x0008,
 
58
    // Drop-button covers the entire control.
 
59
    wxCC_FULL_BUTTON                = 0x0010,
 
60
    // Drop-button goes over the custom-border (used under WinVista).
 
61
    wxCC_BUTTON_COVERS_BORDER       = 0x0020,
 
62
   
 
63
};
 
64
 
 
65
 
 
66
// Flags used by PreprocessMouseEvent and HandleButtonMouseEvent
 
67
enum
 
68
{
 
69
    wxCC_MF_ON_BUTTON               =   0x0001, // cursor is on dropbutton area
 
70
    wxCC_MF_ON_CLICK_AREA           =   0x0002  // cursor is on dropbutton or other area
 
71
                                                // that can be clicked to show the popup.
 
72
};
 
73
 
 
74
 
 
75
DocStr( wxComboCtrlFeatures,
 
76
        "Namespace for `wx.combo.ComboCtrl` feature flags.  See
 
77
`wx.combo.ComboCtrl.GetFeatures`.", "");
 
78
struct wxComboCtrlFeatures
 
79
{
 
80
    enum
 
81
    {
 
82
        MovableButton       = 0x0001, // Button can be on either side of control
 
83
        BitmapButton        = 0x0002, // Button may be replaced with bitmap
 
84
        ButtonSpacing       = 0x0004, // Button can have spacing from the edge
 
85
                                      // of the control
 
86
        TextIndent          = 0x0008, // SetTextIndent can be used
 
87
        PaintControl        = 0x0010, // Combo control itself can be custom painted
 
88
        PaintWritable       = 0x0020, // A variable-width area in front of writable
 
89
                                      // combo control's textctrl can be custom
 
90
                                      // painted
 
91
        Borderless          = 0x0040, // wxNO_BORDER window style works
 
92
 
 
93
        // There are no feature flags for...
 
94
        // PushButtonBitmapBackground - if its in wxRendererNative, then it should be
 
95
        //   not an issue to have it automatically under the bitmap.
 
96
 
 
97
        All                 = MovableButton|BitmapButton|
 
98
                              ButtonSpacing|TextIndent|
 
99
                              PaintControl|PaintWritable|
 
100
                              Borderless
 
101
    };
 
102
};
 
103
 
 
104
//---------------------------------------------------------------------------
 
105
 
 
106
// C++ implemetation of Python aware wxComboCtrl
 
107
%{
 
108
class wxPyComboCtrl : public wxComboCtrl
 
109
{
 
110
    DECLARE_ABSTRACT_CLASS(wxPyComboCtrl)
 
111
public:
 
112
    wxPyComboCtrl() : wxComboCtrl() {}
 
113
    wxPyComboCtrl(wxWindow *parent,
 
114
                  wxWindowID id = wxID_ANY,
 
115
                  const wxString& value = wxEmptyString,
 
116
                  const wxPoint& pos = wxDefaultPosition,
 
117
                  const wxSize& size = wxDefaultSize,
 
118
                  long style = 0,
 
119
                  const wxValidator& validator = wxDefaultValidator,
 
120
                  const wxString& name = wxPyComboBoxNameStr)
 
121
        : wxComboCtrl(parent, id, value, pos, size, style, validator, name)
 
122
    {}
 
123
 
 
124
    void DoSetPopupControl(wxComboPopup* popup)
 
125
    {
 
126
        bool found;
 
127
        wxPyBlock_t blocked = wxPyBeginBlockThreads();
 
128
        if ((found = wxPyCBH_findCallback(m_myInst, "DoSetPopupControl"))) {
 
129
            PyObject* obj = wxPyConstructObject(popup, wxT("wxComboPopup"), false);
 
130
            wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)",obj));
 
131
            Py_DECREF(obj);
 
132
        }
 
133
        wxPyEndBlockThreads(blocked);
 
134
        if (! found)
 
135
            wxComboCtrl::DoSetPopupControl(popup);
 
136
    }
 
137
 
 
138
    virtual bool IsKeyPopupToggle( const wxKeyEvent& event ) const
 
139
    {
 
140
        bool found;
 
141
        bool rval = false;
 
142
        wxPyBlock_t blocked = wxPyBeginBlockThreads();
 
143
        if ((found = wxPyCBH_findCallback(m_myInst, "OnComboKeyEvent"))) {
 
144
            PyObject* oevt = wxPyConstructObject((void*)&event, wxT("wxKeyEvent"), 0);
 
145
            rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", oevt));
 
146
            Py_DECREF(oevt);
 
147
        }
 
148
        wxPyEndBlockThreads(blocked);
 
149
        if (! found)
 
150
            rval = wxComboCtrl::IsKeyPopupToggle(event);
 
151
        return rval;
 
152
    }
 
153
 
 
154
 
 
155
    virtual wxWindow *GetMainWindowOfCompositeControl()
 
156
    {
 
157
        return wxComboCtrl::GetMainWindowOfCompositeControl();
 
158
    }
 
159
 
 
160
    void DestroyPopup()
 
161
    {
 
162
        wxComboCtrlBase::DestroyPopup();
 
163
    }
 
164
        
 
165
 
 
166
    enum
 
167
    {
 
168
        ShowBelow       = 0x0000,  // Showing popup below the control
 
169
        ShowAbove       = 0x0001,  // Showing popup above the control
 
170
        CanDeferShow    = 0x0002  // Can only return true from AnimateShow if this is set
 
171
    };
 
172
 
 
173
 
 
174
    DEC_PYCALLBACK_VOID_(ShowPopup);
 
175
    DEC_PYCALLBACK_VOID_(HidePopup);
 
176
    DEC_PYCALLBACK_VOID_(OnButtonClick);
 
177
    DEC_PYCALLBACK__RECTINT(DoShowPopup);
 
178
    DEC_PYCALLBACK_BOOL_RECTINT(AnimateShow);
 
179
 
 
180
    PYPRIVATE;
 
181
};
 
182
 
 
183
IMPLEMENT_ABSTRACT_CLASS(wxPyComboCtrl, wxComboCtrl);
 
184
 
 
185
IMP_PYCALLBACK_VOID_(wxPyComboCtrl, wxComboCtrl, ShowPopup);
 
186
IMP_PYCALLBACK_VOID_(wxPyComboCtrl, wxComboCtrl, HidePopup);
 
187
IMP_PYCALLBACK_VOID_(wxPyComboCtrl, wxComboCtrl, OnButtonClick);
 
188
IMP_PYCALLBACK__RECTINT(wxPyComboCtrl, wxComboCtrl, DoShowPopup);
 
189
IMP_PYCALLBACK_BOOL_RECTINT(wxPyComboCtrl, wxComboCtrl, AnimateShow);
 
190
 
 
191
%}
 
192
 
 
193
 
 
194
 
 
195
// Now declare wxPyComboCtrl for Python
 
196
 
 
197
DocStr(wxPyComboCtrl,
 
198
"A combo control is a generic combobox that allows for a totally custom
 
199
popup. In addition it has other customization features. For instance,
 
200
position and size of the dropdown button can be changed.
 
201
 
 
202
To specify what to use for the popup control you need to derive a
 
203
class from `wx.combo.ComboPopup` and pass it to the ComboCtrl with
 
204
`SetPopupControl`.  It doesn't derive from any widget class so it can
 
205
be used either as a mixin class combined with some standard or custom
 
206
widget, or you can use the derived ComboPopup to create and hold an
 
207
independent reference to the widget to be used for the popup.
 
208
", "
 
209
 
 
210
Window Styles
 
211
-------------
 
212
    ====================   ============================================
 
213
    wx.CB_READONLY         Text will not be editable.
 
214
    wx.CB_SORT             Sorts the entries in the list alphabetically.
 
215
    wx.TE_PROCESS_ENTER    The control will generate the event
 
216
                           EVT_TEXT_ENTER (otherwise pressing Enter key
 
217
                           is either processed internally by the control
 
218
                           or used for navigation between dialog controls).
 
219
    wx.CC_SPECIAL_DCLICK   Double-clicking triggers a call to popup's
 
220
                           OnComboDoubleClick. Actual behaviour is defined
 
221
                           by a derived class. For instance,
 
222
                           OwnerDrawnComboBox will cycle an item. This
 
223
                           style only applies if wx.CB_READONLY is used
 
224
                           as well.
 
225
    wx.CC_STD_BUTTON       Drop button will behave more like a standard
 
226
                           push button.
 
227
    ====================   ============================================
 
228
");
 
229
 
 
230
MustHaveApp(wxPyComboCtrl);
 
231
%rename(ComboCtrl) wxPyComboCtrl;
 
232
 
 
233
class wxPyComboCtrl : public wxControl, public wxTextEntry
 
234
{
 
235
public:
 
236
    %pythonAppend wxPyComboCtrl      "self._setOORInfo(self);" setCallbackInfo(ComboCtrl)
 
237
    %pythonAppend wxPyComboCtrl()    "";
 
238
 
 
239
    DocCtorStr(
 
240
        wxPyComboCtrl(wxWindow *parent,
 
241
                      wxWindowID id = wxID_ANY,
 
242
                      const wxString& value = wxEmptyString,
 
243
                      const wxPoint& pos = wxDefaultPosition,
 
244
                      const wxSize& size = wxDefaultSize,
 
245
                      long style = 0,
 
246
                      const wxValidator& validator = wxDefaultValidator,
 
247
                      const wxString& name = wxPyComboBoxNameStr),
 
248
        "", "");
 
249
 
 
250
    DocCtorStrName(
 
251
        wxPyComboCtrl(),
 
252
        "", "",
 
253
        PreComboCtrl);
 
254
 
 
255
 
 
256
    void _setCallbackInfo(PyObject* self, PyObject* _class);
 
257
 
 
258
    
 
259
    virtual void Popup();
 
260
    virtual void Dismiss();
 
261
    
 
262
    DocDeclStr(
 
263
        virtual void , ShowPopup(),
 
264
        "Show the popup window.", "");
 
265
 
 
266
    DocDeclStr(
 
267
        virtual void , HidePopup(),
 
268
        "Dismisses the popup window.", "");
 
269
 
 
270
 
 
271
    // Override for totally custom combo action
 
272
    DocDeclStr(
 
273
        virtual void , OnButtonClick(),
 
274
        "Implement in a derived class to define what happens on dropdown button
 
275
click.  Default action is to show the popup. ", "");
 
276
 
 
277
 
 
278
    // return true if the popup is currently shown
 
279
    DocDeclStr(
 
280
        bool , IsPopupShown() const,
 
281
        "Returns true if the popup is currently shown.", "");
 
282
 
 
283
 
 
284
    %disownarg(wxPyComboPopup* popup);
 
285
    DocDeclStr(
 
286
        void , SetPopupControl( wxPyComboPopup* popup ),
 
287
        "Set popup interface class derived from `wx.combo.ComboPopup`. This
 
288
method should be called as soon as possible after the control has been
 
289
created, unless `OnButtonClick` has been overridden.", "");
 
290
    %cleardisown(wxPyComboPopup* popup);
 
291
 
 
292
 
 
293
    DocDeclStr(
 
294
        wxPyComboPopup* , GetPopupControl(),
 
295
        "Returns the current popup interface that has been set with
 
296
`SetPopupControl`.", "");
 
297
 
 
298
 
 
299
    DocDeclStr(
 
300
        wxWindow *, GetPopupWindow() const,
 
301
        "Returns the popup window containing the popup control.", "");
 
302
 
 
303
 
 
304
    DocDeclStr(
 
305
        wxTextCtrl *, GetTextCtrl() const,
 
306
        "Get the text control which is part of the combo control.", "");
 
307
 
 
308
 
 
309
   DocDeclStr(
 
310
        wxWindow *, GetButton() const,
 
311
        "Get the dropdown button which is part of the combobox.  Note: it's not
 
312
necessarily a wx.Button or wx.BitmapButton.", "");
 
313
 
 
314
    
 
315
// NOTE: These are virtuals defined in a base class, so there
 
316
// shouldn't be any reason to provide SWIG wrappers for them...    
 
317
//     // forward these methods to all subcontrols
 
318
//     virtual bool Enable(bool enable = true);
 
319
//     virtual bool Show(bool show = true);
 
320
//     virtual bool SetFont(const wxFont& font);
 
321
//     virtual void SetValidator(const wxValidator &validator);
 
322
//     virtual wxValidator *GetValidator();
 
323
 
 
324
    
 
325
    // wxTextCtrl methods - for readonly combo they should return
 
326
    // without errors.
 
327
 
 
328
    // Hint functions mirrored from TextEntryBase
 
329
    virtual bool SetHint(const wxString& hint);
 
330
    virtual wxString GetHint() const;
 
331
 
 
332
    // Margins functions mirrored from TextEntryBase
 
333
    // (wxComboCtrl does not inherit from wxTextEntry, but may embed a
 
334
    // wxTextCtrl, so we need these). Also note that these functions
 
335
    // have replaced SetTextIndent() in wxWidgets 2.9.1 and later.
 
336
    bool SetMargins(const wxPoint& pt);
 
337
    bool SetMargins(wxCoord left, wxCoord top = -1);
 
338
    wxPoint GetMargins() const;
 
339
 
 
340
    DocDeclStr(
 
341
        void , SetTextCtrlStyle( int style ),
 
342
        "Set a custom window style for the embedded wxTextCtrl. Usually you
 
343
will need to use this during two-step creation, just before Create().
 
344
For example::
 
345
 
 
346
    class MyComboCtrl(wx.combo.ComboCtrl):
 
347
        def __init__(self, *args, **kwargs):
 
348
            pre = wx.combo.PreComboCtrl()
 
349
            # Let's make the text right-aligned
 
350
            pre.SetTextCtrlStyle(wx.TE_RIGHT)
 
351
            pre.Create(*args, **kwargs);
 
352
            self.PostCreate(pre)
 
353
", "");
 
354
 
 
355
    DocDeclStr(
 
356
        virtual wxString , GetValue() const,
 
357
        "Returns text representation of the current value. For writable combo
 
358
control it always returns the value in the text field.", "");
 
359
 
 
360
    DocDeclStr(
 
361
        virtual void , SetValue(const wxString& value),
 
362
        "Sets the text for the combo control text field.  For a combo control
 
363
with wx.CB_READONLY style the string must be accepted by the popup (for
 
364
instance, exist in the dropdown list), otherwise the call to
 
365
SetValue is ignored.", "");
 
366
 
 
367
    virtual void ChangeValue(const wxString& value);
 
368
    virtual void WriteText(const wxString& text);
 
369
    virtual void AppendText(const wxString& text);
 
370
    virtual wxString GetRange(long from, long to) const;
 
371
    
 
372
    virtual void Copy();
 
373
    virtual void Cut();
 
374
    virtual void Paste();
 
375
    virtual void SetInsertionPoint(long pos);
 
376
    virtual void SetInsertionPointEnd();
 
377
    virtual long GetInsertionPoint() const;
 
378
    virtual long GetLastPosition() const;
 
379
    virtual void Replace(long from, long to, const wxString& value);
 
380
    virtual void Remove(long from, long to);
 
381
    virtual void Undo();
 
382
    virtual void Redo();
 
383
    virtual bool CanUndo() const;
 
384
    virtual bool CanRedo() const;
 
385
 
 
386
    virtual void GetSelection(long *OUTPUT, long *OUTPUT) const;
 
387
 
 
388
    virtual bool IsEditable() const;
 
389
    virtual void SetEditable(bool editable);
 
390
 
 
391
    virtual bool SetHint(const wxString& hint);
 
392
    virtual wxString GetHint() const;
 
393
 
 
394
    %Rename(SetMark, void , SetSelection(long from, long to));
 
395
 
 
396
 
 
397
    DocDeclStr(
 
398
        void , SetText(const wxString& value),
 
399
        "Sets the text for the text field without affecting the popup. Thus,
 
400
unlike `SetValue`, it works equally well with combo control using
 
401
wx.CB_READONLY style.", "");
 
402
 
 
403
 
 
404
    DocDeclStr(
 
405
        void , SetValueWithEvent(const wxString& value, bool withEvent = true),
 
406
        "Same as `SetValue`, but also sends a EVT_TEXT event if withEvent is true.", "");
 
407
 
 
408
    void SetValueByUser(const wxString& value);
 
409
 
 
410
    //
 
411
    // Popup customization methods
 
412
    //
 
413
 
 
414
    DocDeclStr(
 
415
        void , SetPopupMinWidth( int width ),
 
416
        "Sets minimum width of the popup. If wider than combo control, it will
 
417
extend to the left.  A value of -1 indicates to use the default.  The
 
418
popup implementation may choose to ignore this.", "");
 
419
 
 
420
 
 
421
    DocDeclStr(
 
422
        void , SetPopupMaxHeight( int height ),
 
423
        "Sets preferred maximum height of the popup. A value of -1 indicates to
 
424
use the default.  The popup implementation may choose to ignore this.", "");
 
425
 
 
426
 
 
427
    DocDeclStr(
 
428
        void , SetPopupExtents( int extLeft, int extRight ),
 
429
        "Extends popup size horizontally, relative to the edges of the combo
 
430
control.  Values are given in pixels, and the defaults are zero.  It
 
431
is up to the popup to fully take these values into account.", "");
 
432
 
 
433
 
 
434
    DocDeclStr(
 
435
        void , SetCustomPaintWidth( int width ),
 
436
        "Set width, in pixels, of custom painted area in control without
 
437
wx.CB_READONLY style. In read-only OwnerDrawnComboBox, this is used
 
438
to indicate the area that is not covered by the focus rectangle.", "");
 
439
 
 
440
    int GetCustomPaintWidth() const;
 
441
 
 
442
 
 
443
    DocDeclStr(
 
444
        void , SetPopupAnchor( int anchorSide ),
 
445
        "Set side of the control to which the popup will align itself. Valid
 
446
values are wx.LEFT, wx.RIGHT and 0. The default value 0 means that the
 
447
most appropriate side is used (which, currently, is always wx.LEFT).", "");
 
448
 
 
449
 
 
450
    DocDeclStr(
 
451
        void , SetButtonPosition( int width = -1,
 
452
                                  int height = -1,
 
453
                                  int side = wxRIGHT,
 
454
                                  int spacingX = 0 ),
 
455
        "Set the position of the dropdown button.", "");
 
456
 
 
457
 
 
458
    DocDeclStr(
 
459
        wxSize , GetButtonSize(),
 
460
        "Returns current size of the dropdown button.", "");
 
461
 
 
462
 
 
463
    DocDeclStr(
 
464
        void , SetButtonBitmaps( const wxBitmap& bmpNormal,
 
465
                                 bool pushButtonBg = false,
 
466
                                 const wxBitmap& bmpPressed = wxNullBitmap,
 
467
                                 const wxBitmap& bmpHover = wxNullBitmap,
 
468
                                 const wxBitmap& bmpDisabled = wxNullBitmap ),
 
469
        "Sets custom dropdown button graphics.
 
470
 
 
471
    :param bmpNormal:  Default button image
 
472
    :param pushButtonBg: If ``True``, blank push button background is painted below the image.
 
473
    :param bmpPressed:  Depressed button image.
 
474
    :param bmpHover:  Button image to use when the mouse hovers over it.
 
475
    :param bmpDisabled: Disabled button image.
 
476
", "");
 
477
 
 
478
 
 
479
    DocDeclStr(
 
480
        void , SetTextIndent( int indent ),
 
481
        "This will set the space in pixels between left edge of the control and
 
482
the text, regardless whether control is read-only or not. A value of -1 can
 
483
be given to indicate platform default.", "");
 
484
 
 
485
 
 
486
    DocDeclStr(
 
487
        wxCoord , GetTextIndent() const,
 
488
        "Returns actual indentation in pixels.", "");
 
489
 
 
490
 
 
491
    DocDeclStr(
 
492
        const wxRect& , GetTextRect() const,
 
493
        "Returns area covered by the text field (includes everything except
 
494
borders and the dropdown button).", "");
 
495
 
 
496
 
 
497
    DocDeclStr(
 
498
        void , UseAltPopupWindow( bool enable = true ),
 
499
        "Enable or disable usage of an alternative popup window, which
 
500
guarantees ability to focus the popup control, and allows common
 
501
native controls to function normally. This alternative popup window is
 
502
usually a wxDialog, and as such, when it is shown, its parent
 
503
top-level window will appear as if the focus has been lost from it.", "");
 
504
 
 
505
 
 
506
    DocDeclStr(
 
507
        void , EnablePopupAnimation( bool enable = true ),
 
508
        "Enables or disables popup animation, if any, depending on the value of
 
509
the argument.", "");
 
510
 
 
511
 
 
512
    //
 
513
    // Utilies needed by the popups or native implementations
 
514
    //
 
515
 
 
516
    DocDeclStr(
 
517
        virtual bool , IsKeyPopupToggle(const wxKeyEvent& event) const,
 
518
        "Returns true if given key combination should toggle the popup.", "");
 
519
 
 
520
 
 
521
    DocDeclStr(
 
522
        virtual void , PrepareBackground( wxDC& dc, const wxRect& rect, int flags ) const,
 
523
        "Prepare background of combo control or an item in a dropdown list in a
 
524
way typical on platform. This includes painting the focus/disabled
 
525
background and setting the clipping region.  Unless you plan to paint
 
526
your own focus indicator, you should always call this in your
 
527
wxComboPopup::PaintComboControl implementation.  In addition, it sets
 
528
pen and text colour to what looks good and proper against the
 
529
background.
 
530
 
 
531
flags are the same as wx.RendererNative flags:
 
532
 
 
533
    ======================   ============================================
 
534
    wx.CONTROL_ISSUBMENU     drawing a list item instead of combo control
 
535
    wx.CONTROL_SELECTED      list item is selected
 
536
    wx.CONTROL_DISABLED       control/item is disabled
 
537
    ======================   ============================================
 
538
", "");
 
539
 
 
540
 
 
541
 
 
542
    DocDeclStr(
 
543
        bool , ShouldDrawFocus() const,
 
544
        "Returns true if focus indicator should be drawn in the control.", "");
 
545
 
 
546
 
 
547
    const wxBitmap& GetBitmapNormal() const;
 
548
    const wxBitmap& GetBitmapPressed() const;
 
549
    const wxBitmap& GetBitmapHover() const;
 
550
    const wxBitmap& GetBitmapDisabled() const;
 
551
 
 
552
    wxUint32 GetInternalFlags() const;
 
553
 
 
554
    DocDeclStr(
 
555
        bool , IsCreated() const,
 
556
        "Return true if Create has finished", "");
 
557
 
 
558
 
 
559
    DocDeclStr(
 
560
        void , OnPopupDismiss(bool generateEvent),
 
561
        "Common code to be called on popup hide/dismiss", "");
 
562
 
 
563
 
 
564
    // PopupShown states
 
565
    enum
 
566
    {
 
567
        Hidden       = 0,
 
568
        //Closing      = 1,
 
569
        Animating    = 2,
 
570
        Visible      = 3
 
571
    };
 
572
 
 
573
    bool IsPopupWindowState( int state ) const;
 
574
 
 
575
    int GetPopupWindowState() const;
 
576
 
 
577
    // Set value returned by GetMainWindowOfCompositeControl
 
578
    void SetCtrlMainWnd( wxWindow* wnd );
 
579
    virtual wxWindow *GetMainWindowOfCompositeControl();
 
580
    void DestroyPopup();
 
581
 
 
582
    DocDeclStr(
 
583
        static int , GetFeatures(),
 
584
        "Returns a bit-list of flags indicating which features of the ComboCtrl
 
585
functionality are implemented by this implemetation.  See
 
586
`wx.combo.ComboCtrlFeatures`.", "");
 
587
 
 
588
 
 
589
 
 
590
    // Flags for DoShowPopup and AnimateShow
 
591
    enum
 
592
    {
 
593
        ShowBelow       = 0x0000,  // Showing popup below the control
 
594
        ShowAbove       = 0x0001,  // Showing popup above the control
 
595
        CanDeferShow    = 0x0002  // Can only return true from AnimateShow if this is set
 
596
    };
 
597
 
 
598
    // Shows and positions the popup.
 
599
    DocDeclStr(
 
600
        virtual void , DoShowPopup( const wxRect& rect, int flags ),
 
601
        "Shows and positions the popup.
 
602
 
 
603
Flags:
 
604
    ============  =====================================================
 
605
    ShowBelow     Showing popup below the control
 
606
    ShowAbove     Showing popup above the control
 
607
    CanDeferShow  Can only return true from AnimateShow if this is set
 
608
    ============  =====================================================
 
609
", "");
 
610
 
 
611
 
 
612
 
 
613
    DocDeclStr(
 
614
        virtual bool , AnimateShow( const wxRect& rect, int flags ),
 
615
        "Implement in derived class to create a drop-down animation.  Return
 
616
``True`` if finished immediately. Otherwise the popup is only shown when the
 
617
derived class calls `DoShowPopup`.  Flags are same as for `DoShowPopup`.
 
618
", "");
 
619
 
 
620
 
 
621
    %property(PopupControl, GetPopupControl, SetPopupControl);
 
622
    %property(PopupWindow, GetPopupWindow);
 
623
    %property(TextCtrl, GetTextCtrl);
 
624
    %property(Button, GetButton);
 
625
//    %property(InsertionPoint, GetInsertionPoint);
 
626
    %property(CustomPaintWidth, GetCustomPaintWidth, SetCustomPaintWidth);
 
627
    %property(ButtonSize, GetButtonSize);
 
628
    %property(TextIndent, GetTextIndent, SetTextIndent);
 
629
    %property(TextRect, GetTextRect);
 
630
    %property(BitmapNormal, GetBitmapNormal);
 
631
    %property(BitmapPressed, GetBitmapPressed);
 
632
    %property(BitmapHover, GetBitmapHover);
 
633
    %property(BitmapDisabled, GetBitmapDisabled);
 
634
    %property(PopupWindowState, GetPopupWindowState);
 
635
 
 
636
};
 
637
 
 
638
//---------------------------------------------------------------------------
 
639
%newgroup
 
640
 
 
641
 
 
642
// C++ implemetation of Python aware wxComboPopup
 
643
%{
 
644
class wxPyComboPopup : public wxComboPopup
 
645
{
 
646
public:
 
647
    wxPyComboPopup() : wxComboPopup() {}
 
648
    ~wxPyComboPopup() {}
 
649
 
 
650
 
 
651
    DEC_PYCALLBACK_VOID_(Init);
 
652
    DEC_PYCALLBACK_BOOL_WXWIN_pure(Create);
 
653
    DEC_PYCALLBACK_VOID_(OnPopup);
 
654
    DEC_PYCALLBACK_VOID_(OnDismiss);
 
655
    DEC_PYCALLBACK__STRING(SetStringValue);
 
656
    DEC_PYCALLBACK_STRING__constpure(GetStringValue);
 
657
    DEC_PYCALLBACK_VOID_(OnComboDoubleClick);
 
658
    DEC_PYCALLBACK_BOOL_(LazyCreate);
 
659
 
 
660
    virtual wxWindow *GetControl()
 
661
    {
 
662
        wxWindow* rval = NULL;
 
663
        const char* errmsg = "GetControl should return an object derived from wx.Window.";
 
664
        wxPyBlock_t blocked = wxPyBeginBlockThreads();
 
665
        if (wxPyCBH_findCallback(m_myInst, "GetControl")) {
 
666
            PyObject* ro;
 
667
            ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()"));
 
668
            if (ro) {
 
669
                if (!wxPyConvertSwigPtr(ro, (void**)&rval, wxT("wxWindow")))
 
670
                    PyErr_SetString(PyExc_TypeError, errmsg);
 
671
                Py_DECREF(ro);
 
672
            }
 
673
        }
 
674
        else
 
675
            PyErr_SetString(PyExc_TypeError, errmsg);
 
676
        wxPyEndBlockThreads(blocked);
 
677
        return rval;
 
678
    }
 
679
 
 
680
 
 
681
    virtual void PaintComboControl( wxDC& dc, const wxRect& rect )
 
682
    {
 
683
        bool found;
 
684
        wxPyBlock_t blocked = wxPyBeginBlockThreads();
 
685
        if ((found = wxPyCBH_findCallback(m_myInst, "PaintComboControl"))) {
 
686
            PyObject* odc = wxPyMake_wxObject(&dc,false);
 
687
            PyObject* orect = wxPyConstructObject((void*)&rect, wxT("wxRect"), 0);
 
688
            wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OO)", odc, orect));
 
689
            Py_DECREF(odc);
 
690
            Py_DECREF(orect);
 
691
        }
 
692
        wxPyEndBlockThreads(blocked);
 
693
        if (! found)
 
694
            wxComboPopup::PaintComboControl(dc, rect);
 
695
    }
 
696
 
 
697
 
 
698
    virtual void OnComboKeyEvent( wxKeyEvent& event )
 
699
    {
 
700
        bool found;
 
701
        wxPyBlock_t blocked = wxPyBeginBlockThreads();
 
702
        if ((found = wxPyCBH_findCallback(m_myInst, "OnComboKeyEvent"))) {
 
703
            PyObject* oevt = wxPyConstructObject((void*)&event, wxT("wxKeyEvent"), 0);
 
704
            wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", oevt));
 
705
            Py_DECREF(oevt);
 
706
        }
 
707
        wxPyEndBlockThreads(blocked);
 
708
        if (! found)
 
709
            wxComboPopup::OnComboKeyEvent(event);
 
710
    }
 
711
 
 
712
 
 
713
    virtual wxSize GetAdjustedSize( int minWidth, int prefHeight, int maxHeight )
 
714
    {
 
715
        const char* errmsg = "GetAdjustedSize should return a wx.Size or a 2-tuple of integers.";
 
716
        bool found;
 
717
        wxSize rval(0,0);
 
718
        wxSize* rptr = &rval;
 
719
        wxPyBlock_t blocked = wxPyBeginBlockThreads();
 
720
        if ((found = wxPyCBH_findCallback(m_myInst, "GetAdjustedSize"))) {
 
721
            PyObject* ro;
 
722
            ro = wxPyCBH_callCallbackObj(
 
723
                m_myInst, Py_BuildValue("(iii)", minWidth, prefHeight, maxHeight));
 
724
            if (ro) {
 
725
                if (! wxSize_helper(ro, &rptr))
 
726
                    PyErr_SetString(PyExc_TypeError, errmsg);
 
727
                else
 
728
                    rval = *rptr;
 
729
                Py_DECREF(ro);
 
730
            }
 
731
        }
 
732
        wxPyEndBlockThreads(blocked);
 
733
        if (! found)
 
734
            rval = wxComboPopup::GetAdjustedSize(minWidth, prefHeight, maxHeight);
 
735
        return rval;
 
736
    }
 
737
 
 
738
    wxComboCtrl* GetCombo() { return (wxComboCtrl*)m_combo; }
 
739
 
 
740
    PYPRIVATE;
 
741
};
 
742
 
 
743
 
 
744
IMP_PYCALLBACK_VOID_(wxPyComboPopup, wxComboPopup, Init);
 
745
IMP_PYCALLBACK_BOOL_WXWIN_pure(wxPyComboPopup, wxComboPopup, Create);
 
746
IMP_PYCALLBACK_VOID_(wxPyComboPopup, wxComboPopup, OnPopup);
 
747
IMP_PYCALLBACK_VOID_(wxPyComboPopup, wxComboPopup, OnDismiss);
 
748
IMP_PYCALLBACK__STRING(wxPyComboPopup, wxComboPopup, SetStringValue);
 
749
IMP_PYCALLBACK_STRING__constpure(wxPyComboPopup, wxComboPopup, GetStringValue);
 
750
IMP_PYCALLBACK_VOID_(wxPyComboPopup, wxComboPopup, OnComboDoubleClick);
 
751
IMP_PYCALLBACK_BOOL_(wxPyComboPopup, wxComboPopup, LazyCreate);
 
752
 
 
753
%}
 
754
 
 
755
 
 
756
 
 
757
// Now declare wxPyComboPopup for Python
 
758
DocStr(wxPyComboPopup,
 
759
"In order to use a custom popup with `wx.combo.ComboCtrl` an interface
 
760
class derived from wx.combo.ComboPopup is used to manage the interface
 
761
between the popup control and the popup.  You can either derive a new
 
762
class from both the widget class and this ComboPopup class, or the
 
763
derived class can have a reference to the widget used for the popup.
 
764
In either case you simply need to return the widget from the
 
765
`GetControl` method to allow the ComboCtrl to interact with it.
 
766
 
 
767
Nearly all of the methods of this class are overridable in Python.", "");
 
768
 
 
769
 
 
770
MustHaveApp(wxPyComboPopup);
 
771
%rename(ComboPopup) wxPyComboPopup;
 
772
%typemap(out) wxPyComboCtrl*  { $result = wxPyMake_wxObject($1, (bool)$owner); }
 
773
 
 
774
class wxPyComboPopup
 
775
{
 
776
public:
 
777
    %pythonAppend wxPyComboPopup  setCallbackInfo(ComboPopup);
 
778
 
 
779
    DocCtorStr(
 
780
        wxPyComboPopup(),
 
781
        "Constructor", "");
 
782
 
 
783
    DocCtorStr(
 
784
        ~wxPyComboPopup(),
 
785
        "Destructor", "");
 
786
 
 
787
 
 
788
    void _setCallbackInfo(PyObject* self, PyObject* _class);
 
789
 
 
790
    DocDeclStr(
 
791
        virtual void , Init(),
 
792
        "This method is called after the popup is contructed and has been
 
793
assigned to the ComboCtrl.  Derived classes can override this to do
 
794
extra inialization or whatever.", "");
 
795
 
 
796
 
 
797
    // Create the popup child control.
 
798
    // Return true for success.
 
799
    DocDeclStr(
 
800
        virtual bool , Create(wxWindow* parent),
 
801
        "The derived class must implement this method to create the popup
 
802
control.  It should be a child of the ``parent`` passed in, but other
 
803
than that there is much flexibility in what the widget can be, its
 
804
style, etc.  Return ``True`` for success, ``False`` otherwise.  (NOTE:
 
805
this return value is not currently checked...)", "");
 
806
 
 
807
 
 
808
    // Calls Destroy() for the popup control (i.e. one returned by
 
809
    // GetControl()) and makes sure that 'this' is deleted at the end.
 
810
    // Default implementation works for both cases where popup control
 
811
    // class is multiple inherited or created on heap as a separate
 
812
    // object.
 
813
    virtual void DestroyPopup();
 
814
    
 
815
    DocDeclStr(
 
816
        virtual wxWindow *, GetControl(),
 
817
        "The derived class must implement this method and it should return a
 
818
reference to the widget created in the `Create` method.  If the
 
819
derived class inherits from both the widget class and ComboPopup then
 
820
the return value is probably just ``self``.", "");
 
821
 
 
822
 
 
823
    DocDeclStr(
 
824
        virtual void , OnPopup(),
 
825
        "The derived class may implement this to do special processing when
 
826
popup is shown.", "");
 
827
 
 
828
 
 
829
    DocDeclStr(
 
830
        virtual void , OnDismiss(),
 
831
        "The derived class may implement this to do special processing when
 
832
popup is hidden.", "");
 
833
 
 
834
 
 
835
    DocDeclStr(
 
836
        virtual void , SetStringValue( const wxString& value ),
 
837
        "Called just prior to displaying the popup.  The derived class can
 
838
implement this to \"select\" the item in the popup that coresponds to
 
839
the passed in string value, if appropriate.  The default
 
840
implementation does nothing.", "");
 
841
 
 
842
 
 
843
    DocDeclStr(
 
844
        virtual wxString , GetStringValue() const,
 
845
        "Gets the string representation of the currently selected value to be
 
846
used to display in the combo widget.", "");
 
847
 
 
848
 
 
849
    DocDeclStr(
 
850
        virtual void , PaintComboControl( wxDC& dc, const wxRect& rect ),
 
851
        "This is called to custom paint in the combo control itself (ie. not
 
852
the popup).  Default implementation draws the current value as string.", "");
 
853
 
 
854
 
 
855
    DocDeclStr(
 
856
        virtual void , OnComboKeyEvent( wxKeyEvent& event ),
 
857
        "Receives key events from the parent ComboCtrl.  Events not handled
 
858
should be skipped, as usual.", "");
 
859
 
 
860
 
 
861
    DocDeclStr(
 
862
        virtual void , OnComboDoubleClick(),
 
863
        "Implement this method in the derived class if you need to support
 
864
special actions when the user double-clicks on the parent ComboCtrl.", "");
 
865
 
 
866
 
 
867
    DocDeclStr(
 
868
        virtual wxSize , GetAdjustedSize( int minWidth, int prefHeight, int maxHeight ),
 
869
        "The derived class may implement this method to return adjusted size
 
870
for the popup control, according to the variables given.  It is called
 
871
on every popup, just prior to `OnPopup`.
 
872
 
 
873
    :param minWidth:    Preferred minimum width.
 
874
    :param prefHeight:  Preferred height. May be -1 to indicate no preference.
 
875
    :maxWidth:          Max height for window, as limited by screen size, and
 
876
                        should only be rounded down, if necessary.
 
877
", "");
 
878
 
 
879
 
 
880
    DocDeclStr(
 
881
        virtual bool , LazyCreate(),
 
882
        "The derived class may implement this to return ``True`` if it wants to
 
883
delay the call to `Create` until the popup is shown for the first
 
884
time. It is more efficient, but on the other hand it is often more
 
885
convenient to have the control created immediately.  The default
 
886
implementation returns ``False``.", "");
 
887
 
 
888
 
 
889
    //
 
890
    // Utilies
 
891
    //
 
892
 
 
893
 
 
894
    DocDeclStr(
 
895
        void , Dismiss(),
 
896
        "Hides the popup", "");
 
897
 
 
898
 
 
899
    DocDeclStr(
 
900
        bool , IsCreated() const,
 
901
        "Returns true if `Create` has been called.", "");
 
902
 
 
903
 
 
904
    DocDeclStr(
 
905
        wxComboCtrl* , GetComboCtrl() const,
 
906
        "Returns the associated parent ComboCtrl.", "");
 
907
    
 
908
 
 
909
    DocDeclStr(
 
910
        static void , DefaultPaintComboControl( wxComboCtrlBase* combo,
 
911
                                                wxDC& dc,
 
912
                                                const wxRect& rect ),
 
913
        "Default PaintComboControl behaviour", "");
 
914
 
 
915
 
 
916
    DocDeclStr(
 
917
        wxPyComboCtrl* , GetCombo(),
 
918
        "Returns a reference to the `wx.combo.ComboCtrl` this ComboPopup object
 
919
is associated with.", "");
 
920
 
 
921
};
 
922
 
 
923
 
 
924
//---------------------------------------------------------------------------
 
925
%newgroup
 
926
 
 
927
 
 
928
enum {
 
929
    wxODCB_DCLICK_CYCLES,
 
930
    wxODCB_STD_CONTROL_PAINT,
 
931
    wxODCB_PAINTING_CONTROL,
 
932
    wxODCB_PAINTING_SELECTED
 
933
};
 
934
 
 
935
 
 
936
 
 
937
// C++ implemetation of Python aware wxOwnerDrawnComboBox
 
938
%{
 
939
class wxPyOwnerDrawnComboBox : public wxOwnerDrawnComboBox
 
940
{
 
941
public:
 
942
    wxPyOwnerDrawnComboBox() : wxOwnerDrawnComboBox() {}
 
943
    wxPyOwnerDrawnComboBox(wxWindow *parent,
 
944
                           wxWindowID id,
 
945
                           const wxString& value,
 
946
                           const wxPoint& pos,
 
947
                           const wxSize& size,
 
948
                           const wxArrayString& choices,
 
949
                           long style,
 
950
                           const wxValidator& validator = wxDefaultValidator,
 
951
                           const wxString& name = wxPyComboBoxNameStr)
 
952
        : wxOwnerDrawnComboBox(parent, id, value, pos, size, choices, style,
 
953
                               validator, name)
 
954
    {}
 
955
 
 
956
    DEC_PYCALLBACK__DCRECTINTINT_const(OnDrawItem);
 
957
    DEC_PYCALLBACK_COORD_SIZET_const(OnMeasureItem);
 
958
    DEC_PYCALLBACK_COORD_SIZET_const(OnMeasureItemWidth);
 
959
    DEC_PYCALLBACK__DCRECTINTINT_const(OnDrawBackground);
 
960
 
 
961
 
 
962
    PYPRIVATE;
 
963
};
 
964
 
 
965
IMP_PYCALLBACK__DCRECTINTINT_const(wxPyOwnerDrawnComboBox, wxOwnerDrawnComboBox, OnDrawItem);
 
966
IMP_PYCALLBACK_COORD_SIZET_const(wxPyOwnerDrawnComboBox, wxOwnerDrawnComboBox, OnMeasureItem);
 
967
IMP_PYCALLBACK_COORD_SIZET_const(wxPyOwnerDrawnComboBox, wxOwnerDrawnComboBox, OnMeasureItemWidth);
 
968
IMP_PYCALLBACK__DCRECTINTINT_const(wxPyOwnerDrawnComboBox, wxOwnerDrawnComboBox, OnDrawBackground);
 
969
 
 
970
%}
 
971
 
 
972
 
 
973
 
 
974
// Now declare wxPyOwnerDrawnComboBox for Python
 
975
 
 
976
DocStr(wxPyOwnerDrawnComboBox,
 
977
"wx.combo.OwnerDrawnComboBox is a combobox with owner-drawn list
 
978
items. In essence, it is a `wx.combo.ComboCtrl` with a `wx.VListBox`
 
979
popup and a `wx.ControlWithItems` API.
 
980
 
 
981
Implementing item drawing and measuring is similar to wx.VListBox.
 
982
The application needs to subclass wx.combo.OwnerDrawnComboBox and
 
983
implement the `OnDrawItem`, `OnMeasureItem` and `OnMeasureItemWidth`
 
984
methods.", "");
 
985
 
 
986
MustHaveApp(wxPyOwnerDrawnComboBox);
 
987
%rename(OwnerDrawnComboBox) wxPyOwnerDrawnComboBox;
 
988
 
 
989
class wxPyOwnerDrawnComboBox : public wxPyComboCtrl,
 
990
                               public wxItemContainer
 
991
{
 
992
public:
 
993
    %pythonAppend wxPyOwnerDrawnComboBox      "self._setOORInfo(self);" setCallbackInfo(OwnerDrawnComboBox)
 
994
    %pythonAppend wxPyOwnerDrawnComboBox()    "";
 
995
 
 
996
    DocCtorStr(
 
997
        wxPyOwnerDrawnComboBox(wxWindow *parent,
 
998
                               wxWindowID id = -1,
 
999
                               const wxString& value = wxPyEmptyString,
 
1000
                               const wxPoint& pos = wxDefaultPosition,
 
1001
                               const wxSize& size = wxDefaultSize,
 
1002
                               const wxArrayString& choices = wxPyEmptyStringArray,
 
1003
                               long style = 0,
 
1004
                               const wxValidator& validator = wxDefaultValidator,
 
1005
                               const wxString& name = wxPyComboBoxNameStr),
 
1006
        "Standard constructor.", "");
 
1007
 
 
1008
    DocCtorStrName(wxPyOwnerDrawnComboBox(),
 
1009
                   "2-phase create constructor.", "",
 
1010
                   PreOwnerDrawnComboBox);
 
1011
 
 
1012
    void _setCallbackInfo(PyObject* self, PyObject* _class);
 
1013
 
 
1014
    
 
1015
    DocDeclStr(        
 
1016
        bool , Create(wxWindow *parent,
 
1017
                      wxWindowID id = -1,
 
1018
                      const wxString& value = wxPyEmptyString,
 
1019
                      const wxPoint& pos = wxDefaultPosition,
 
1020
                      const wxSize& size = wxDefaultSize,
 
1021
                      const wxArrayString& choices = wxPyEmptyStringArray,
 
1022
                      long style = 0,
 
1023
                      const wxValidator& validator = wxDefaultValidator,
 
1024
                      const wxString& name = wxPyComboBoxNameStr),
 
1025
        "Create the UI object, and other initialization.", "");
 
1026
    
 
1027
 
 
1028
    DocDeclStr(
 
1029
        virtual int , GetWidestItemWidth(),
 
1030
        "Return the widest item width (recalculating it if necessary.)", "");
 
1031
    
 
1032
 
 
1033
    DocDeclStr(
 
1034
        virtual int , GetWidestItem(),
 
1035
        "Return the index of the widest item (recalculating it if necessary.)", "");
 
1036
    
 
1037
 
 
1038
    void SetSelection(int n);
 
1039
    %Rename(SetMark, void , SetSelection(long from, long to));
 
1040
 
 
1041
    // Implemented in wxItemContainer, but hidden in wxPyComboCtrl, so list
 
1042
    // it explicitly here.
 
1043
    %pythoncode { GetString = wx.ItemContainer.GetString }
 
1044
 
 
1045
 
 
1046
    // Callback for drawing. Font, background and text colour have been
 
1047
    // prepared according to selection, focus and such.
 
1048
    // item: item index to be drawn, may be wxNOT_FOUND when painting combo control itself
 
1049
    //       and there is no valid selection
 
1050
    // flags: wxODCB_PAINTING_CONTROL is set if painting to combo control instead of list
 
1051
    DocDeclStr(
 
1052
        virtual void , OnDrawItem( wxDC& dc, const wxRect& rect, int item, int flags ) const,
 
1053
        "The derived class may implement this function to actually draw the
 
1054
item with the given index on the provided DC. If this method is not
 
1055
overridden, the item text is simply drawn as if the control was a
 
1056
normal combobox.
 
1057
 
 
1058
   :param dc:    The device context to use for drawing.
 
1059
   :param rect:  The bounding rectangle for the item being drawn, the
 
1060
                 DC's clipping region is set to this rectangle before
 
1061
                 calling this method.
 
1062
   :param item:  The index of the item to be drawn.
 
1063
 
 
1064
   :param flags: ``wx.combo.ODCB_PAINTING_CONTROL`` (The Combo control itself
 
1065
                  is being painted, instead of a list item.  The ``item``
 
1066
                  parameter may be ``wx.NOT_FOUND`` in this case.
 
1067
                  ``wx.combo.ODCB_PAINTING_SELECTED``  (An item with
 
1068
                  selection background is being painted. The DC's text colour
 
1069
                  should already be correct.
 
1070
", "");
 
1071
    
 
1072
 
 
1073
    DocDeclStr(
 
1074
        virtual wxCoord , OnMeasureItem( size_t item ) const,
 
1075
        "The derived class may implement this method to return the height of
 
1076
the specified item (in pixels).  The default implementation returns
 
1077
text height, as if this control was a normal combobox.", "");
 
1078
    
 
1079
 
 
1080
    DocDeclStr(
 
1081
        virtual wxCoord , OnMeasureItemWidth( size_t item ) const,
 
1082
        "The derived class may implement this method to return the width of the
 
1083
specified item (in pixels). If -1 is returned, then the item text
 
1084
width is used.  The default implementation returns -1.", "");
 
1085
    
 
1086
 
 
1087
    DocDeclStr(
 
1088
        virtual void , OnDrawBackground( wxDC& dc, const wxRect& rect, int item, int flags ) const,
 
1089
        "This method is used to draw the items background and, maybe, a border
 
1090
around it.
 
1091
 
 
1092
The base class version implements a reasonable default behaviour which
 
1093
consists in drawing the selected item with the standard background
 
1094
colour and drawing a border around the item if it is either selected
 
1095
or current.  ``flags`` has the sam meaning as with `OnDrawItem`.", "");
 
1096
    
 
1097
 
 
1098
};
 
1099
 
 
1100
//---------------------------------------------------------------------------
 
1101
 
 
1102
%{
 
1103
#include <wx/bmpcbox.h>
 
1104
%}
 
1105
 
 
1106
DocStr(wxBitmapComboBox,
 
1107
       "A combobox that displays a bitmap in front of the list items. It
 
1108
currently only allows using bitmaps of one size, and resizes itself so
 
1109
that a bitmap can be shown next to the text field.",
 
1110
"
 
1111
 
 
1112
Window Styles
 
1113
-------------
 
1114
    ===================    ============================================
 
1115
    wx.CB_READONLY         Creates a combobox without a text editor. On
 
1116
                           some platforms the control may appear very
 
1117
                           different when this style is used. 
 
1118
    wx.CB_SORT             Sorts the entries in the list alphabetically. 
 
1119
    wx.TE_PROCESS_ENTER    The control will generate the event
 
1120
                           wx.EVT__TEXT_ENTER (otherwise pressing Enter
 
1121
                           key is either processed internally by the
 
1122
                           control or used for navigation between dialog
 
1123
                           controls).
 
1124
    ===================    ============================================
 
1125
");
 
1126
 
 
1127
MustHaveApp(wxBitmapComboBox);
 
1128
 
 
1129
#if defined(__WXMSW__) || defined(__WXGTK__)
 
1130
class wxBitmapComboBox : public wxComboBox
 
1131
#else
 
1132
class wxBitmapComboBox : public wxPyOwnerDrawnComboBox
 
1133
#endif
 
1134
{
 
1135
public:
 
1136
    %pythonAppend wxBitmapComboBox      "self._setOORInfo(self);";
 
1137
    %pythonAppend wxBitmapComboBox()    "";
 
1138
 
 
1139
    DocCtorStr(
 
1140
        wxBitmapComboBox(wxWindow *parent,
 
1141
                         wxWindowID id = -1,
 
1142
                         const wxString& value = wxPyEmptyString,
 
1143
                         const wxPoint& pos = wxDefaultPosition,
 
1144
                         const wxSize& size = wxDefaultSize,
 
1145
                         const wxArrayString& choices = wxPyEmptyStringArray,
 
1146
                         long style = 0,
 
1147
                         const wxValidator& validator = wxDefaultValidator,
 
1148
                         const wxString& name = wxBitmapComboBoxNameStr),
 
1149
        "Standard constructor", "");
 
1150
 
 
1151
    DocCtorStrName(wxBitmapComboBox(),
 
1152
                   "2-phase create constructor.", "",
 
1153
                   PreBitmapComboBox);
 
1154
 
 
1155
    DocDeclStr(
 
1156
        bool , Create(wxWindow *parent,
 
1157
                      wxWindowID id = -1,
 
1158
                      const wxString& value = wxPyEmptyString,
 
1159
                      const wxPoint& pos = wxDefaultPosition,
 
1160
                      const wxSize& size = wxDefaultSize,
 
1161
                      const wxArrayString& choices = wxPyEmptyStringArray,
 
1162
                      long style = 0,
 
1163
                      const wxValidator& validator = wxDefaultValidator,
 
1164
                      const wxString& name = wxBitmapComboBoxNameStr),
 
1165
        "Create the UI object, and other initialization.", "");
 
1166
    
 
1167
 
 
1168
 
 
1169
    %extend {
 
1170
        DocStr(Append,
 
1171
               "Adds the item to the control, associating the given data with the item
 
1172
if not None.  The return value is the index of the newly added item.", "");
 
1173
        int Append(const wxString& item, const wxBitmap& bitmap = wxNullBitmap, PyObject* clientData=NULL) {
 
1174
            if (clientData) {
 
1175
                wxPyClientData* data = new wxPyClientData(clientData);
 
1176
                return self->Append(item, bitmap, data);
 
1177
            } else
 
1178
                return self->Append(item, bitmap);
 
1179
        }
 
1180
    }
 
1181
    
 
1182
    
 
1183
    DocDeclStr(
 
1184
        virtual wxBitmap , GetItemBitmap(/*unsigned*/ int n) const,
 
1185
        "Returns the image of the item with the given index.", "");
 
1186
 
 
1187
    
 
1188
    %extend {
 
1189
        DocStr(Insert,
 
1190
               "Insert an item into the control before the item at the ``pos`` index,
 
1191
optionally associating some data object with the item.", "");
 
1192
        int Insert(const wxString& item, const wxBitmap& bitmap,
 
1193
                   /*unsigned*/ int pos, PyObject* clientData=NULL) {
 
1194
            if (clientData) {
 
1195
                wxPyClientData* data = new wxPyClientData(clientData);
 
1196
                return self->Insert(item, bitmap, pos, data);
 
1197
            } else
 
1198
                return self->Insert(item, bitmap, pos);
 
1199
        }
 
1200
    }
 
1201
 
 
1202
    
 
1203
    DocDeclStr(
 
1204
        virtual void , SetItemBitmap(/*unsigned*/ int n, const wxBitmap& bitmap),
 
1205
        "Sets the image for the given item.", "");
 
1206
    
 
1207
 
 
1208
    DocDeclStr(
 
1209
        virtual wxSize , GetBitmapSize() const,
 
1210
        "Returns size of the image used in list.", "");
 
1211
    
 
1212
 
 
1213
};
 
1214
 
 
1215
//---------------------------------------------------------------------------
 
1216
 
 
1217
%init %{
 
1218
    // Map renamed classes back to their common name for OOR
 
1219
    wxPyPtrTypeMap_Add("wxComboCtrl", "wxPyComboCtrl");
 
1220
    wxPyPtrTypeMap_Add("wxComboPopup", "wxPyComboPopup");
 
1221
    wxPyPtrTypeMap_Add("wxOwnerDrawnComboBox", "wxPyOwnerDrawnComboBox");
 
1222
%}
 
1223
//---------------------------------------------------------------------------
 
1224