X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/62f6be4448a1a8ba6b3ddc920df7c0957b7b1f31..77c8efc8c37da6d6a5e2e8022d21d1cd7d76371d:/src/common/framecmn.cpp?ds=sidebyside diff --git a/src/common/framecmn.cpp b/src/common/framecmn.cpp index f83d3e488b..b303b53a36 100644 --- a/src/common/framecmn.cpp +++ b/src/common/framecmn.cpp @@ -33,6 +33,9 @@ #include "wx/statusbr.h" #endif // WX_PRECOMP +extern WXDLLEXPORT_DATA(const char) wxFrameNameStr[] = "frame"; +extern WXDLLEXPORT_DATA(const char) wxStatusLineNameStr[] = "status_line"; + // ---------------------------------------------------------------------------- // event table // ---------------------------------------------------------------------------- @@ -52,6 +55,81 @@ END_EVENT_TABLE() // implementation // ============================================================================ +// ---------------------------------------------------------------------------- +// XTI +// ---------------------------------------------------------------------------- + +wxDEFINE_FLAGS( wxFrameStyle ) +wxBEGIN_FLAGS( wxFrameStyle ) +// new style border flags, we put them first to +// use them for streaming out +wxFLAGS_MEMBER(wxBORDER_SIMPLE) +wxFLAGS_MEMBER(wxBORDER_SUNKEN) +wxFLAGS_MEMBER(wxBORDER_DOUBLE) +wxFLAGS_MEMBER(wxBORDER_RAISED) +wxFLAGS_MEMBER(wxBORDER_STATIC) +wxFLAGS_MEMBER(wxBORDER_NONE) + +// old style border flags +wxFLAGS_MEMBER(wxSIMPLE_BORDER) +wxFLAGS_MEMBER(wxSUNKEN_BORDER) +wxFLAGS_MEMBER(wxDOUBLE_BORDER) +wxFLAGS_MEMBER(wxRAISED_BORDER) +wxFLAGS_MEMBER(wxSTATIC_BORDER) +wxFLAGS_MEMBER(wxBORDER) + +// standard window styles +wxFLAGS_MEMBER(wxTAB_TRAVERSAL) +wxFLAGS_MEMBER(wxCLIP_CHILDREN) +wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW) +wxFLAGS_MEMBER(wxWANTS_CHARS) +wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE) +wxFLAGS_MEMBER(wxALWAYS_SHOW_SB ) +wxFLAGS_MEMBER(wxVSCROLL) +wxFLAGS_MEMBER(wxHSCROLL) + +// frame styles +wxFLAGS_MEMBER(wxSTAY_ON_TOP) +wxFLAGS_MEMBER(wxCAPTION) +#if WXWIN_COMPATIBILITY_2_6 +wxFLAGS_MEMBER(wxTHICK_FRAME) +#endif // WXWIN_COMPATIBILITY_2_6 +wxFLAGS_MEMBER(wxSYSTEM_MENU) +wxFLAGS_MEMBER(wxRESIZE_BORDER) +#if WXWIN_COMPATIBILITY_2_6 +wxFLAGS_MEMBER(wxRESIZE_BOX) +#endif // WXWIN_COMPATIBILITY_2_6 +wxFLAGS_MEMBER(wxCLOSE_BOX) +wxFLAGS_MEMBER(wxMAXIMIZE_BOX) +wxFLAGS_MEMBER(wxMINIMIZE_BOX) + +wxFLAGS_MEMBER(wxFRAME_TOOL_WINDOW) +wxFLAGS_MEMBER(wxFRAME_FLOAT_ON_PARENT) + +wxFLAGS_MEMBER(wxFRAME_SHAPED) +wxEND_FLAGS( wxFrameStyle ) + +wxIMPLEMENT_DYNAMIC_CLASS_XTI(wxFrame, wxTopLevelWindow, "wx/frame.h") + +wxBEGIN_PROPERTIES_TABLE(wxFrame) +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, wxEMPTY_PARAMETER_VALUE, 0 /*flags*/, \ + wxT("Helpstring"), wxT("group")) // style +#if wxUSE_MENUS +wxPROPERTY( MenuBar, wxMenuBar *, SetMenuBar, GetMenuBar, wxEMPTY_PARAMETER_VALUE, \ + 0 /*flags*/, wxT("Helpstring"), wxT("group")) +#endif +wxEND_PROPERTIES_TABLE() + +wxEMPTY_HANDLERS_TABLE(wxFrame) + +wxCONSTRUCTOR_6( wxFrame, wxWindow*, Parent, wxWindowID, Id, wxString, Title, \ + wxPoint, Position, wxSize, Size, long, WindowStyle) + // ---------------------------------------------------------------------------- // construction/destruction // ---------------------------------------------------------------------------- @@ -92,27 +170,15 @@ wxFrame *wxFrameBase::New(wxWindow *parent, void wxFrameBase::DeleteAllBars() { #if wxUSE_MENUS - if ( m_frameMenuBar ) - { - delete m_frameMenuBar; - m_frameMenuBar = NULL; - } + wxDELETE(m_frameMenuBar); #endif // wxUSE_MENUS #if wxUSE_STATUSBAR - if ( m_frameStatusBar ) - { - delete m_frameStatusBar; - m_frameStatusBar = NULL; - } + wxDELETE(m_frameStatusBar); #endif // wxUSE_STATUSBAR #if wxUSE_TOOLBAR - if ( m_frameToolBar ) - { - delete m_frameToolBar; - m_frameToolBar = NULL; - } + wxDELETE(m_frameToolBar); #endif // wxUSE_TOOLBAR } @@ -178,11 +244,7 @@ wxPoint wxFrameBase::GetClientAreaOrigin() const bool wxFrameBase::ProcessCommand(int id) { - wxMenuBar *bar = GetMenuBar(); - if ( !bar ) - return false; - - wxMenuItem *item = bar->FindItem(id); + wxMenuItem* const item = FindItemInMenuBar(id); if ( !item ) return false; @@ -191,8 +253,7 @@ bool wxFrameBase::ProcessCommand(int id) bool wxFrameBase::ProcessCommand(wxMenuItem *item) { - wxCommandEvent commandEvent(wxEVT_COMMAND_MENU_SELECTED, item->GetId()); - commandEvent.SetEventObject(this); + wxCHECK_MSG( item, false, wxS("Menu item can't be NULL") ); if (!item->IsEnabled()) return true; @@ -200,15 +261,23 @@ bool wxFrameBase::ProcessCommand(wxMenuItem *item) if ((item->GetKind() == wxITEM_RADIO) && item->IsChecked() ) return true; + int checked; if (item->IsCheckable()) { item->Toggle(); // use the new value - commandEvent.SetInt(item->IsChecked()); + checked = item->IsChecked(); } + else // Uncheckable item. + { + checked = -1; + } + + wxMenu* const menu = item->GetMenu(); + wxCHECK_MSG( menu, false, wxS("Menu item should be attached to a menu") ); - return HandleWindowEvent(commandEvent); + return menu->SendEvent(item->GetId(), checked); } #endif // wxUSE_MENUS @@ -347,8 +416,10 @@ bool wxFrameBase::ShowMenuHelp(int menuId) { #if wxUSE_MENUS // if no help string found, we will clear the status bar text + // + // NB: wxID_NONE is used for (sub)menus themselves by wxMSW wxString helpString; - if ( menuId != wxID_SEPARATOR && menuId != -3 /* wxID_TITLE */ ) + if ( menuId != wxID_SEPARATOR && menuId != wxID_NONE ) { const wxMenuItem * const item = FindItemInMenuBar(menuId); if ( item && !item->IsSeparator() )