1 /////////////////////////////////////////////////////////////////////////////
 
   3 // Purpose:     SWIG definitions for StatusBar and ToolBar classes
 
   9 // Copyright:   (c) 1998 by Total Control Software
 
  10 // Licence:     wxWindows license
 
  11 /////////////////////////////////////////////////////////////////////////////
 
  18 #include <wx/toolbar.h>
 
  19 #include <wx/tbarsmpl.h>
 
  22 //----------------------------------------------------------------------
 
  25 %include my_typemaps.i
 
  27 // Import some definitions of other classes, etc.
 
  33 %pragma(python) code = "import wx"
 
  34 %pragma(python) code = "wxITEM_NORMAL = 0 # predeclare this since wx isn't fully imported yet"
 
  36 //----------------------------------------------------------------------
 
  39     // Put some wx default wxChar* values into wxStrings.
 
  40     DECLARE_DEF_STRING(StatusLineNameStr);
 
  41     DECLARE_DEF_STRING(ToolBarNameStr);
 
  42     static const wxString wxPyEmptyString(wxT(""));
 
  45 //---------------------------------------------------------------------------
 
  47 class wxStatusBar : public wxWindow {
 
  49     wxStatusBar(wxWindow* parent, wxWindowID id = -1,
 
  50                 long style = wxST_SIZEGRIP,
 
  51                 const wxString& name = wxPyStatusLineNameStr);
 
  52     %name(wxPreStatusBar)wxStatusBar();
 
  54     bool Create(wxWindow* parent, wxWindowID id,
 
  55                 long style = wxST_SIZEGRIP,
 
  56                 const wxString& name = wxPyStatusLineNameStr);
 
  58     %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
 
  59     %pragma(python) addtomethod = "wxPreStatusBar:val._setOORInfo(val)"
 
  62         %new wxRect* GetFieldRect(long item) {
 
  63             wxRect* rect= new wxRect;
 
  64             self->GetFieldRect(item, *rect);
 
  68     int GetFieldsCount(void);
 
  69     wxString GetStatusText(int ir = 0);
 
  73     void SetFieldsCount(int number = 1);
 
  74     void SetStatusText(const wxString& text, int i = 0);
 
  75     void SetStatusWidths(int LCOUNT, int* choices);
 
  76     void PushStatusText(const wxString& text, int number = 0);
 
  77     void PopStatusText(int number = 0);
 
  79     void SetMinHeight(int height);
 
  83 //---------------------------------------------------------------------------
 
  87 enum wxToolBarToolStyle
 
  89     wxTOOL_STYLE_BUTTON    = 1,
 
  90     wxTOOL_STYLE_SEPARATOR = 2,
 
  96 class wxToolBarToolBase : public wxObject {
 
  98 //      wxToolBarToolBase(wxToolBarBase *tbar = (wxToolBarBase *)NULL,
 
  99 //                        int id = wxID_SEPARATOR,
 
 100 //                        const wxString& label = wxEmptyString,
 
 101 //                        const wxBitmap& bmpNormal = wxNullBitmap,
 
 102 //                        const wxBitmap& bmpDisabled = wxNullBitmap,
 
 103 //                        wxItemKind kind = wxITEM_NORMAL,
 
 104 //                        wxObject *clientData = (wxObject *) NULL,
 
 105 //                        const wxString& shortHelpString = wxEmptyString,
 
 106 //                        const wxString& longHelpString = wxEmptyString)
 
 107 //      ~wxToolBarToolBase();
 
 109     %addmethods { void Destroy() { delete self; } }
 
 112     wxControl *GetControl();
 
 113     wxToolBarBase *GetToolBar();
 
 118     wxItemKind GetKind();
 
 122     const wxBitmap& GetNormalBitmap();
 
 123     const wxBitmap& GetDisabledBitmap();
 
 124     wxBitmap GetBitmap();
 
 126     wxString GetShortHelp();
 
 127     wxString GetLongHelp();
 
 128     bool Enable(bool enable);
 
 130     bool SetToggle(bool toggle);
 
 131     bool SetShortHelp(const wxString& help);
 
 132     bool SetLongHelp(const wxString& help);
 
 133     void SetNormalBitmap(const wxBitmap& bmp);
 
 134     void SetDisabledBitmap(const wxBitmap& bmp);
 
 135     void SetLabel(const wxString& label);
 
 137     void Attach(wxToolBarBase *tbar);
 
 139     //wxObject *GetClientData();
 
 141         // convert the ClientData back to a PyObject
 
 142         PyObject* GetClientData() {
 
 143             wxPyUserData* udata = (wxPyUserData*)self->GetClientData();
 
 145                 Py_INCREF(udata->m_obj);
 
 153         void SetClientData(PyObject* clientData) {
 
 154             self->SetClientData(new wxPyUserData(clientData));
 
 158     %pragma(python) addtoclass="
 
 159     GetBitmap1 = GetNormalBitmap
 
 160     GetBitmap2 = GetDisabledBitmap
 
 161     SetBitmap1 = SetNormalBitmap
 
 162     SetBitmap2 = SetDisabledBitmap
 
 168 class wxToolBarBase : public wxControl {
 
 171     // This is an Abstract Base Class
 
 175         // The full AddTool() function.  Call it DoAddTool in wxPython and
 
 176         // implement the other Add methods by calling it.
 
 178         // If bmpDisabled is wxNullBitmap, a shadowed version of the normal bitmap
 
 179         // is created and used as the disabled image.
 
 180         wxToolBarToolBase *DoAddTool(int id,
 
 181                                      const wxString& label,
 
 182                                      const wxBitmap& bitmap,
 
 183                                      const wxBitmap& bmpDisabled = wxNullBitmap,
 
 184                                      wxItemKind kind = wxITEM_NORMAL,
 
 185                                      const wxString& shortHelp = wxPyEmptyString,
 
 186                                      const wxString& longHelp = wxPyEmptyString,
 
 187                                      PyObject *clientData = NULL)
 
 189             wxPyUserData* udata = NULL;
 
 190             if (clientData && clientData != Py_None)
 
 191                 udata = new wxPyUserData(clientData);
 
 192             return self->AddTool(id, label, bitmap, bmpDisabled, kind,
 
 193                                  shortHelp, longHelp, udata);
 
 197         // Insert the new tool at the given position, if pos == GetToolsCount(), it
 
 198         // is equivalent to DoAddTool()
 
 199         wxToolBarToolBase *DoInsertTool(size_t pos,
 
 201                                       const wxString& label,
 
 202                                       const wxBitmap& bitmap,
 
 203                                       const wxBitmap& bmpDisabled = wxNullBitmap,
 
 204                                       wxItemKind kind = wxITEM_NORMAL,
 
 205                                       const wxString& shortHelp = wxPyEmptyString,
 
 206                                       const wxString& longHelp = wxPyEmptyString,
 
 207                                       PyObject *clientData = NULL)
 
 209             wxPyUserData* udata = NULL;
 
 210             if (clientData && clientData != Py_None)
 
 211                 udata = new wxPyUserData(clientData);
 
 212             return self->InsertTool(pos, id, label, bitmap, bmpDisabled, kind,
 
 213                                     shortHelp, longHelp, udata);
 
 219     %pragma(python) addtoclass = "
 
 220     # These match the original Add methods for this class, kept for
 
 221     # backwards compatibility with versions < 2.3.3.
 
 224     def AddTool(self, id, bitmap,
 
 225                 pushedBitmap = wxNullBitmap,
 
 228                 shortHelpString = '',
 
 229                 longHelpString = '') :
 
 230         '''Old style method to add a tool to the toolbar.'''
 
 231         kind = wx.wxITEM_NORMAL
 
 232         if isToggle: kind = wx.wxITEM_CHECK
 
 233         return self.DoAddTool(id, '', bitmap, pushedBitmap, kind,
 
 234                               shortHelpString, longHelpString, clientData)
 
 236     def AddSimpleTool(self, id, bitmap,
 
 237                       shortHelpString = '',
 
 240         '''Old style method to add a tool to the toolbar.'''
 
 241         kind = wx.wxITEM_NORMAL
 
 242         if isToggle: kind = wx.wxITEM_CHECK
 
 243         return self.DoAddTool(id, '', bitmap, wxNullBitmap, kind,
 
 244                               shortHelpString, longHelpString, None)
 
 246     def InsertTool(self, pos, id, bitmap,
 
 247                    pushedBitmap = wxNullBitmap,
 
 250                    shortHelpString = '',
 
 251                    longHelpString = ''):
 
 252         '''Old style method to insert a tool in the toolbar.'''
 
 253         kind = wx.wxITEM_NORMAL
 
 254         if isToggle: kind = wx.wxITEM_CHECK
 
 255         return self.DoInsertTool(pos, id, '', bitmap, pushedBitmap, kind,
 
 256                                  shortHelpString, longHelpString, clientData)
 
 258     def InsertSimpleTool(self, pos, id, bitmap,
 
 259                          shortHelpString = '',
 
 262         '''Old style method to insert a tool in the toolbar.'''
 
 263         kind = wx.wxITEM_NORMAL
 
 264         if isToggle: kind = wx.wxITEM_CHECK
 
 265         return self.DoInsertTool(pos, id, '', bitmap, wxNullBitmap, kind,
 
 266                                  shortHelpString, longHelpString, None)
 
 269     # The following are the new toolbar Add methods starting with
 
 270     # 2.3.3.  They are renamed to have 'Label' in the name so as to be
 
 271     # able to keep backwards compatibility with using the above
 
 272     # methods.  Eventually these should migrate to be the methods used
 
 273     # primarily and lose the 'Label' in the name...
 
 275     def AddLabelTool(self, id, label, bitmap,
 
 276                      bmpDisabled = wxNullBitmap,
 
 277                      kind = wxITEM_NORMAL,
 
 278                      shortHelp = '', longHelp = '',
 
 281         The full AddTool() function.
 
 283         If bmpDisabled is wxNullBitmap, a shadowed version of the normal bitmap
 
 284         is created and used as the disabled image.
 
 286         return self.DoAddTool(id, label, bitmap, bmpDisabled, kind,
 
 287                               shortHelp, longHelp, clientData)
 
 290     def InsertLabelTool(self, pos, id, label, bitmap,
 
 291                         bmpDisabled = wxNullBitmap,
 
 292                         kind = wxITEM_NORMAL,
 
 293                         shortHelp = '', longHelp = '',
 
 296         Insert the new tool at the given position, if pos == GetToolsCount(), it
 
 297         is equivalent to AddTool()
 
 299         return self.DoInsertTool(pos, id, label, bitmap, bmpDisabled, kind,
 
 300                                  shortHelp, longHelp, clientData)
 
 302     def AddCheckLabelTool(self, id, label, bitmap,
 
 303                         bmpDisabled = wxNullBitmap,
 
 304                         shortHelp = '', longHelp = '',
 
 306         '''Add a check tool, i.e. a tool which can be toggled'''
 
 307         return self.DoAddTool(id, label, bitmap, bmpDisabled, wx.wxITEM_CHECK,
 
 308                               shortHelp, longHelp, clientData)
 
 310     def AddRadioLabelTool(self, id, label, bitmap,
 
 311                           bmpDisabled = wxNullBitmap,
 
 312                           shortHelp = '', longHelp = '',
 
 315         Add a radio tool, i.e. a tool which can be toggled and releases any
 
 316         other toggled radio tools in the same group when it happens
 
 318         return self.DoAddTool(id, label, bitmap, bmpDisabled, wx.wxITEM_RADIO,
 
 319                               shortHelp, longHelp, clientData)
 
 322     # For consistency with the backwards compatible methods above, here are
 
 323     # some non-'Label' versions of the Check and Radio methods
 
 324     def AddCheckTool(self, id, bitmap,
 
 325                      bmpDisabled = wxNullBitmap,
 
 326                      shortHelp = '', longHelp = '',
 
 328         '''Add a check tool, i.e. a tool which can be toggled'''
 
 329         return self.DoAddTool(id, '', bitmap, bmpDisabled, wx.wxITEM_CHECK,
 
 330                               shortHelp, longHelp, clientData)
 
 332     def AddRadioTool(self, id, bitmap,
 
 333                      bmpDisabled = wxNullBitmap,
 
 334                      shortHelp = '', longHelp = '',
 
 337         Add a radio tool, i.e. a tool which can be toggled and releases any
 
 338         other toggled radio tools in the same group when it happens
 
 340         return self.DoAddTool(id, '', bitmap, bmpDisabled, wx.wxITEM_RADIO,
 
 341                               shortHelp, longHelp, clientData)
 
 345     //wxToolBarToolBase *AddTool (wxToolBarToolBase *tool);
 
 346     //wxToolBarToolBase *InsertTool (size_t pos, wxToolBarToolBase *tool);
 
 348     wxToolBarToolBase *AddControl(wxControl *control);
 
 349     wxToolBarToolBase *InsertControl(size_t pos, wxControl *control);
 
 350     wxControl *FindControl( int id );
 
 352     wxToolBarToolBase *AddSeparator();
 
 353     wxToolBarToolBase *InsertSeparator(size_t pos);
 
 355     wxToolBarToolBase *RemoveTool(int id);
 
 357     bool DeleteToolByPos(size_t pos);
 
 358     bool DeleteTool(int id);
 
 362     void EnableTool(int id, bool enable);
 
 363     void ToggleTool(int id, bool toggle);
 
 364     void SetToggle(int id, bool toggle);
 
 368         // convert the ClientData back to a PyObject
 
 369         PyObject* GetToolClientData(int id) {
 
 370             wxPyUserData* udata = (wxPyUserData*)self->GetToolClientData(id);
 
 372                 Py_INCREF(udata->m_obj);
 
 380         void SetToolClientData(int id, PyObject* clientData) {
 
 381             self->SetToolClientData(id, new wxPyUserData(clientData));
 
 386     bool GetToolState(int id);
 
 387     bool GetToolEnabled(int id);
 
 388     void SetToolShortHelp(int id, const wxString& helpString);
 
 389     wxString GetToolShortHelp(int id);
 
 390     void SetToolLongHelp(int id, const wxString& helpString);
 
 391     wxString GetToolLongHelp(int id);
 
 393     %name(SetMarginsXY) void SetMargins(int x, int y);
 
 394     void SetMargins(const wxSize& size);
 
 395     void SetToolPacking(int packing);
 
 396     void SetToolSeparation(int separation);
 
 397     wxSize GetToolMargins();
 
 399     int GetToolPacking();
 
 400     int GetToolSeparation();
 
 402     void SetRows(int nRows);
 
 403     void SetMaxRowsCols(int rows, int cols);
 
 407     void SetToolBitmapSize(const wxSize& size);
 
 408     wxSize GetToolBitmapSize();
 
 409     wxSize GetToolSize();
 
 411     // returns a (non separator) tool containing the point (x, y) or NULL if
 
 412     // there is no tool at this point (corrdinates are client)
 
 413     wxToolBarToolBase *FindToolForPosition(wxCoord x, wxCoord y);
 
 415     // return TRUE if this is a vertical toolbar, otherwise FALSE
 
 422 class wxToolBar : public wxToolBarBase {
 
 424     wxToolBar(wxWindow *parent,
 
 426               const wxPoint& pos = wxDefaultPosition,
 
 427               const wxSize& size = wxDefaultSize,
 
 428               long style = wxNO_BORDER | wxTB_HORIZONTAL,
 
 429               const wxString& name = wxPyToolBarNameStr);
 
 430     %name(wxPreToolBar)wxToolBar();
 
 432     bool Create(wxWindow *parent,
 
 434               const wxPoint& pos = wxDefaultPosition,
 
 435               const wxSize& size = wxDefaultSize,
 
 436               long style = wxNO_BORDER | wxTB_HORIZONTAL,
 
 437               const wxString& name = wxPyToolBarNameStr);
 
 439     %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
 
 440     %pragma(python) addtomethod = "wxPreToolBar:val._setOORInfo(val)"
 
 442     wxToolBarToolBase *FindToolForPosition(wxCoord x, wxCoord y);
 
 448 class wxToolBarSimple : public wxToolBarBase {
 
 450     wxToolBarSimple(wxWindow *parent,
 
 452                     const wxPoint& pos = wxDefaultPosition,
 
 453                     const wxSize& size = wxDefaultSize,
 
 454                     long style = wxNO_BORDER | wxTB_HORIZONTAL,
 
 455                     const wxString& name = wxPyToolBarNameStr);
 
 456     %name(wxPreToolBarSimple)wxToolBarSimple();
 
 458     bool Create(wxWindow *parent,
 
 460                     const wxPoint& pos = wxDefaultPosition,
 
 461                     const wxSize& size = wxDefaultSize,
 
 462                     long style = wxNO_BORDER | wxTB_HORIZONTAL,
 
 463                     const wxString& name = wxPyToolBarNameStr);
 
 465     %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
 
 466     %pragma(python) addtomethod = "wxPreToolBarSimple:val._setOORInfo(val)"
 
 468     wxToolBarToolBase *FindToolForPosition(wxCoord x, wxCoord y);
 
 471 //---------------------------------------------------------------------------
 
 472 //---------------------------------------------------------------------------