1 /////////////////////////////////////////////////////////////////////////////
 
   3 // Purpose:     SWIG interface defs for wxStatusBar
 
   7 // Created:     24-Aug-1998
 
   9 // Copyright:   (c) 2003 by Total Control Software
 
  10 // Licence:     wxWindows license
 
  11 /////////////////////////////////////////////////////////////////////////////
 
  16 //---------------------------------------------------------------------------
 
  18 MAKE_CONST_WXSTRING_NOSWIG(ToolBarNameStr);
 
  21 //---------------------------------------------------------------------------
 
  27 enum wxToolBarToolStyle
 
  29     wxTOOL_STYLE_BUTTON    = 1,
 
  30     wxTOOL_STYLE_SEPARATOR = 2,
 
  50 // wxToolBarTool is a toolbar element.
 
  52 // It has a unique id (except for the separators which always have id -1), the
 
  53 // style (telling whether it is a normal button, separator or a control), the
 
  54 // state (toggled or not, enabled or not) and short and long help strings. The
 
  55 // default implementations use the short help string for the tooltip text which
 
  56 // is popped up when the mouse pointer enters the tool and the long help string
 
  57 // for the applications status bar.
 
  58 class wxToolBarToolBase : public wxObject {
 
  60 //      wxToolBarToolBase(wxToolBarBase *tbar = (wxToolBarBase *)NULL,
 
  61 //                        int id = wxID_SEPARATOR,
 
  62 //                        const wxString& label = wxPyEmptyString,
 
  63 //                        const wxBitmap& bmpNormal = wxNullBitmap,
 
  64 //                        const wxBitmap& bmpDisabled = wxNullBitmap,
 
  65 //                        wxItemKind kind = wxITEM_NORMAL,
 
  66 //                        wxObject *clientData = (wxObject *) NULL,
 
  67 //                        const wxString& shortHelpString = wxPyEmptyString,
 
  68 //                        const wxString& longHelpString = wxPyEmptyString)
 
  69 //      ~wxToolBarToolBase();
 
  72     wxControl *GetControl();
 
  73     wxToolBarBase *GetToolBar();
 
  82     const wxBitmap& GetNormalBitmap();
 
  83     const wxBitmap& GetDisabledBitmap();
 
  86     wxString GetShortHelp();
 
  87     wxString GetLongHelp();
 
  88     bool Enable(bool enable);
 
  90     bool SetToggle(bool toggle);
 
  91     bool SetShortHelp(const wxString& help);
 
  92     bool SetLongHelp(const wxString& help);
 
  93     void SetNormalBitmap(const wxBitmap& bmp);
 
  94     void SetDisabledBitmap(const wxBitmap& bmp);
 
  95     void SetLabel(const wxString& label);
 
  97     void Attach(wxToolBarBase *tbar);
 
  99     //wxObject *GetClientData();
 
 101         // convert the ClientData back to a PyObject
 
 102         PyObject* GetClientData() {
 
 103             wxPyUserData* udata = (wxPyUserData*)self->GetClientData();
 
 105                 Py_INCREF(udata->m_obj);
 
 113         void SetClientData(PyObject* clientData) {
 
 114             self->SetClientData(new wxPyUserData(clientData));
 
 119     GetBitmap1 = GetNormalBitmap
 
 120     GetBitmap2 = GetDisabledBitmap
 
 121     SetBitmap1 = SetNormalBitmap
 
 122     SetBitmap2 = SetDisabledBitmap
 
 129 class wxToolBarBase : public wxControl {
 
 132     // This is an Abstract Base Class
 
 136         // The full AddTool() function.  Call it DoAddTool in wxPython and
 
 137         // implement the other Add methods by calling it.
 
 139         // If bmpDisabled is wxNullBitmap, a shadowed version of the normal bitmap
 
 140         // is created and used as the disabled image.
 
 141         wxToolBarToolBase *DoAddTool(int id,
 
 142                                      const wxString& label,
 
 143                                      const wxBitmap& bitmap,
 
 144                                      const wxBitmap& bmpDisabled = wxNullBitmap,
 
 145                                      wxItemKind kind = wxITEM_NORMAL,
 
 146                                      const wxString& shortHelp = wxPyEmptyString,
 
 147                                      const wxString& longHelp = wxPyEmptyString,
 
 148                                      PyObject *clientData = NULL)
 
 150             wxPyUserData* udata = NULL;
 
 151             if (clientData && clientData != Py_None)
 
 152                 udata = new wxPyUserData(clientData);
 
 153             return self->AddTool(id, label, bitmap, bmpDisabled, kind,
 
 154                                  shortHelp, longHelp, udata);
 
 158         // Insert the new tool at the given position, if pos == GetToolsCount(), it
 
 159         // is equivalent to DoAddTool()
 
 160         wxToolBarToolBase *DoInsertTool(size_t pos,
 
 162                                       const wxString& label,
 
 163                                       const wxBitmap& bitmap,
 
 164                                       const wxBitmap& bmpDisabled = wxNullBitmap,
 
 165                                       wxItemKind kind = wxITEM_NORMAL,
 
 166                                       const wxString& shortHelp = wxPyEmptyString,
 
 167                                       const wxString& longHelp = wxPyEmptyString,
 
 168                                       PyObject *clientData = NULL)
 
 170             wxPyUserData* udata = NULL;
 
 171             if (clientData && clientData != Py_None)
 
 172                 udata = new wxPyUserData(clientData);
 
 173             return self->InsertTool(pos, id, label, bitmap, bmpDisabled, kind,
 
 174                                     shortHelp, longHelp, udata);
 
 181     %# These match the original Add methods for this class, kept for
 
 182     %# backwards compatibility with versions < 2.3.3.
 
 185     def AddTool(self, id, bitmap,
 
 186                 pushedBitmap = wx.NullBitmap,
 
 189                 shortHelpString = '',
 
 190                 longHelpString = '') :
 
 191         '''Old style method to add a tool to the toolbar.'''
 
 192         kind = wx.ITEM_NORMAL
 
 193         if isToggle: kind = wx.ITEM_CHECK
 
 194         return self.DoAddTool(id, '', bitmap, pushedBitmap, kind,
 
 195                               shortHelpString, longHelpString, clientData)
 
 197     def AddSimpleTool(self, id, bitmap,
 
 198                       shortHelpString = '',
 
 201         '''Old style method to add a tool to the toolbar.'''
 
 202         kind = wx.ITEM_NORMAL
 
 203         if isToggle: kind = wx.ITEM_CHECK
 
 204         return self.DoAddTool(id, '', bitmap, wx.NullBitmap, kind,
 
 205                               shortHelpString, longHelpString, None)
 
 207     def InsertTool(self, pos, id, bitmap,
 
 208                    pushedBitmap = wx.NullBitmap,
 
 211                    shortHelpString = '',
 
 212                    longHelpString = ''):
 
 213         '''Old style method to insert a tool in the toolbar.'''
 
 214         kind = wx.ITEM_NORMAL
 
 215         if isToggle: kind = wx.ITEM_CHECK
 
 216         return self.DoInsertTool(pos, id, '', bitmap, pushedBitmap, kind,
 
 217                                  shortHelpString, longHelpString, clientData)
 
 219     def InsertSimpleTool(self, pos, id, bitmap,
 
 220                          shortHelpString = '',
 
 223         '''Old style method to insert a tool in the toolbar.'''
 
 224         kind = wx.ITEM_NORMAL
 
 225         if isToggle: kind = wx.ITEM_CHECK
 
 226         return self.DoInsertTool(pos, id, '', bitmap, wx.NullBitmap, kind,
 
 227                                  shortHelpString, longHelpString, None)
 
 230     %# The following are the new toolbar Add methods starting with
 
 231     %# 2.3.3.  They are renamed to have 'Label' in the name so as to be
 
 232     %# able to keep backwards compatibility with using the above
 
 233     %# methods.  Eventually these should migrate to be the methods used
 
 234     %# primarily and lose the 'Label' in the name...
 
 236     def AddLabelTool(self, id, label, bitmap,
 
 237                      bmpDisabled = wx.NullBitmap,
 
 238                      kind = wx.ITEM_NORMAL,
 
 239                      shortHelp = '', longHelp = '',
 
 242         The full AddTool() function.
 
 244         If bmpDisabled is wx.NullBitmap, a shadowed version of the normal bitmap
 
 245         is created and used as the disabled image.
 
 247         return self.DoAddTool(id, label, bitmap, bmpDisabled, kind,
 
 248                               shortHelp, longHelp, clientData)
 
 251     def InsertLabelTool(self, pos, id, label, bitmap,
 
 252                         bmpDisabled = wx.NullBitmap,
 
 253                         kind = wx.ITEM_NORMAL,
 
 254                         shortHelp = '', longHelp = '',
 
 257         Insert the new tool at the given position, if pos == GetToolsCount(), it
 
 258         is equivalent to AddTool()
 
 260         return self.DoInsertTool(pos, id, label, bitmap, bmpDisabled, kind,
 
 261                                  shortHelp, longHelp, clientData)
 
 263     def AddCheckLabelTool(self, id, label, bitmap,
 
 264                         bmpDisabled = wx.NullBitmap,
 
 265                         shortHelp = '', longHelp = '',
 
 267         '''Add a check tool, i.e. a tool which can be toggled'''
 
 268         return self.DoAddTool(id, label, bitmap, bmpDisabled, wx.ITEM_CHECK,
 
 269                               shortHelp, longHelp, clientData)
 
 271     def AddRadioLabelTool(self, id, label, bitmap,
 
 272                           bmpDisabled = wx.NullBitmap,
 
 273                           shortHelp = '', longHelp = '',
 
 276         Add a radio tool, i.e. a tool which can be toggled and releases any
 
 277         other toggled radio tools in the same group when it happens
 
 279         return self.DoAddTool(id, label, bitmap, bmpDisabled, wx.ITEM_RADIO,
 
 280                               shortHelp, longHelp, clientData)
 
 283     %# For consistency with the backwards compatible methods above, here are
 
 284     %# some non-'Label' versions of the Check and Radio methods
 
 286     def AddCheckTool(self, id, bitmap,
 
 287                      bmpDisabled = wx.NullBitmap,
 
 288                      shortHelp = '', longHelp = '',
 
 290         '''Add a check tool, i.e. a tool which can be toggled'''
 
 291         return self.DoAddTool(id, '', bitmap, bmpDisabled, wx.ITEM_CHECK,
 
 292                               shortHelp, longHelp, clientData)
 
 294     def AddRadioTool(self, id, bitmap,
 
 295                      bmpDisabled = wx.NullBitmap,
 
 296                      shortHelp = '', longHelp = '',
 
 299         Add a radio tool, i.e. a tool which can be toggled and releases any
 
 300         other toggled radio tools in the same group when it happens
 
 302         return self.DoAddTool(id, '', bitmap, bmpDisabled, wx.ITEM_RADIO,
 
 303                               shortHelp, longHelp, clientData)
 
 306     %name(AddToolItem) wxToolBarToolBase *AddTool (wxToolBarToolBase *tool);
 
 307     %name(InsertToolItem) wxToolBarToolBase *InsertTool (size_t pos, wxToolBarToolBase *tool);
 
 309     wxToolBarToolBase *AddControl(wxControl *control);
 
 310     wxToolBarToolBase *InsertControl(size_t pos, wxControl *control);
 
 311     wxControl *FindControl( int id );
 
 313     wxToolBarToolBase *AddSeparator();
 
 314     wxToolBarToolBase *InsertSeparator(size_t pos);
 
 316     wxToolBarToolBase *RemoveTool(int id);
 
 318     bool DeleteToolByPos(size_t pos);
 
 319     bool DeleteTool(int id);
 
 323     void EnableTool(int id, bool enable);
 
 324     void ToggleTool(int id, bool toggle);
 
 325     void SetToggle(int id, bool toggle);
 
 329         // convert the ClientData back to a PyObject
 
 330         PyObject* GetToolClientData(int id) {
 
 331             wxPyUserData* udata = (wxPyUserData*)self->GetToolClientData(id);
 
 333                 Py_INCREF(udata->m_obj);
 
 341         void SetToolClientData(int id, PyObject* clientData) {
 
 342             self->SetToolClientData(id, new wxPyUserData(clientData));
 
 346     // returns tool pos, or wxNOT_FOUND if tool isn't found
 
 347     int GetToolPos(int id) const;
 
 349     bool GetToolState(int id);
 
 350     bool GetToolEnabled(int id);
 
 351     void SetToolShortHelp(int id, const wxString& helpString);
 
 352     wxString GetToolShortHelp(int id);
 
 353     void SetToolLongHelp(int id, const wxString& helpString);
 
 354     wxString GetToolLongHelp(int id);
 
 356     %name(SetMarginsXY) void SetMargins(int x, int y);
 
 357     void SetMargins(const wxSize& size);
 
 358     void SetToolPacking(int packing);
 
 359     void SetToolSeparation(int separation);
 
 360     wxSize GetToolMargins();
 
 362     int GetToolPacking();
 
 363     int GetToolSeparation();
 
 365     void SetRows(int nRows);
 
 366     void SetMaxRowsCols(int rows, int cols);
 
 370     void SetToolBitmapSize(const wxSize& size);
 
 371     wxSize GetToolBitmapSize();
 
 372     wxSize GetToolSize();
 
 374     // returns a (non separator) tool containing the point (x, y) or NULL if
 
 375     // there is no tool at this point (corrdinates are client)
 
 376     wxToolBarToolBase *FindToolForPosition(wxCoord x, wxCoord y);
 
 378     // find the tool by id
 
 379     wxToolBarToolBase *FindById(int toolid) const;
 
 381     // return True if this is a vertical toolbar, otherwise False
 
 388 MustHaveApp(wxToolBar);
 
 390 class wxToolBar : public wxToolBarBase {
 
 392     %pythonAppend wxToolBar         "self._setOORInfo(self)"
 
 393     %pythonAppend wxToolBar()       ""
 
 394     %typemap(out) wxToolBar*;    // turn off this typemap
 
 396     wxToolBar(wxWindow *parent,
 
 398               const wxPoint& pos = wxDefaultPosition,
 
 399               const wxSize& size = wxDefaultSize,
 
 400               long style = wxNO_BORDER | wxTB_HORIZONTAL,
 
 401               const wxString& name = wxPyToolBarNameStr);
 
 402     %name(PreToolBar)wxToolBar();
 
 404     // Turn it back on again
 
 405     %typemap(out) wxToolBar* { $result = wxPyMake_wxObject($1, $owner); }
 
 407     bool Create(wxWindow *parent,
 
 409               const wxPoint& pos = wxDefaultPosition,
 
 410               const wxSize& size = wxDefaultSize,
 
 411               long style = wxNO_BORDER | wxTB_HORIZONTAL,
 
 412               const wxString& name = wxPyToolBarNameStr);
 
 414     wxToolBarToolBase *FindToolForPosition(wxCoord x, wxCoord y);
 
 416     static wxVisualAttributes
 
 417     GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
 
 420 //---------------------------------------------------------------------------