home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / wxos2233.zip / wxOS2-2_3_3.zip / wxWindows-2.3.3 / include / wx / os2 / toolbar.h < prev    next >
C/C++ Source or Header  |  2002-08-27  |  9KB  |  216 lines

  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name:        toolbar.h
  3. // Purpose:     wxToolBar class
  4. // Author:      David Webster
  5. // Modified by:
  6. // Created:     10/17/98
  7. // RCS-ID:      $Id: TOOLBAR.H,v 1.14 2002/08/25 18:20:22 SN Exp $
  8. // Copyright:   (c) David Webster
  9. // Licence:     wxWindows licence
  10. /////////////////////////////////////////////////////////////////////////////
  11.  
  12. #ifndef _WX_TOOLBAR_H_
  13. #define _WX_TOOLBAR_H_
  14.  
  15. #if wxUSE_TOOLBAR
  16. #include "wx/timer.h"
  17. #include "wx/tbarbase.h"
  18.  
  19. #define ID_TOOLTIMER                100
  20. #define ID_TOOLEXPTIMER             101
  21.  
  22. class WXDLLEXPORT wxToolBar: public wxToolBarBase
  23. {
  24. public:
  25.     /*
  26.      * Public interface
  27.      */
  28.  
  29.     wxToolBar()
  30.     : m_vToolTimer(this, ID_TOOLTIMER)
  31.     , m_vToolExpTimer(this, ID_TOOLEXPTIMER)
  32.     { Init(); }
  33.  
  34.     inline wxToolBar( wxWindow*       pParent
  35.                      ,wxWindowID      vId
  36.                      ,const wxPoint&  rPos = wxDefaultPosition
  37.                      ,const wxSize&   rSize = wxDefaultSize
  38.                      ,long            lStyle = wxNO_BORDER | wxTB_HORIZONTAL
  39.                      ,const wxString& rName = wxToolBarNameStr
  40.                     ) : m_vToolTimer(this, ID_TOOLTIMER)
  41.                       , m_vToolExpTimer(this, ID_TOOLEXPTIMER)
  42.     {
  43.         Init();
  44.         Create( pParent
  45.                ,vId
  46.                ,rPos
  47.                ,rSize
  48.                ,lStyle
  49.                ,rName
  50.               );
  51.     }
  52.     virtual ~wxToolBar();
  53.  
  54.     bool Create( wxWindow*       pParent
  55.                 ,wxWindowID      vId
  56.                 ,const wxPoint&  rPos = wxDefaultPosition
  57.                 ,const wxSize&   rSize = wxDefaultSize
  58.                 ,long            lStyle = wxNO_BORDER | wxTB_HORIZONTAL
  59.                 ,const wxString& rName = wxToolBarNameStr
  60.                );
  61.  
  62.  
  63.     //
  64.     // Override/implement base class virtuals
  65.     //
  66.     virtual wxToolBarToolBase* FindToolForPosition( wxCoord vX
  67.                                                    ,wxCoord vY
  68.                                                   ) const;
  69.     virtual bool               Realize(void);
  70.     virtual void               SetRows(int nRows);
  71.  
  72.     //
  73.     // Special overrides for OS/2
  74.     //
  75.     virtual wxToolBarToolBase* InsertControl( size_t     nPos
  76.                                              ,wxControl* pControl
  77.                                             );
  78.     virtual wxToolBarToolBase* InsertSeparator(size_t nPos);
  79.     virtual wxToolBarToolBase* InsertTool( size_t          nPos
  80.                                           ,int             nId
  81.                                           ,const wxString& rsLabel
  82.                                           ,const wxBitmap& rBitmap
  83.                                           ,const wxBitmap& rBmpDisabled = wxNullBitmap
  84.                                           ,wxItemKind      eKind = wxITEM_NORMAL
  85.                                           ,const wxString& rsShortHelp = wxEmptyString
  86.                                           ,const wxString& rsLongHelp = wxEmptyString
  87.                                           ,wxObject*       pClientData = NULL
  88.                                          );
  89.     wxToolBarToolBase*         InsertTool( size_t          nPos
  90.                                           ,int             nId
  91.                                           ,const wxBitmap& rBitmap
  92.                                           ,const wxBitmap& rBmpDisabled = wxNullBitmap
  93.                                           ,bool            bToggle = FALSE
  94.                                           ,wxObject*       pClientData = NULL
  95.                                           ,const wxString& rsShortHelp = wxEmptyString
  96.                                           ,const wxString& rsLongHelp = wxEmptyString
  97.                                          )
  98.     {
  99.         return InsertTool( nPos
  100.                           ,nId
  101.                           ,wxEmptyString
  102.                           ,rBitmap
  103.                           ,rBmpDisabled
  104.                           ,bToggle ? wxITEM_CHECK : wxITEM_NORMAL
  105.                           ,rsShortHelp
  106.                           ,rsLongHelp
  107.                           ,pClientData
  108.                          );
  109.     }
  110.     virtual bool               DeleteTool(int nId);
  111.     virtual bool               DeleteToolByPos(size_t nPos);
  112.  
  113.     //
  114.     // Event handlers
  115.     //
  116.     void OnPaint(wxPaintEvent& event);
  117.     void OnSize(wxSizeEvent& event);
  118.     void OnMouseEvent(wxMouseEvent& event);
  119.     void OnKillFocus(wxFocusEvent& event);
  120.  
  121. protected:
  122.     //
  123.     // Common part of all ctors
  124.     //
  125.     void Init();
  126.  
  127.     //
  128.     // Implement base class pure virtuals
  129.     //
  130.     virtual wxToolBarToolBase* DoAddTool( int id
  131.                                          ,const wxString& label
  132.                                          ,const wxBitmap& bitmap
  133.                                          ,const wxBitmap& bmpDisabled
  134.                                          ,wxItemKind kind
  135.                                          ,const wxString& shortHelp = wxEmptyString
  136.                                          ,const wxString& longHelp = wxEmptyString
  137.                                          ,wxObject *clientData = NULL
  138.                                          ,wxCoord xPos = -1
  139.                                          ,wxCoord yPos = -1
  140.                                         );
  141.  
  142.     virtual bool DoInsertTool( size_t             nPos
  143.                               ,wxToolBarToolBase* pTool
  144.                              );
  145.     virtual bool DoDeleteTool( size_t              nPos
  146.                               , wxToolBarToolBase* pTool
  147.                              );
  148.  
  149.     virtual void DoEnableTool( wxToolBarToolBase* pTool
  150.                               ,bool               bEnable
  151.                              );
  152.     virtual void DoToggleTool( wxToolBarToolBase* pTool
  153.                               ,bool               bToggle
  154.                              );
  155.     virtual void DoSetToggle( wxToolBarToolBase* pTool
  156.                              ,bool               bToggle
  157.                             );
  158.  
  159.     virtual wxToolBarToolBase* CreateTool( int             vId
  160.                                           ,const wxString& rsLabel
  161.                                           ,const wxBitmap& rBmpNormal
  162.                                           ,const wxBitmap& rBmpDisabled
  163.                                           ,wxItemKind      eKind
  164.                                           ,wxObject*       pClientData
  165.                                           ,const wxString& rsShortHelp
  166.                                           ,const wxString& rsLongHelp
  167.                                          );
  168.     virtual wxToolBarToolBase* CreateTool(wxControl* pControl);
  169.  
  170.     //
  171.     // Helpers
  172.     //
  173.     void         DrawTool(wxToolBarToolBase *tool);
  174.     virtual void DrawTool( wxDC&              rDC
  175.                           ,wxToolBarToolBase* pTool
  176.                          );
  177.     virtual void SpringUpButton(int nIndex);
  178.  
  179.     int                             m_nCurrentRowsOrColumns;
  180.     int                             m_nPressedTool;
  181.     int                             m_nCurrentTool;
  182.     wxCoord                         m_vLastX;
  183.     wxCoord                         m_vLastY;
  184.     wxCoord                         m_vMaxWidth;
  185.     wxCoord                         m_vMaxHeight;
  186.     wxCoord                         m_vXPos;
  187.     wxCoord                         m_vYPos;
  188.     wxCoord                         m_vTextX;
  189.     wxCoord                         m_vTextY;
  190.  
  191. private:
  192.     void LowerTool( wxToolBarToolBase* pTool
  193.                    ,bool               bLower = TRUE
  194.                   );
  195.     void RaiseTool( wxToolBarToolBase* pTool
  196.                    ,bool               bRaise = TRUE
  197.                   );
  198.     void OnTimer(wxTimerEvent& rEvent);
  199.  
  200.     static bool                     m_bInitialized;
  201.  
  202.     wxTimer                         m_vToolTimer;
  203.     wxTimer                         m_vToolExpTimer;
  204.     wxToolTip*                      m_pToolTip;
  205.     wxCoord                         m_vXMouse;
  206.     wxCoord                         m_vYMouse;
  207.  
  208.     DECLARE_EVENT_TABLE()
  209.     DECLARE_DYNAMIC_CLASS(wxToolBar)
  210. };
  211.  
  212. #endif // wxUSE_TOOLBAR
  213.  
  214. #endif
  215.     // _WX_TOOLBAR_H_
  216.