// 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);
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;
style |= m_horzToolbar ? wxTB_HORIZONTAL : wxTB_VERTICAL;
toolBar = CreateToolBar(style, ID_TOOLBAR);
+#endif
// Set up toolbar
wxBitmap toolBarBitmaps[8];
m_rows = 1;
m_nPrint = 1;
+#ifndef __WXWINCE__
// Give it a status line
CreateStatusBar();
+#endif
// Give it an icon
SetIcon(wxICON(mondrian));
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;
}
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);
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();
// 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
{
wxToolBarToolBase *tool = node->GetData();
+ bool processedThis = TRUE;
+
TBBUTTON& button = buttons[i];
wxZeroMemory(button);
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) )
{
}
}
- 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;
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"));