]> git.saurik.com Git - wxWidgets.git/commitdiff
1. added code to dyntbar to allow bitmap loading from windows resources
authorJ. Russell Smyth <drfish@cox.net>
Sat, 13 Mar 1999 00:42:30 +0000 (00:42 +0000)
committerJ. Russell Smyth <drfish@cox.net>
Sat, 13 Mar 1999 00:42:30 +0000 (00:42 +0000)
2. modified fl_demo sample to use bitmaps in windows resource to allow
   run-from-anywhere behaviour under windows.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1921 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

utils/framelayout/README
utils/framelayout/samples/demo/fl_demo.cpp
utils/framelayout/samples/demo/fl_demo.rc
utils/framelayout/src/dyntbar.cpp
utils/framelayout/src/dyntbar.h

index c606d30d555deaa61248b1e2f762ee2107eb04b6..3ec6e16bc3fff715a1279751b22005b294242850 100644 (file)
@@ -22,6 +22,10 @@ trivial to adapt this for other systems that use a configure build.
 YOU NEED TO RUN THE SAMPLES FROM THIS BITMAP DIR otherwise the binaries
 can't find their pics and horrible things will ensue.
 
 YOU NEED TO RUN THE SAMPLES FROM THIS BITMAP DIR otherwise the binaries
 can't find their pics and horrible things will ensue.
 
+<03-12-99 Russell>
+/samples/demo/fl_demo no longer needs to be run from the bitmap dir under
+windows, it now uses windows resources.
+
 -----------------------------------------------------------------------------
 BUILDING
 -----------------------------------------------------------------------------
 -----------------------------------------------------------------------------
 BUILDING
 -----------------------------------------------------------------------------
index ea69a4d46398107e5e8a39d28c19ef67aaca2407..27483bee96411fc6d3e3763b0c421288aace7632 100644 (file)
@@ -192,14 +192,26 @@ void StartButton95::OnPaint( wxPaintEvent& event )
 
     if ( mPressed )
     {
 
     if ( mPressed )
     {
+#ifdef __WXMSW__
+        if ( !mPBmp.Ok()  )
+    
+            mPBmp.LoadFile( "start95_pr_icon", wxBITMAP_TYPE_BMP_RESOURCE );
+#else
         if ( !mPBmp.Ok() && wxFileExists( "start95_pr.bmp" ) )
     
             mPBmp.LoadFile( "start95_pr.bmp", wxBITMAP_TYPE_BMP );
         if ( !mPBmp.Ok() && wxFileExists( "start95_pr.bmp" ) )
     
             mPBmp.LoadFile( "start95_pr.bmp", wxBITMAP_TYPE_BMP );
+#endif
 
         pBmp = &mPBmp;
     }
     else
     {
 
         pBmp = &mPBmp;
     }
     else
     {
+#ifdef __WXMSW__
+        if ( !mDBmp.Ok()  )
+                                   
+            mDBmp.LoadFile( "start95_dp_icon", wxBITMAP_TYPE_BMP_RESOURCE );
+
+#endif
         if ( !mDBmp.Ok() && wxFileExists( "start95_dp.bmp" ) )
                                    
             mDBmp.LoadFile( "start95_dp.bmp", wxBITMAP_TYPE_BMP );
         if ( !mDBmp.Ok() && wxFileExists( "start95_dp.bmp" ) )
                                    
             mDBmp.LoadFile( "start95_dp.bmp", wxBITMAP_TYPE_BMP );
@@ -278,13 +290,16 @@ MyFrame::MyFrame(wxFrame *frame, char *title, int x, int y, int w, int h)
     // and use it as initial reference (IR)
 
     wxBitmap bmp1,bmp2;
     // and use it as initial reference (IR)
 
     wxBitmap bmp1,bmp2;
-
+#ifdef __WXMSW__
+    bmp1.LoadFile( "folder_icon", wxBITMAP_TYPE_BMP_RESOURCE );
+    bmp2.LoadFile( "class_icon1", wxBITMAP_TYPE_BMP_RESOURCE );
+#else
     if ( wxFileExists( "folder_icon.bmp" ) )
         bmp1.LoadFile( "folder_icon.bmp", wxBITMAP_TYPE_BMP );
 
     if ( wxFileExists( "class_icon1.bmp" ) )
         bmp2.LoadFile( "class_icon1.bmp", wxBITMAP_TYPE_BMP );
     if ( wxFileExists( "folder_icon.bmp" ) )
         bmp1.LoadFile( "folder_icon.bmp", wxBITMAP_TYPE_BMP );
 
     if ( wxFileExists( "class_icon1.bmp" ) )
         bmp2.LoadFile( "class_icon1.bmp", wxBITMAP_TYPE_BMP );
-
+#endif
     int idx1 = mImageList.Add( bmp1 );
     int idx2 = mImageList.Add( bmp2 );
 
     int idx1 = mImageList.Add( bmp1 );
     int idx2 = mImageList.Add( bmp2 );
 
@@ -749,12 +764,45 @@ void MyFrame::AddSearchToolbars( wxFrameLayout& layout, wxWindow* pParent )
     wxChoice* pChoice = new wxChoice( pTBar2, -1, wxDefaultPosition, wxSize( 140,25 ) );
 
     pTBar2->AddTool( 1, pChoice );
     wxChoice* pChoice = new wxChoice( pTBar2, -1, wxDefaultPosition, wxSize( 140,25 ) );
 
     pTBar2->AddTool( 1, pChoice );
+#ifdef __WXMSW__
+    pTBar2->AddTool( 2, wxBitmap("search_icon") );
+    //pTBar2->AddSeparator();
+    pTBar2->AddTool( 3, wxBitmap("bookmarks_icon") );
+    pTBar2->AddTool( 4, wxBitmap("nextmark_icon") );
+    pTBar2->AddTool( 5, wxBitmap("prevmark_icon") );
+
+
+
+    wxDynamicToolBar* pTBar3 = new wxDynamicToolBar( mpInternalFrm, -1 );
+
+    pTBar3->AddTool( 1, wxBitmap("open_icon"), " Open " );
+    pTBar3->AddTool( 2, wxBitmap("save_icon"), " Save " );
+    pTBar3->AddTool( 3, wxBitmap("saveall_icon"), " Save All " );
+    //pTBar3->AddSeparator();
+    pTBar3->AddTool( 4, wxBitmap("cut_icon"), " Open " );
+    pTBar3->AddTool( 5, wxBitmap("copy_icon"), " Copy " );
+    pTBar3->AddTool( 6, wxBitmap("paste_icon")," Paste " );
+
+    pTBar3->EnableTool( 2, FALSE );
+
+    wxDynamicToolBar* pTBar4 = new wxDynamicToolBar( mpInternalFrm, -1 );
+
+    pTBar4->AddTool( 1, wxBitmap("bookmarks_icon"), "Bookmarks ", TRUE );
+    pTBar4->AddTool( 2, wxBitmap("nextmark_icon"), "Next bookmark ", TRUE );
+    pTBar4->AddTool( 3, wxBitmap("prevmark_icon"), "Prev bookmark ", TRUE );
+    //pTBar4->AddSeparator();
+    pTBar4->AddTool( 4, wxBitmap("search_icon"),"Search ", TRUE );
+
+    pTBar4->EnableTool( 4, FALSE );
+
+#else
     pTBar2->AddTool( 2, "search.bmp" );
     //pTBar2->AddSeparator();
     pTBar2->AddTool( 3, "bookmarks.bmp" );
     pTBar2->AddTool( 4, "nextmark.bmp" );
     pTBar2->AddTool( 5, "prevmark.bmp" );
 
     pTBar2->AddTool( 2, "search.bmp" );
     //pTBar2->AddSeparator();
     pTBar2->AddTool( 3, "bookmarks.bmp" );
     pTBar2->AddTool( 4, "nextmark.bmp" );
     pTBar2->AddTool( 5, "prevmark.bmp" );
 
+
     wxDynamicToolBar* pTBar3 = new wxDynamicToolBar( mpInternalFrm, -1 );
 
     pTBar3->AddTool( 1, "open.bmp", wxBITMAP_TYPE_BMP, " Open " );
     wxDynamicToolBar* pTBar3 = new wxDynamicToolBar( mpInternalFrm, -1 );
 
     pTBar3->AddTool( 1, "open.bmp", wxBITMAP_TYPE_BMP, " Open " );
@@ -765,10 +813,6 @@ void MyFrame::AddSearchToolbars( wxFrameLayout& layout, wxWindow* pParent )
     pTBar3->AddTool( 5, "copy.bmp",  wxBITMAP_TYPE_BMP, " Copy " );
     pTBar3->AddTool( 6, "paste.bmp", wxBITMAP_TYPE_BMP, " Paste " );
 
     pTBar3->AddTool( 5, "copy.bmp",  wxBITMAP_TYPE_BMP, " Copy " );
     pTBar3->AddTool( 6, "paste.bmp", wxBITMAP_TYPE_BMP, " Paste " );
 
-#ifdef __WXMSW__
-    pTBar3->EnableTool( 2, FALSE );
-#endif
-
     wxDynamicToolBar* pTBar4 = new wxDynamicToolBar( mpInternalFrm, -1 );
 
     pTBar4->AddTool( 1, "bookmarks.bmp", wxBITMAP_TYPE_BMP, "Bookmarks ", TRUE );
     wxDynamicToolBar* pTBar4 = new wxDynamicToolBar( mpInternalFrm, -1 );
 
     pTBar4->AddTool( 1, "bookmarks.bmp", wxBITMAP_TYPE_BMP, "Bookmarks ", TRUE );
@@ -776,9 +820,6 @@ void MyFrame::AddSearchToolbars( wxFrameLayout& layout, wxWindow* pParent )
     pTBar4->AddTool( 3, "prevmark.bmp",  wxBITMAP_TYPE_BMP, "Prev bookmark ", TRUE );
     //pTBar4->AddSeparator();
     pTBar4->AddTool( 4, "search.bmp", wxBITMAP_TYPE_BMP, "Search ", TRUE );
     pTBar4->AddTool( 3, "prevmark.bmp",  wxBITMAP_TYPE_BMP, "Prev bookmark ", TRUE );
     //pTBar4->AddSeparator();
     pTBar4->AddTool( 4, "search.bmp", wxBITMAP_TYPE_BMP, "Search ", TRUE );
-
-#ifdef __WXMSW__
-    pTBar4->EnableTool( 4, FALSE );
 #endif
 
     layout.AddBar( pTBar2,              
 #endif
 
     layout.AddBar( pTBar2,              
@@ -865,13 +906,22 @@ wxWindow* MyFrame::CreateDevLayout( wxFrameLayout& layout, wxWindow* pParent )
     ::wxCreateClassInfoTree( pClassView, cinfId,     1 );
     ::wxCreateSerializerInfoTree( pClassView, serId, 1 );
 
     ::wxCreateClassInfoTree( pClassView, cinfId,     1 );
     ::wxCreateSerializerInfoTree( pClassView, serId, 1 );
 
-                                                                          // (default arg anyway)
+#ifdef __WXMSW__
+                                                                         // (default arg anyway)
+    pMiniTabArea->AddTab( pClassView,    "ClassView",   &wxBitmap("class_icon"));
+    pMiniTabArea->AddTab( new wxPanel(), "ResourceView",&wxBitmap("res_icon") );
+    pMiniTabArea->AddTab( new wxPanel(), "FileView",    &wxBitmap("file_icon") );
+    pMiniTabArea->AddTab( new wxPanel(), "InfoView",    &wxBitmap("help_icon") );
+    pMiniTabArea->AddTab( CreateTxtCtrl( helloworld_src, 
+                                         pMiniTabArea), "HelloWorld", &wxBitmap("help_icon") );
+#else
     pMiniTabArea->AddTab( pClassView,    "ClassView",   "class_icon.bmp", wxBITMAP_TYPE_BMP );
     pMiniTabArea->AddTab( new wxPanel(), "ResourceView","res_icon.bmp"  );
     pMiniTabArea->AddTab( new wxPanel(), "FileView",    "file_icon.bmp" );
     pMiniTabArea->AddTab( new wxPanel(), "InfoView",    "help_icon.bmp" );
     pMiniTabArea->AddTab( CreateTxtCtrl( helloworld_src, 
                                          pMiniTabArea), "HelloWorld", "help_icon.bmp" );
     pMiniTabArea->AddTab( pClassView,    "ClassView",   "class_icon.bmp", wxBITMAP_TYPE_BMP );
     pMiniTabArea->AddTab( new wxPanel(), "ResourceView","res_icon.bmp"  );
     pMiniTabArea->AddTab( new wxPanel(), "FileView",    "file_icon.bmp" );
     pMiniTabArea->AddTab( new wxPanel(), "InfoView",    "help_icon.bmp" );
     pMiniTabArea->AddTab( CreateTxtCtrl( helloworld_src, 
                                          pMiniTabArea), "HelloWorld", "help_icon.bmp" );
+#endif
     // now create "output" window
 
     wxPaggedWindow* pTabbedArea = new wxPaggedWindow();
     // now create "output" window
 
     wxPaggedWindow* pTabbedArea = new wxPaggedWindow();
@@ -884,7 +934,7 @@ wxWindow* MyFrame::CreateDevLayout( wxFrameLayout& layout, wxWindow* pParent )
 
     pTabbedArea->AddTab( CreateTxtCtrl("build",   pTabbedArea), "Build",  "" );
     pTabbedArea->AddTab( CreateTxtCtrl("debug",   pTabbedArea), "Debug",  "" );
 
     pTabbedArea->AddTab( CreateTxtCtrl("build",   pTabbedArea), "Build",  "" );
     pTabbedArea->AddTab( CreateTxtCtrl("debug",   pTabbedArea), "Debug",  "" );
-    pTabbedArea->AddTab( pSheet3,                               "Find in Files!", "file_icon.bmp" );
+    pTabbedArea->AddTab( pSheet3,                               "Find in Files!", &wxBitmap("file_icon") );
     pTabbedArea->AddTab( CreateTxtCtrl("profile", pTabbedArea), "Profile", "" );
 
     layout.AddBar( new StartButton95(pParent), sizes5, wxTOP,    0, 0,  "Start..." );
     pTabbedArea->AddTab( CreateTxtCtrl("profile", pTabbedArea), "Profile", "" );
 
     layout.AddBar( new StartButton95(pParent), sizes5, wxTOP,    0, 0,  "Start..." );
@@ -1008,7 +1058,15 @@ void MyFrame::DropInSomeBars( int layoutNo )
                pToolBar->Create( mpInternalFrm, -1 );
                                                                 
                // 1001-1006 ids of command events fired by added tool-buttons
                pToolBar->Create( mpInternalFrm, -1 );
                                                                 
                // 1001-1006 ids of command events fired by added tool-buttons
-               
+#ifdef __WXMSW__               
+               pToolBar->AddTool( 1001, wxBitmap("new_icon") );
+               pToolBar->AddTool( 1002, wxBitmap("open_icon") );
+               pToolBar->AddTool( 1003, wxBitmap("save_icon") );
+
+               pToolBar->AddTool( 1004, wxBitmap("cut_icon") );
+               pToolBar->AddTool( 1005, wxBitmap("copy_icon") );
+               pToolBar->AddTool( 1006, wxBitmap("paste_icon") );
+#else
                pToolBar->AddTool( 1001, "new.bmp" );
                pToolBar->AddTool( 1002, "open.bmp" );
                pToolBar->AddTool( 1003, "save.bmp" );
                pToolBar->AddTool( 1001, "new.bmp" );
                pToolBar->AddTool( 1002, "open.bmp" );
                pToolBar->AddTool( 1003, "save.bmp" );
@@ -1016,7 +1074,7 @@ void MyFrame::DropInSomeBars( int layoutNo )
                pToolBar->AddTool( 1004, "cut.bmp" );
                pToolBar->AddTool( 1005, "copy.bmp" );
                pToolBar->AddTool( 1006, "paste.bmp" );
                pToolBar->AddTool( 1004, "cut.bmp" );
                pToolBar->AddTool( 1005, "copy.bmp" );
                pToolBar->AddTool( 1006, "paste.bmp" );
-
+#endif
                layout.AddBar( pToolBar,  // bar window (can be NULL)
                                           sizes10, wxTOP,         // alignment ( 0-top,1-bottom, etc)
                                           0,                     // insert into 0th row (vert. position)
                layout.AddBar( pToolBar,  // bar window (can be NULL)
                                           sizes10, wxTOP,         // alignment ( 0-top,1-bottom, etc)
                                           0,                     // insert into 0th row (vert. position)
index 82bdf07561820e7c4fad310d1cc21b72b5cb7ef7..4acfb02372ab9054c879cedf29518f2b3b13ae72 100644 (file)
@@ -1,2 +1,20 @@
 #include "wx/msw/wx.rc"
 #include "wx/msw/wx.rc"
+start95_pr_icon        BITMAP "../bitmaps/start95_pr.bmp"
+start95_dp_icon BITMAP "../bitmaps/start95_dp.bmp"
+folder_icon    BITMAP "../bitmaps/folder_icon.bmp"
+class_icon1 BITMAP "../bitmaps/class_icon1.bmp"
+class_icon BITMAP "../bitmaps/class_icon.bmp"
+res_icon BITMAP "../bitmaps/res_icon.bmp"
+file_icon BITMAP "../bitmaps/file_icon.bmp"
+help_icon BITMAP "../bitmaps/help_icon.bmp"
+search_icon BITMAP "../bitmaps/search.bmp"
+bookmarks_icon BITMAP "../bitmaps/bookmarks.bmp"
+nextmark_icon BITMAP "../bitmaps/nextmark.bmp"
+prevmark_icon BITMAP "../bitmaps/prevmark.bmp"
+open_icon BITMAP "../bitmaps/open.bmp"
+save_icon BITMAP "../bitmaps/save.bmp"
+saveall_icon BITMAP "../bitmaps/saveall.bmp"
+cut_icon BITMAP "../bitmaps/cut.bmp"
+copy_icon BITMAP "../bitmaps/copy.bmp"
+paste_icon BITMAP "../bitmaps/paste.bmp"
 
 
index cc5aa166bc41cf7ce2febe0f7cad777901c9d911..e455a5947e52cd96ed45f855e8dc4b7eaa4485d1 100644 (file)
@@ -145,6 +145,26 @@ void wxDynamicToolBar::AddTool( int toolIndex,
        
        AddTool( toolIndex, pBtn );
 }
        
        AddTool( toolIndex, pBtn );
 }
+void wxDynamicToolBar::AddTool( int toolIndex, wxBitmap labelBmp,
+                                                               const wxString& labelText, bool alignTextRight,
+                                                               bool isFlat )
+{
+       wxNewBitmapButton* pBtn =
+
+         new wxNewBitmapButton( labelBmp,
+                                                        labelText, 
+                                                        ( alignTextRight ) 
+                                                        ? NB_ALIGN_TEXT_RIGHT 
+                                                        : NB_ALIGN_TEXT_BOTTOM,
+                                                        isFlat
+                                                  );
+
+       pBtn->Create( this, toolIndex );
+
+       pBtn->Reshape();
+       
+       AddTool( toolIndex, pBtn );
+}
 
 
   wxToolBarTool* 
 
 
   wxToolBarTool* 
index c2815632b3066dbfc05a2139c45400cd251b5c22..e05f2e2e275ad2c49108aebe771b88736965f31f 100644 (file)
@@ -120,6 +120,9 @@ public:
                                                  int imageFileType = wxBITMAP_TYPE_BMP,
                                                  const wxString& labelText = "", bool alignTextRight = FALSE,
                                                  bool isFlat = TRUE );
                                                  int imageFileType = wxBITMAP_TYPE_BMP,
                                                  const wxString& labelText = "", bool alignTextRight = FALSE,
                                                  bool isFlat = TRUE );
+       virtual void AddTool( int toolIndex, wxBitmap labelBmp,
+                                                 const wxString& labelText = "", bool alignTextRight = FALSE,
+                                                 bool isFlat = TRUE );
 
        // method from wxToolBarBase (for compatibility), only
        // first two arguments are valid
 
        // method from wxToolBarBase (for compatibility), only
        // first two arguments are valid