]> git.saurik.com Git - wxWidgets.git/commitdiff
Added some standard further identifiers to help with WinCE toolbars
authorJulian Smart <julian@anthemion.co.uk>
Fri, 18 Jul 2003 16:16:14 +0000 (16:16 +0000)
committerJulian Smart <julian@anthemion.co.uk>
Fri, 18 Jul 2003 16:16:14 +0000 (16:16 +0000)
Moved wxID_REPLACE to defs.h
Can now add tools to WinCE toolbar, if using standard identifiers

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

docs/latex/wx/tevent.tex
include/wx/defs.h
samples/toolbar/toolbar.cpp
src/common/framecmn.cpp
src/generic/fdrepdlg.cpp
src/msw/menu.cpp
src/msw/wince/tbarwce.cpp

index 12d45d3e2c538a50dec4ee1c97227eeb514c0f0c..7d746e98de00c7f84053109efd7f7062e5a55ad2 100644 (file)
@@ -319,6 +319,19 @@ you can use identifiers below wxID\_LOWEST.
 #define wxID_FIND               5034
 #define wxID_DUPLICATE          5035
 #define wxID_SELECTALL          5036
+#define wxID_DELETE             5037
+#define wxID_REPLACE            5038
+#define wxID_REPLACE_ALL        5039
+#define wxID_PROPERTIES         5040
+
+#define wxID_VIEW_DETAILS       5041
+#define wxID_VIEW_LARGEICONS    5042
+#define wxID_VIEW_SMALLICONS    5043
+#define wxID_VIEW_LIST          5044
+#define wxID_VIEW_SORTDATE      5045
+#define wxID_VIEW_SORTNAME      5046
+#define wxID_VIEW_SORTSIZE      5047
+#define wxID_VIEW_SORTTYPE      5048
 
 #define wxID_FILE1              5050
 #define wxID_FILE2              5051
index ff6a1e99fad3dcfb2169163bbcec3a4e33c2d9c4..4d49f427e572179700e073d2a5364bbd8d005e2f 100644 (file)
@@ -1388,6 +1388,19 @@ enum
     wxID_FIND,
     wxID_DUPLICATE,
     wxID_SELECTALL,
+    wxID_DELETE,
+    wxID_REPLACE,
+    wxID_REPLACE_ALL,
+    wxID_PROPERTIES,
+
+    wxID_VIEW_DETAILS,
+    wxID_VIEW_LARGEICONS,
+    wxID_VIEW_SMALLICONS,
+    wxID_VIEW_LIST,
+    wxID_VIEW_SORTDATE,
+    wxID_VIEW_SORTNAME,
+    wxID_VIEW_SORTSIZE,
+    wxID_VIEW_SORTTYPE,
 
     wxID_FILE1 = 5050,
     wxID_FILE2,
index b08c9cae8750f29249b3cd944cefc333a773db50..cda93e9e868f18b3dd2c21af6e7d29efe555c3e8 100644 (file)
@@ -233,7 +233,12 @@ bool MyApp::OnInit()
     // Create the main frame window
     MyFrame* frame = new MyFrame((wxFrame *) NULL, -1,
                                  _T("wxToolBar Sample"),
-                                 wxPoint(100, 100), wxSize(550, 300));
+#ifdef __WXWINCE__
+                                 wxPoint(0, 0), wxDefaultSize, wxNO_BORDER
+#else
+                                 wxPoint(100, 100), wxSize(550, 300)
+#endif
+                                 );
 
     frame->Show(TRUE);
 
@@ -246,6 +251,12 @@ bool MyApp::OnInit()
 
 void MyFrame::RecreateToolbar()
 {
+#ifdef __WXWINCE__
+    // On Windows CE, we should not delete the
+    // previous toolbar in case it contains the menubar.
+    // We'll try to accomodate this usage in due course.
+    wxToolBar* toolBar = CreateToolBar();
+#else
     // delete and recreate the toolbar
     wxToolBarBase *toolBar = GetToolBar();
     long style = toolBar ? toolBar->GetWindowStyle() : TOOLBAR_STYLE;
@@ -258,6 +269,7 @@ void MyFrame::RecreateToolbar()
     style |= m_horzToolbar ? wxTB_HORIZONTAL : wxTB_VERTICAL;
 
     toolBar = CreateToolBar(style, ID_TOOLBAR);
+#endif
 
     // Set up toolbar
     wxBitmap toolBarBitmaps[8];
@@ -349,8 +361,10 @@ MyFrame::MyFrame(wxFrame* parent,
     m_rows = 1;
     m_nPrint = 1;
 
+#ifndef __WXWINCE__
     // Give it a status line
     CreateStatusBar();
+#endif
 
     // Give it an icon
     SetIcon(wxICON(mondrian));
index 4abe465d336fe16bd33dd8658e0a18085245bd6b..cbf6bf21ee24a0501d9aef1c7ee4672dc29296e8 100644 (file)
@@ -151,7 +151,7 @@ wxPoint wxFrameBase::GetClientAreaOrigin() const
 {
     wxPoint pt = wxTopLevelWindow::GetClientAreaOrigin();
 
-#if wxUSE_TOOLBAR && !defined(__WXUNIVERSAL__)
+#if wxUSE_TOOLBAR && !defined(__WXUNIVERSAL__) && !defined(__WXWINCE__)
     wxToolBar *toolbar = GetToolBar();
     if ( toolbar && toolbar->IsShown() )
     {
index 8d96a93a3a45a213762d77394d5dfddcd08c1421..e62385ca8eab0dee4d9e1a05d086a5f8e37757cc 100644 (file)
 // constants
 // ----------------------------------------------------------------------------
 
-enum
-{
-    wxID_REPLACE = 5890,
-    wxID_REPLACE_ALL
-};
-
 // ============================================================================
 // implementation
 // ============================================================================
index 6bce598d97bcbefbf583ab69716a91fdc89233f4..e8c4c22ce1025cd7fa02c9ebb24ecf49e1d98d47 100644 (file)
@@ -615,7 +615,10 @@ wxMenuBar::~wxMenuBar()
 {
     // In Windows CE, the menubar is always associated
     // with a toolbar, which destroys the menu implicitly.
-#ifndef __WXWINCE__
+#ifdef __WXWINCE__
+    if (GetToolBar())
+        GetToolBar()->SetMenuBar(NULL);
+#else
     // we should free Windows resources only if Windows doesn't do it for us
     // which happens if we're attached to a frame
     if (m_hMenu && !IsAttached())
index 554b07da26cc1b1ee493a34175af2da424db8fec..8bf694bdbf41a20c9287b1c30ed997cf2108e77f 100644 (file)
@@ -285,44 +285,7 @@ bool wxToolBar::MSWCreateToolbar(const wxPoint& pos, const wxSize& size, wxMenuB
 
     if (menuBar)
         menuBar->Create();
-#if 0
-    {
-        HMENU hMenu = (HMENU)::SendMessage(mbi.hwndMB, SHCMBM_GETMENU, (WPARAM)0, (LPARAM)0);
-        if (hMenu)
-        {
-            TBBUTTON tbButton; 
-            memset(&tbButton, 0, sizeof(TBBUTTON));
-            tbButton.iBitmap = I_IMAGENONE;
-            tbButton.fsState = TBSTATE_ENABLED;
-            tbButton.fsStyle = TBSTYLE_DROPDOWN | TBSTYLE_NO_DROPDOWN_ARROW | TBSTYLE_AUTOSIZE;
-            
-            size_t i;
-            for (i = 0; i < menuBar->GetMenuCount(); i++)
-            {
-                HMENU hPopupMenu = (HMENU) menuBar->GetMenu(i)->GetHMenu() ;
-                tbButton.dwData = (DWORD)hPopupMenu;
-                wxString label = wxStripMenuCodes(menuBar->GetLabelTop(i));
-                tbButton.iString = (int) label.c_str();
-
-                tbButton.idCommand = NewControlId();
-                if (!::SendMessage((HWND) GetHWND(), TB_INSERTBUTTON, i, (LPARAM)&tbButton))
-                {
-                    wxLogLastError(wxT("TB_INSERTBUTTON"));
-                }
-            }
-        }
-    }
-#endif
-    
-#if 0
-    CommandBar_AddToolTips(    hwndCB,    uNumSmallTips,szSmallTips);
     
-    CommandBar_AddBitmap(hwndCB, HINST_COMMCTRL, IDB_STD_SMALL_COLOR,
-        15, 16, 16);
-    // Add buttons in tbSTDButton to Commandbar
-    CommandBar_AddButtons(hwndCB, sizeof(tbSTDButton)/sizeof(TBBUTTON),
-        tbSTDButton);
-#endif    
     return TRUE;
 }
 
@@ -378,6 +341,9 @@ void wxToolBar::Recreate()
 
 wxToolBar::~wxToolBar()
 {
+    if (GetMenuBar())
+        GetMenuBar()->SetToolBar(NULL);
+
     // we must refresh the frame size when the toolbar is deleted but the frame
     // is not - otherwise toolbar leaves a hole in the place it used to occupy
     wxFrame *frame = wxDynamicCast(GetParent(), wxFrame);
@@ -548,6 +514,69 @@ bool wxToolBar::DoDeleteTool(size_t pos, wxToolBarToolBase *tool)
     return TRUE;
 }
 
+struct wxToolBarIdMapping
+{
+    int m_wxwinId;
+    int m_winceId;
+};
+
+static wxToolBarIdMapping sm_ToolBarIdMappingArray[] =
+{
+    { wxID_COPY, STD_COPY },
+    { wxID_CUT, STD_CUT },
+    { wxID_FIND, STD_FIND },
+    { wxID_PASTE, STD_PASTE },
+    { wxID_NEW, STD_FILENEW },
+    { wxID_OPEN, STD_FILEOPEN },
+    { wxID_SAVE, STD_FILESAVE },
+    { wxID_PRINT, STD_PRINT },
+    { wxID_PREVIEW, STD_PRINTPRE },
+    { wxID_UNDO, STD_UNDO  },
+    { wxID_REDO, STD_REDOW },
+    { wxID_HELP, STD_HELP },
+    { wxID_DELETE, STD_DELETE },
+    { wxID_REPLACE, STD_REPLACE },
+    { wxID_PROPERTIES, STD_PROPERTIES },
+    { wxID_VIEW_DETAILS, VIEW_DETAILS },
+    { wxID_VIEW_SORTDATE, VIEW_SORTDATE },
+    { wxID_VIEW_LARGEICONS, VIEW_LARGEICONS },
+    { wxID_VIEW_SORTNAME, VIEW_SORTNAME },
+    { wxID_VIEW_LIST, VIEW_LIST },
+    { wxID_VIEW_SORTSIZE, VIEW_SORTSIZE },
+    { wxID_VIEW_SMALLICONS, VIEW_SMALLICONS },
+    { wxID_VIEW_SORTTYPE, VIEW_SORTTYPE },
+    { 0, 0},
+};
+
+static int wxFindIdForWinceId(int id)
+{
+    int i = 0;
+    while (TRUE)
+    {
+        if (sm_ToolBarIdMappingArray[i].m_winceId == 0)
+            return -1;
+        else if (sm_ToolBarIdMappingArray[i].m_winceId == id)
+            return sm_ToolBarIdMappingArray[i].m_wxwinId;
+        i ++;
+    }
+    return -1;
+}
+
+static int wxFindIdForwxWinId(int id)
+{
+    int i = 0;
+    while (TRUE)
+    {
+        if (sm_ToolBarIdMappingArray[i].m_wxwinId == 0)
+            return -1;
+        else if (sm_ToolBarIdMappingArray[i].m_wxwinId == id)
+            return sm_ToolBarIdMappingArray[i].m_winceId;
+        i ++;
+    }
+    return -1;
+}
+
+
 bool wxToolBar::Realize()
 {
     const size_t nTools = GetToolsCount();
@@ -573,6 +602,10 @@ bool wxToolBar::Realize()
     // add the buttons and separators
     // ------------------------------
 
+    // Use standard buttons
+    CommandBar_AddBitmap((HWND) GetHWND(), HINST_COMMCTRL,
+        IDB_STD_SMALL_COLOR, 0, 16, 16);
+
     TBBUTTON *buttons = new TBBUTTON[nTools];
 
     // this array will hold the indices of all controls in the toolbar
@@ -585,6 +618,8 @@ bool wxToolBar::Realize()
     {
         wxToolBarToolBase *tool = node->GetData();
 
+        bool processedThis = TRUE;
+
         TBBUTTON& button = buttons[i];
 
         wxZeroMemory(button);
@@ -602,10 +637,8 @@ bool wxToolBar::Realize()
                 break;
 
             case wxTOOL_STYLE_BUTTON:
-                    // TODO
-#if 0
-                if ( !HasFlag(wxTB_NOICONS) )
-                    button.iBitmap = bitmapId;
+//                if ( !HasFlag(wxTB_NOICONS) )
+//                    button.iBitmap = bitmapId;
 
                 if ( HasFlag(wxTB_TEXT) )
                 {
@@ -616,7 +649,15 @@ bool wxToolBar::Realize()
                     }
                 }
 
-                button.idCommand = tool->GetId();
+                int winceId = wxFindIdForwxWinId(tool->GetId());
+                if (winceId > -1)
+                {
+                    button.idCommand = tool->GetId();
+//                if ( !HasFlag(wxTB_NOICONS) )
+                    button.iBitmap = winceId;
+                }
+                else
+                    processedThis = FALSE;
 
                 if ( tool->IsEnabled() )
                     button.fsState |= TBSTATE_ENABLED;
@@ -653,17 +694,17 @@ bool wxToolBar::Realize()
                         button.fsStyle = TBSTYLE_BUTTON;
                 }
 
-                bitmapId++;
-#endif
+//                bitmapId++;
                 break;
         }
 
         lastWasRadio = isRadio;
 
-        i++;
+        if (processedThis)
+            i++;
     }
 
-    // Add buttons in tbSTDButton to Commandbar
+    // Add buttons to Commandbar
     if (!CommandBar_AddButtons(GetHwnd(), i, buttons))
     {
         wxLogLastError(wxT("CommandBar_AddButtons"));