Main Page | Namespace List | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

slidebar.h

Go to the documentation of this file.
00001 
00002 // Name:        wx/slidebar.h
00003 // Purpose:     wxSlideBar class
00004 // Author:      Mark McCormack
00005 // Modified by:
00006 // Created:     25/05/05
00007 // RCS-ID:      $Id: slidebar.h,v 1.12 2005/05/12 14:02:29 frm Exp $
00008 // Copyright:   (c) 2004 Mark McCormack
00009 // Licence:     wxWindows licence
00011 
00012 #ifndef _WX_SLIDEBAR_H_
00013 #define _WX_SLIDEBAR_H_
00014 
00015 #include <wx/defs.h>
00016 #include <wx/barholder.h>
00017 #include <wx/wfstream.h>
00018 #include "wx/export.h"
00019 
00020 enum wxSlideBarMode {
00021     wxSLIDE_MODE_SIMPLE,
00022     wxSLIDE_MODE_COMPACT
00023 };
00024 
00025 struct wxBarPlacement {
00026     wxBarHolder * pBarHolder;
00027     wxRect placement;
00028 };
00029 
00030 class wxMenu;
00031 
00032 // ----------------------------------------------------------------------------
00033 // wxSlideBar control
00034 // ----------------------------------------------------------------------------
00035 
00036 WX_DECLARE_USER_EXPORTED_LIST( wxBarHolder, BarHolderList, WXDLLIMPEXP_DI );
00037 WX_DECLARE_USER_EXPORTED_OBJARRAY( wxBarPlacement, BarPlacementArray, WXDLLIMPEXP_DI );
00038 
00039 class WXDLLIMPEXP_DI wxSlideBar : public wxWindow
00040 {
00041 public:
00042     // Default constructor
00043     wxSlideBar() 
00044         : barList_( wxKEY_STRING ) {
00045         Init();
00046     }
00047     
00048     // Normal constructor
00049     wxSlideBar( wxWindow *parent, wxWindowID id = -1, 
00050         const wxPoint& pos = wxDefaultPosition,
00051         const wxSize& size = wxDefaultSize, long style = wxTAB_TRAVERSAL, 
00052         const wxString& name = wxT("slidebar") )
00053         : barList_( wxKEY_STRING ) 
00054     {
00055         Init();
00056 
00057         Create(parent, id, pos, size, style, name);
00058     }
00059 
00060     void Init();
00061 
00062     bool Create( wxWindow *parent, wxWindowID id = -1, 
00063         const wxPoint& pos = wxDefaultPosition,
00064         const wxSize& size = wxDefaultSize, 
00065         long style = wxTAB_TRAVERSAL, 
00066         const wxString& name = wxT("slidebar") );
00067 
00068     virtual ~wxSlideBar();
00069 
00070     // standard interface
00071     wxBarHolder * AddWindow( wxWindow * pWindow, 
00072         const wxString & label = wxT(""), unsigned int flags = wxBF_DEFAULT );
00073     void UpdateLayout();
00074 
00075     // extended interface
00076     void SetMode( wxSlideBarMode mode );
00077     wxSlideBarMode GetMode();
00078     void SetBarLock( bool enable );
00079     bool GetBarLock();
00080 
00081     // event handlers
00082     void OnQueryLayoutInfo( wxQueryLayoutInfoEvent& event );
00083     void OnCalculateLayout( wxCalculateLayoutEvent& event );
00084     void OnSize( wxSizeEvent &event );
00085     void OnContextMenu( wxContextMenuEvent &event );
00086     void OnLockBars( wxCommandEvent &event );
00087     void OnContextItem( wxCommandEvent &event );
00088 
00089     // overrides
00090     virtual void DoGetSize( int * x, int * y ) const;
00091     virtual wxSize DoGetBestSize() const;
00092 
00093     // load/save
00094     bool SaveToStream( wxOutputStream &stream );
00095     bool LoadFromStream( wxInputStream &stream );
00096 #ifdef wxDI_USE_XMLLOADSAVE
00097     bool SaveToXML( const wxString& filename );
00098     bool LoadFromXML( const wxString& filename );
00099 #endif
00100 
00101     // access
00102     wxBarHolder * GetBarHolderAt( wxPoint pt );
00103     wxBarHolder * GetBarHolderAt( BarPlacementArray &barPlacementArray, 
00104         wxPoint pt );
00105     void SwapBarHolders( wxBarHolder * p1, wxBarHolder * p2 );
00106     BarPlacementArray & CalcBarPlacement( int width, 
00107         int * pAreaHeight = NULL );
00108 
00109 private:
00110     void applyBarPlacement( BarPlacementArray & bpl );
00111     void createContextMenu();
00112     void deleteContextMenu();
00113     void refreshBars();
00114 
00115     DECLARE_DYNAMIC_CLASS( wxSlideBar )
00116     DECLARE_EVENT_TABLE()
00117 
00118 private:
00119     BarPlacementArray barPlacementArray_;
00120     int areaHeight_;
00121     int areaWidth_;
00122     wxSlideBarMode mode_;
00123     BarHolderList barList_;
00124     bool barLock_;
00125     wxMenu * pContextMenu_;
00126     
00127     int contextIdStart_;
00128     int contextIdEnd_;
00129 };
00130 
00131 // ----------------------------------------------------------------------------
00132 // wxSlideBar events
00133 // ----------------------------------------------------------------------------
00134 
00135 BEGIN_DECLARE_EVENT_TYPES()
00136     DECLARE_EXPORTED_EVENT_TYPE( WXDLLIMPEXP_DI, wxEVT_SLIDEBAR_SIZE_CHANGED, wxEVT_FIRST + 1251 )  // TODO: must change id
00137     DECLARE_EXPORTED_EVENT_TYPE( WXDLLIMPEXP_DI, wxEVT_SLIDEBAR_UPDATE_LAYOUT, wxEVT_FIRST + 1252 )  // TODO: must change id
00138 END_DECLARE_EVENT_TYPES()
00139 
00140 // This should keep wxDockit compatible with wxWidgets 2.4.x
00141 #ifndef WXWIN_COMPATIBILITY_2_4
00142 #define EVT_SLIDEBAR_SIZE_CHANGED(fn) \
00143     DECLARE_EVENT_TABLE_ENTRY( wxEVT_SLIDEBAR_SIZE_CHANGED, -1, -1, \
00144         (wxObjectEventFunction) (wxEventFunction) & fn, NULL ),
00145 #define EVT_SLIDEBAR_UPDATE_LAYOUT(fn) \
00146     DECLARE_EVENT_TABLE_ENTRY( wxEVT_SLIDEBAR_UPDATE_LAYOUT, -1, -1, \
00147         (wxObjectEventFunction) (wxEventFunction) & fn, NULL ),
00148 #else
00149 // Patch for wxWidgets-2.5.4 compat submitted by Jesus Gonzalez (2005-03-02)
00150 typedef void (wxEvtHandler::*wxCommandEventFunction)(wxCommandEvent&);
00151 #define EVT_SLIDEBAR_SIZE_CHANGED(fn) \
00152     DECLARE_EVENT_TABLE_ENTRY( wxEVT_SLIDEBAR_SIZE_CHANGED, -1, -1, \
00153         (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxCommandEventFunction, & fn ), NULL ),
00154 #define EVT_SLIDEBAR_UPDATE_LAYOUT(fn) \
00155     DECLARE_EVENT_TABLE_ENTRY( wxEVT_SLIDEBAR_UPDATE_LAYOUT, -1, -1, \
00156         (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxCommandEventFunction, & fn ), NULL ),
00157 #endif
00158 
00159 #endif
00160     // _WX_SLIDEBAR_H_

Generated on Sat May 14 14:54:39 2005 for wxDockIt by  doxygen 1.4.2