IMPLEMENT_DYNAMIC_CLASS_XTI(wxFrame, wxTopLevelWindow,"wx/frame.h")
wxBEGIN_PROPERTIES_TABLE(wxFrame)
- wxEVENT_PROPERTY( Menu , wxEVT_COMMAND_MENU_SELECTED , wxCommandEvent)
+ wxEVENT_PROPERTY( Menu , wxEVT_COMMAND_MENU_SELECTED , wxCommandEvent)
wxPROPERTY( Title,wxString, SetTitle, GetTitle, wxString() , 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
- wxPROPERTY_FLAGS( WindowStyle , wxFrameStyle , long , SetWindowStyleFlag , GetWindowStyleFlag , , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style
- wxPROPERTY( MenuBar , wxMenuBar * , SetMenuBar , GetMenuBar , , 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
+ wxPROPERTY_FLAGS( WindowStyle , wxFrameStyle , long , SetWindowStyleFlag , GetWindowStyleFlag , EMPTY_MACROVALUE , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style
+ wxPROPERTY( MenuBar , wxMenuBar * , SetMenuBar , GetMenuBar , EMPTY_MACROVALUE , 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
wxEND_PROPERTIES_TABLE()
wxBEGIN_HANDLERS_TABLE(wxFrame)
const wxString& name)
{
if ( !wxTopLevelWindow::Create(parent, id, title, pos, size, style, name) )
- return FALSE;
+ return false;
SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE));
- wxModelessWindows.Append(this);
+#ifdef __SMARTPHONE__
+ SetLeftMenu(wxID_EXIT, _("Done"));
+#endif
- return TRUE;
+ return true;
}
wxFrame::~wxFrame()
void wxFrame::AttachMenuBar(wxMenuBar *menubar)
{
-#if defined(__WXWINCE__) && (_WIN32_WCE < 400 || wxUSE_POCKETPC_UI)
+#if defined(__SMARTPHONE__)
+
+ wxMenu *autoMenu = NULL;
+
+ if( menubar->GetMenuCount() == 1 )
+ {
+ autoMenu = wxTopLevelWindowMSW::ButtonMenu::DuplicateMenu(menubar->GetMenu(0));
+ SetRightMenu(wxID_ANY, menubar->GetLabelTop(0), autoMenu);
+ }
+ else
+ {
+ autoMenu = new wxMenu;
+
+ for( size_t n = 0; n < menubar->GetMenuCount(); n++ )
+ {
+ wxMenu *item = menubar->GetMenu(n);
+ wxString label = menubar->GetLabelTop(n);
+ wxMenu *new_item = wxTopLevelWindowMSW::ButtonMenu::DuplicateMenu(item);
+ autoMenu->Append(wxID_ANY, label, new_item);
+ }
+
+ SetRightMenu(wxID_ANY, _("Menu"), autoMenu);
+ }
+
+#elif defined(WINCE_WITHOUT_COMMANDBAR)
if (!GetToolBar())
{
wxToolBar* toolBar = new wxToolBar(this, -1,
SetToolBar(toolBar);
menubar->SetToolBar(toolBar);
}
+ // Now adjust size for menu bar
+ int menuHeight = 26;
+
+ //When the main window is created using CW_USEDEFAULT the height of the
+ // is created is not taken into account). So we resize the window after
+ // if a menubar is present
+ {
+ RECT rc;
+ ::GetWindowRect((HWND) GetHWND(), &rc);
+ // adjust for menu / titlebar height
+ rc.bottom -= (2*menuHeight-1);
+
+ MoveWindow((HWND) GetHWND(), rc.left, rc.top, rc.right, rc.bottom, FALSE);
+ }
#endif
wxFrameBase::AttachMenuBar(menubar);
}
else // set new non NULL menu bar
{
-#if !defined(__WXWINCE__) || (_WIN32_WCE >= 400 && !wxUSE_POCKETPC_UI)
+#if !defined(__WXWINCE__) || defined(WINCE_WITH_COMMANDBAR)
// Can set a menubar several times.
if ( menubar->GetHMenu() )
{
if (show)
{
#if wxUSE_TOOLBAR
-#if defined(__WXWINCE__) && (_WIN32_WCE < 400 || wxUSE_POCKETPC_UI)
+
+#if defined(WINCE_WITH_COMMANDBAR)
// TODO: hide commandbar
#else
wxToolBar *theToolBar = GetToolBar();
else
{
#if wxUSE_TOOLBAR
-#if defined(__WXWINCE__) && (_WIN32_WCE < 400 || wxUSE_POCKETPC_UI)
+#if defined(WINCE_WITHOUT_COMMANDBAR)
// TODO: show commandbar
#else
wxToolBar *theToolBar = GetToolBar();
wxToolBar* wxFrame::CreateToolBar(long style, wxWindowID id, const wxString& name)
{
-#if defined(__WXWINCE__) && (_WIN32_WCE < 400 || wxUSE_POCKETPC_UI)
+#if defined(WINCE_WITHOUT_COMMANDBAR)
// We may already have a toolbar from calling SetMenuBar.
if (GetToolBar())
return GetToolBar();
wxToolBar *toolbar = GetToolBar();
if ( toolbar && toolbar->IsShown() )
{
-#if defined(__WXWINCE__) && (_WIN32_WCE < 400 || wxUSE_POCKETPC_UI)
+#if defined(WINCE_WITHOUT_COMMANDBAR)
// We want to do something different in WinCE, because
// the toolbar should be associated with the commandbar,
// and not an independent window.
}
#endif // wxUSE_STATUSBAR
+ int x = 0;
+ int y = 0;
+#if defined(WINCE_WITH_COMMANDBAR)
+ // We're using a commandbar - so we have to allow for it.
+ if (GetMenuBar() && GetMenuBar()->GetCommandBar())
+ {
+ RECT rect;
+ ::GetWindowRect((HWND) GetMenuBar()->GetCommandBar(), &rect);
+ y = rect.bottom - rect.top;
+ }
+#endif
+
int tx, ty;
int tw, th;
toolbar->GetPosition(&tx, &ty);
}
if (tx != 0 || ty != 0 || widthChanging || heightChanging)
- toolbar->SetSize(0, 0, desiredW, desiredH, wxSIZE_NO_ADJUSTMENTS);
+ toolbar->SetSize(x, y, desiredW, desiredH, wxSIZE_NO_ADJUSTMENTS);
#endif // __WXWINCE__
}
PositionToolBar();
#endif // wxUSE_TOOLBAR
+#if defined(WINCE_WITH_COMMANDBAR)
+ // Position the menu command bar
+ if (GetMenuBar() && GetMenuBar()->GetCommandBar())
+ {
+ RECT rect;
+ ::GetWindowRect((HWND) GetMenuBar()->GetCommandBar(), &rect);
+ wxSize clientSz = GetClientSize();
+
+ if ( !::MoveWindow((HWND) GetMenuBar()->GetCommandBar(), 0, 0, clientSz.x, rect.bottom - rect.top, true ) )
+ {
+ wxLogLastError(wxT("MoveWindow"));
+ }
+
+ }
+#endif
+
+
processed = wxWindow::HandleSize(x, y, id);
}
}
#endif // wxUSE_MENUS_NATIVE
+#ifdef __SMARTPHONE__
+ // handle here commands from Smartphone menu bar
+ if ( wxTopLevelWindow::HandleCommand(id, cmd, control ) )
+ {
+ return true;
+ }
+#endif // __SMARTPHONE__
+
if ( ProcessCommand(id) )
{
return TRUE;
return GetEventHandler()->ProcessEvent(event);
}
+
+// ----------------------------------------------------------------------------
+// wxFrame size management: we exclude the areas taken by menu/status/toolbars
+// from the client area, so the client area is what's really available for the
+// frame contents
+// ----------------------------------------------------------------------------
+
+// get the origin of the client area in the client coordinates
+wxPoint wxFrame::GetClientAreaOrigin() const
+{
+ wxPoint pt = wxTopLevelWindow::GetClientAreaOrigin();
+
+#if wxUSE_TOOLBAR && !defined(__WXUNIVERSAL__) && \
+ (!defined(__WXWINCE__) || (_WIN32_WCE >= 400 && !defined(__POCKETPC__) && !defined(__SMARTPHONE__)))
+ wxToolBar *toolbar = GetToolBar();
+ if ( toolbar && toolbar->IsShown() )
+ {
+ int w, h;
+ toolbar->GetSize(&w, &h);
+
+ if ( toolbar->GetWindowStyleFlag() & wxTB_VERTICAL )
+ {
+ pt.x += w;
+ }
+ else
+ {
+ pt.y += h;
+ }
+ }
+#endif // wxUSE_TOOLBAR
+
+#if defined(WINCE_WITH_COMMANDBAR)
+ if (GetMenuBar() && GetMenuBar()->GetCommandBar())
+ {
+ RECT rect;
+ ::GetWindowRect((HWND) GetMenuBar()->GetCommandBar(), &rect);
+ pt.y += (rect.bottom - rect.top);
+ }
+#endif
+
+ return pt;
+}