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>
 
  21 //----------------------------------------------------------------------
 
  24 %include my_typemaps.i
 
  26 // Import some definitions of other classes, etc.
 
  32 %pragma(python) code = "import wx"
 
  33 %pragma(python) code = "wxITEM_NORMAL = 0 # predeclare this since wx isn't fully imported yet"
 
  35 //----------------------------------------------------------------------
 
  38     // Put some wx default wxChar* values into wxStrings.
 
  39     DECLARE_DEF_STRING(StatusLineNameStr);
 
  40     DECLARE_DEF_STRING(ToolBarNameStr);
 
  41     static const wxString wxPyEmptyString(wxT(""));
 
  44 //---------------------------------------------------------------------------
 
  46 class wxStatusBar : public wxWindow {
 
  48     wxStatusBar(wxWindow* parent, wxWindowID id = -1,
 
  49                 long style = wxST_SIZEGRIP,
 
  50                 const wxString& name = wxPyStatusLineNameStr);
 
  51     %name(wxPreStatusBar)wxStatusBar();
 
  53     bool Create(wxWindow* parent, wxWindowID id,
 
  54                 long style = wxST_SIZEGRIP,
 
  55                 const wxString& name = wxPyStatusLineNameStr);
 
  57     %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
 
  58     %pragma(python) addtomethod = "wxPreStatusBar:val._setOORInfo(val)"
 
  61         %new wxRect* GetFieldRect(long item) {
 
  62             wxRect* rect= new wxRect;
 
  63             self->GetFieldRect(item, *rect);
 
  67     int GetFieldsCount(void);
 
  68     wxString GetStatusText(int ir = 0);
 
  72     void SetFieldsCount(int number = 1);
 
  73     void SetStatusText(const wxString& text, int i = 0);
 
  74     void SetStatusWidths(int LCOUNT, int* choices);
 
  75     void PushStatusText(const wxString& text, int number = 0);
 
  76     void PopStatusText(int number = 0);
 
  78     void SetMinHeight(int height);
 
  82 //---------------------------------------------------------------------------
 
  86 enum wxToolBarToolStyle
 
  88     wxTOOL_STYLE_BUTTON    = 1,
 
  89     wxTOOL_STYLE_SEPARATOR = 2,
 
 109 class wxToolBarToolBase : public wxObject {
 
 111 //      wxToolBarToolBase(wxToolBarBase *tbar = (wxToolBarBase *)NULL,
 
 112 //                        int id = wxID_SEPARATOR,
 
 113 //                        const wxString& label = wxEmptyString,
 
 114 //                        const wxBitmap& bmpNormal = wxNullBitmap,
 
 115 //                        const wxBitmap& bmpDisabled = wxNullBitmap,
 
 116 //                        wxItemKind kind = wxITEM_NORMAL,
 
 117 //                        wxObject *clientData = (wxObject *) NULL,
 
 118 //                        const wxString& shortHelpString = wxEmptyString,
 
 119 //                        const wxString& longHelpString = wxEmptyString)
 
 120 //      ~wxToolBarToolBase();
 
 122     %addmethods { void Destroy() { delete self; } }
 
 125     wxControl *GetControl();
 
 126     wxToolBarBase *GetToolBar();
 
 131     wxItemKind GetKind();
 
 135     const wxBitmap& GetNormalBitmap();
 
 136     const wxBitmap& GetDisabledBitmap();
 
 137     wxBitmap GetBitmap();
 
 139     wxString GetShortHelp();
 
 140     wxString GetLongHelp();
 
 141     bool Enable(bool enable);
 
 143     bool SetToggle(bool toggle);
 
 144     bool SetShortHelp(const wxString& help);
 
 145     bool SetLongHelp(const wxString& help);
 
 146     void SetNormalBitmap(const wxBitmap& bmp);
 
 147     void SetDisabledBitmap(const wxBitmap& bmp);
 
 148     void SetLabel(const wxString& label);
 
 150     void Attach(wxToolBarBase *tbar);
 
 152     //wxObject *GetClientData();
 
 154         // convert the ClientData back to a PyObject
 
 155         PyObject* GetClientData() {
 
 156             wxPyUserData* udata = (wxPyUserData*)self->GetClientData();
 
 158                 Py_INCREF(udata->m_obj);
 
 166         void SetClientData(PyObject* clientData) {
 
 167             self->SetClientData(new wxPyUserData(clientData));
 
 171     %pragma(python) addtoclass="
 
 172     GetBitmap1 = GetNormalBitmap
 
 173     GetBitmap2 = GetDisabledBitmap
 
 174     SetBitmap1 = SetNormalBitmap
 
 175     SetBitmap2 = SetDisabledBitmap
 
 181 class wxToolBarBase : public wxControl {
 
 184     // This is an Abstract Base Class
 
 188         // The full AddTool() function.  Call it DoAddTool in wxPython and
 
 189         // implement the other Add methods by calling it.
 
 191         // If bmpDisabled is wxNullBitmap, a shadowed version of the normal bitmap
 
 192         // is created and used as the disabled image.
 
 193         wxToolBarToolBase *DoAddTool(int id,
 
 194                                      const wxString& label,
 
 195                                      const wxBitmap& bitmap,
 
 196                                      const wxBitmap& bmpDisabled = wxNullBitmap,
 
 197                                      wxItemKind kind = wxITEM_NORMAL,
 
 198                                      const wxString& shortHelp = wxPyEmptyString,
 
 199                                      const wxString& longHelp = wxPyEmptyString,
 
 200                                      PyObject *clientData = NULL)
 
 202             wxPyUserData* udata = NULL;
 
 203             if (clientData && clientData != Py_None)
 
 204                 udata = new wxPyUserData(clientData);
 
 205             return self->AddTool(id, label, bitmap, bmpDisabled, kind,
 
 206                                  shortHelp, longHelp, udata);
 
 210         // Insert the new tool at the given position, if pos == GetToolsCount(), it
 
 211         // is equivalent to DoAddTool()
 
 212         wxToolBarToolBase *DoInsertTool(size_t pos,
 
 214                                       const wxString& label,
 
 215                                       const wxBitmap& bitmap,
 
 216                                       const wxBitmap& bmpDisabled = wxNullBitmap,
 
 217                                       wxItemKind kind = wxITEM_NORMAL,
 
 218                                       const wxString& shortHelp = wxPyEmptyString,
 
 219                                       const wxString& longHelp = wxPyEmptyString,
 
 220                                       PyObject *clientData = NULL)
 
 222             wxPyUserData* udata = NULL;
 
 223             if (clientData && clientData != Py_None)
 
 224                 udata = new wxPyUserData(clientData);
 
 225             return self->InsertTool(pos, id, label, bitmap, bmpDisabled, kind,
 
 226                                     shortHelp, longHelp, udata);
 
 232     %pragma(python) addtoclass = "
 
 233     # These match the original Add methods for this class, kept for
 
 234     # backwards compatibility with versions < 2.3.3.
 
 237     def AddTool(self, id, bitmap,
 
 238                 pushedBitmap = wxNullBitmap,
 
 241                 shortHelpString = '',
 
 242                 longHelpString = '') :
 
 243         '''Old style method to add a tool to the toolbar.'''
 
 244         kind = wx.wxITEM_NORMAL
 
 245         if isToggle: kind = wx.wxITEM_CHECK
 
 246         return self.DoAddTool(id, '', bitmap, pushedBitmap, kind,
 
 247                               shortHelpString, longHelpString, clientData)
 
 249     def AddSimpleTool(self, id, bitmap,
 
 250                       shortHelpString = '',
 
 253         '''Old style method to add a tool to the toolbar.'''
 
 254         kind = wx.wxITEM_NORMAL
 
 255         if isToggle: kind = wx.wxITEM_CHECK
 
 256         return self.DoAddTool(id, '', bitmap, wxNullBitmap, kind,
 
 257                               shortHelpString, longHelpString, None)
 
 259     def InsertTool(self, pos, id, bitmap,
 
 260                    pushedBitmap = wxNullBitmap,
 
 263                    shortHelpString = '',
 
 264                    longHelpString = ''):
 
 265         '''Old style method to insert a tool in the toolbar.'''
 
 266         kind = wx.wxITEM_NORMAL
 
 267         if isToggle: kind = wx.wxITEM_CHECK
 
 268         return self.DoInsertTool(pos, id, '', bitmap, pushedBitmap, kind,
 
 269                                  shortHelpString, longHelpString, clientData)
 
 271     def InsertSimpleTool(self, pos, id, bitmap,
 
 272                          shortHelpString = '',
 
 275         '''Old style method to insert a tool in the toolbar.'''
 
 276         kind = wx.wxITEM_NORMAL
 
 277         if isToggle: kind = wx.wxITEM_CHECK
 
 278         return self.DoInsertTool(pos, id, '', bitmap, wxNullBitmap, kind,
 
 279                                  shortHelpString, longHelpString, None)
 
 282     # The following are the new toolbar Add methods starting with
 
 283     # 2.3.3.  They are renamed to have 'Label' in the name so as to be
 
 284     # able to keep backwards compatibility with using the above
 
 285     # methods.  Eventually these should migrate to be the methods used
 
 286     # primarily and lose the 'Label' in the name...
 
 288     def AddLabelTool(self, id, label, bitmap,
 
 289                      bmpDisabled = wxNullBitmap,
 
 290                      kind = wxITEM_NORMAL,
 
 291                      shortHelp = '', longHelp = '',
 
 294         The full AddTool() function.
 
 296         If bmpDisabled is wxNullBitmap, a shadowed version of the normal bitmap
 
 297         is created and used as the disabled image.
 
 299         return self.DoAddTool(id, label, bitmap, bmpDisabled, kind,
 
 300                               shortHelp, longHelp, clientData)
 
 303     def InsertLabelTool(self, pos, id, label, bitmap,
 
 304                         bmpDisabled = wxNullBitmap,
 
 305                         kind = wxITEM_NORMAL,
 
 306                         shortHelp = '', longHelp = '',
 
 309         Insert the new tool at the given position, if pos == GetToolsCount(), it
 
 310         is equivalent to AddTool()
 
 312         return self.DoInsertTool(pos, id, label, bitmap, bmpDisabled, kind,
 
 313                                  shortHelp, longHelp, clientData)
 
 315     def AddCheckLabelTool(self, id, label, bitmap,
 
 316                         bmpDisabled = wxNullBitmap,
 
 317                         shortHelp = '', longHelp = '',
 
 319         '''Add a check tool, i.e. a tool which can be toggled'''
 
 320         return self.DoAddTool(id, label, bitmap, bmpDisabled, wx.wxITEM_CHECK,
 
 321                               shortHelp, longHelp, clientData)
 
 323     def AddRadioLabelTool(self, id, label, bitmap,
 
 324                           bmpDisabled = wxNullBitmap,
 
 325                           shortHelp = '', longHelp = '',
 
 328         Add a radio tool, i.e. a tool which can be toggled and releases any
 
 329         other toggled radio tools in the same group when it happens
 
 331         return self.DoAddTool(id, label, bitmap, bmpDisabled, wx.wxITEM_RADIO,
 
 332                               shortHelp, longHelp, clientData)
 
 335     # For consistency with the backwards compatible methods above, here are
 
 336     # some non-'Label' versions of the Check and Radio methods
 
 337     def AddCheckTool(self, id, bitmap,
 
 338                      bmpDisabled = wxNullBitmap,
 
 339                      shortHelp = '', longHelp = '',
 
 341         '''Add a check tool, i.e. a tool which can be toggled'''
 
 342         return self.DoAddTool(id, '', bitmap, bmpDisabled, wx.wxITEM_CHECK,
 
 343                               shortHelp, longHelp, clientData)
 
 345     def AddRadioTool(self, id, bitmap,
 
 346                      bmpDisabled = wxNullBitmap,
 
 347                      shortHelp = '', longHelp = '',
 
 350         Add a radio tool, i.e. a tool which can be toggled and releases any
 
 351         other toggled radio tools in the same group when it happens
 
 353         return self.DoAddTool(id, '', bitmap, bmpDisabled, wx.wxITEM_RADIO,
 
 354                               shortHelp, longHelp, clientData)
 
 358     //wxToolBarToolBase *AddTool (wxToolBarToolBase *tool);
 
 359     //wxToolBarToolBase *InsertTool (size_t pos, wxToolBarToolBase *tool);
 
 361     wxToolBarToolBase *AddControl(wxControl *control);
 
 362     wxToolBarToolBase *InsertControl(size_t pos, wxControl *control);
 
 363     wxControl *FindControl( int id );
 
 365     wxToolBarToolBase *AddSeparator();
 
 366     wxToolBarToolBase *InsertSeparator(size_t pos);
 
 368     wxToolBarToolBase *RemoveTool(int id);
 
 370     bool DeleteToolByPos(size_t pos);
 
 371     bool DeleteTool(int id);
 
 375     void EnableTool(int id, bool enable);
 
 376     void ToggleTool(int id, bool toggle);
 
 377     void SetToggle(int id, bool toggle);
 
 381         // convert the ClientData back to a PyObject
 
 382         PyObject* GetToolClientData(int id) {
 
 383             wxPyUserData* udata = (wxPyUserData*)self->GetToolClientData(id);
 
 385                 Py_INCREF(udata->m_obj);
 
 393         void SetToolClientData(int id, PyObject* clientData) {
 
 394             self->SetToolClientData(id, new wxPyUserData(clientData));
 
 398     // returns tool pos, or wxNOT_FOUND if tool isn't found
 
 399     int GetToolPos(int id) const;
 
 401     bool GetToolState(int id);
 
 402     bool GetToolEnabled(int id);
 
 403     void SetToolShortHelp(int id, const wxString& helpString);
 
 404     wxString GetToolShortHelp(int id);
 
 405     void SetToolLongHelp(int id, const wxString& helpString);
 
 406     wxString GetToolLongHelp(int id);
 
 408     %name(SetMarginsXY) void SetMargins(int x, int y);
 
 409     void SetMargins(const wxSize& size);
 
 410     void SetToolPacking(int packing);
 
 411     void SetToolSeparation(int separation);
 
 412     wxSize GetToolMargins();
 
 414     int GetToolPacking();
 
 415     int GetToolSeparation();
 
 417     void SetRows(int nRows);
 
 418     void SetMaxRowsCols(int rows, int cols);
 
 422     void SetToolBitmapSize(const wxSize& size);
 
 423     wxSize GetToolBitmapSize();
 
 424     wxSize GetToolSize();
 
 426     // returns a (non separator) tool containing the point (x, y) or NULL if
 
 427     // there is no tool at this point (corrdinates are client)
 
 428     wxToolBarToolBase *FindToolForPosition(wxCoord x, wxCoord y);
 
 430     // return TRUE if this is a vertical toolbar, otherwise FALSE
 
 437 class wxToolBar : public wxToolBarBase {
 
 439     wxToolBar(wxWindow *parent,
 
 441               const wxPoint& pos = wxDefaultPosition,
 
 442               const wxSize& size = wxDefaultSize,
 
 443               long style = wxNO_BORDER | wxTB_HORIZONTAL,
 
 444               const wxString& name = wxPyToolBarNameStr);
 
 445     %name(wxPreToolBar)wxToolBar();
 
 447     bool Create(wxWindow *parent,
 
 449               const wxPoint& pos = wxDefaultPosition,
 
 450               const wxSize& size = wxDefaultSize,
 
 451               long style = wxNO_BORDER | wxTB_HORIZONTAL,
 
 452               const wxString& name = wxPyToolBarNameStr);
 
 454     %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
 
 455     %pragma(python) addtomethod = "wxPreToolBar:val._setOORInfo(val)"
 
 457     wxToolBarToolBase *FindToolForPosition(wxCoord x, wxCoord y);
 
 463 // class wxToolBarSimple : public wxToolBarBase {
 
 465 //     wxToolBarSimple(wxWindow *parent,
 
 467 //                     const wxPoint& pos = wxDefaultPosition,
 
 468 //                     const wxSize& size = wxDefaultSize,
 
 469 //                     long style = wxNO_BORDER | wxTB_HORIZONTAL,
 
 470 //                     const wxString& name = wxPyToolBarNameStr);
 
 471 //     %name(wxPreToolBarSimple)wxToolBarSimple();
 
 473 //     bool Create(wxWindow *parent,
 
 475 //                     const wxPoint& pos = wxDefaultPosition,
 
 476 //                     const wxSize& size = wxDefaultSize,
 
 477 //                     long style = wxNO_BORDER | wxTB_HORIZONTAL,
 
 478 //                     const wxString& name = wxPyToolBarNameStr);
 
 480 //     %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
 
 481 //     %pragma(python) addtomethod = "wxPreToolBarSimple:val._setOORInfo(val)"
 
 483 //     wxToolBarToolBase *FindToolForPosition(wxCoord x, wxCoord y);
 
 486 //---------------------------------------------------------------------------
 
 487 //---------------------------------------------------------------------------