From: Julian Smart Date: Fri, 18 Jul 2003 16:16:14 +0000 (+0000) Subject: Added some standard further identifiers to help with WinCE toolbars X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/bf95a04f16759468ee7af83a7a78019399c648bb Added some standard further identifiers to help with WinCE toolbars 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 --- diff --git a/docs/latex/wx/tevent.tex b/docs/latex/wx/tevent.tex index 12d45d3e2c..7d746e98de 100644 --- a/docs/latex/wx/tevent.tex +++ b/docs/latex/wx/tevent.tex @@ -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 diff --git a/include/wx/defs.h b/include/wx/defs.h index ff6a1e99fa..4d49f427e5 100644 --- a/include/wx/defs.h +++ b/include/wx/defs.h @@ -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, diff --git a/samples/toolbar/toolbar.cpp b/samples/toolbar/toolbar.cpp index b08c9cae87..cda93e9e86 100644 --- a/samples/toolbar/toolbar.cpp +++ b/samples/toolbar/toolbar.cpp @@ -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)); diff --git a/src/common/framecmn.cpp b/src/common/framecmn.cpp index 4abe465d33..cbf6bf21ee 100644 --- a/src/common/framecmn.cpp +++ b/src/common/framecmn.cpp @@ -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() ) { diff --git a/src/generic/fdrepdlg.cpp b/src/generic/fdrepdlg.cpp index 8d96a93a3a..e62385ca8e 100644 --- a/src/generic/fdrepdlg.cpp +++ b/src/generic/fdrepdlg.cpp @@ -49,12 +49,6 @@ // constants // ---------------------------------------------------------------------------- -enum -{ - wxID_REPLACE = 5890, - wxID_REPLACE_ALL -}; - // ============================================================================ // implementation // ============================================================================ diff --git a/src/msw/menu.cpp b/src/msw/menu.cpp index 6bce598d97..e8c4c22ce1 100644 --- a/src/msw/menu.cpp +++ b/src/msw/menu.cpp @@ -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()) diff --git a/src/msw/wince/tbarwce.cpp b/src/msw/wince/tbarwce.cpp index 554b07da26..8bf694bdbf 100644 --- a/src/msw/wince/tbarwce.cpp +++ b/src/msw/wince/tbarwce.cpp @@ -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"));