void OnActivate( wxActivateEvent &WXUNUSED(event) ) { } // called from docview.cpp
void OnSize( wxSizeEvent &event );
void OnCloseWindow( wxCloseEvent& event );
+
+ void OnMenuHighlight( wxMenuEvent& event );
// implementation
int FindMenuItem( const wxString &menuString, const wxString &itemString ) const;
wxMenuItem* FindMenuItemById( int id ) const;
- inline wxMenuItem* FindItemForId( int id ) const
- { return FindMenuItemById( id ); }
+ inline wxMenuItem* FindItemForId( int id ) const { return FindMenuItemById( id ); }
void Check( int id, bool check );
bool Checked( int id ) const;
void Enable( int id, bool enable );
bool Enabled( int id ) const;
- inline bool IsEnabled(int Id) const { return Enabled(Id); }
- inline bool IsChecked(int Id) const { return Checked(Id); }
+ inline bool IsEnabled( int id ) const { return Enabled(id); }
+ inline bool IsChecked( int id ) const { return Checked(id); }
wxString GetLabel( int id ) const;
void SetLabel( int id, const wxString &label );
void SetLabelTop( int pos, const wxString& label );
wxString GetLabelTop( int pos ) const;
- int GetMenuCount() const { return m_menus.Number(); }
- wxMenu *GetMenu(int n) const { return (wxMenu *)m_menus.Nth(n)->Data(); }
+ virtual void SetHelpString( int id, const wxString& helpString );
+ virtual wxString GetHelpString( int id ) const;
+
+ inline int GetMenuCount() const { return m_menus.Number(); }
+ inline wxMenu *GetMenu( int n ) const { return (wxMenu *)m_menus.Nth(n)->Data(); }
wxList m_menus;
GtkWidget *m_menubar;
void OnActivate( wxActivateEvent &WXUNUSED(event) ) { } // called from docview.cpp
void OnSize( wxSizeEvent &event );
void OnCloseWindow( wxCloseEvent& event );
+
+ void OnMenuHighlight( wxMenuEvent& event );
// implementation
int FindMenuItem( const wxString &menuString, const wxString &itemString ) const;
wxMenuItem* FindMenuItemById( int id ) const;
- inline wxMenuItem* FindItemForId( int id ) const
- { return FindMenuItemById( id ); }
+ inline wxMenuItem* FindItemForId( int id ) const { return FindMenuItemById( id ); }
void Check( int id, bool check );
bool Checked( int id ) const;
void Enable( int id, bool enable );
bool Enabled( int id ) const;
- inline bool IsEnabled(int Id) const { return Enabled(Id); }
- inline bool IsChecked(int Id) const { return Checked(Id); }
+ inline bool IsEnabled( int id ) const { return Enabled(id); }
+ inline bool IsChecked( int id ) const { return Checked(id); }
wxString GetLabel( int id ) const;
void SetLabel( int id, const wxString &label );
void SetLabelTop( int pos, const wxString& label );
wxString GetLabelTop( int pos ) const;
- int GetMenuCount() const { return m_menus.Number(); }
- wxMenu *GetMenu(int n) const { return (wxMenu *)m_menus.Nth(n)->Data(); }
+ virtual void SetHelpString( int id, const wxString& helpString );
+ virtual wxString GetHelpString( int id ) const;
+
+ inline int GetMenuCount() const { return m_menus.Number(); }
+ inline wxMenu *GetMenu( int n ) const { return (wxMenu *)m_menus.Nth(n)->Data(); }
wxList m_menus;
GtkWidget *m_menubar;
// Make a menubar
wxMenu *fileMenu = new wxMenu;
- fileMenu->Append(wxID_EXIT, "E&xit");
+ fileMenu->Append(wxID_EXIT, "E&xit", "Quit toolbar sample" );
wxMenu *helpMenu = new wxMenu;
- helpMenu->Append(wxID_HELP, "&About");
+ helpMenu->Append(wxID_HELP, "&About", "About toolbar sample");
wxMenuBar* menuBar = new wxMenuBar;
#endif
-#ifdef __WXGTK__
-#include "gtk/gtk.h"
-#include "gdk/gdk.h"
-#endif
-
//-----------------------------------------------------------------------------
// start and end of document/page
//-----------------------------------------------------------------------------
wxCHECK_MSG( source, FALSE, "invalid source dc" );
- wxClientDC *srcDC = (wxClientDC*)source;
+ /* blit into a bitmap */
wxBitmap bitmap( fwidth, fheight );
-
-#ifdef __WXGTK__
- /* just take any GC so we don't have to create our own. */
-
- GtkStyle *style = gtk_widget_get_default_style ();
- GdkGC *gc = style->white_gc;
-
- /* copy from either window or bitmap */
-
- gdk_window_copy_area( bitmap.GetPixmap(), gc, 0, 0,
- srcDC->GetWindow(),
- xsrc, ysrc, fwidth, fheight );
-#else
wxMemoryDC memDC;
memDC.SelectObject(bitmap);
- // TODO: Do we want to blit transparently?
- memDC.Blit(0, 0, fwidth, fheight, source, xsrc, ysrc, rop);
+ memDC.Blit(0, 0, fwidth, fheight, source, xsrc, ysrc, rop); /* TODO: Blit transparently? */
memDC.SelectObject(wxNullBitmap);
-#endif
/* draw bitmap. scaling and positioning is done there */
return 12;
}
-void wxPostScriptDC::GetTextExtent (const wxString& string, long *x, long *y,
- long *descent, long *externalLeading, wxFont *theFont,
- bool WXUNUSED(use16))
+void wxPostScriptDC::GetTextExtent( const wxString& string, long *x, long *y,
+ long *descent, long *externalLeading, wxFont *theFont,
+ bool WXUNUSED(use16) )
{
wxFont *fontToUse = theFont;
BEGIN_EVENT_TABLE(wxFrame, wxWindow)
EVT_SIZE(wxFrame::OnSize)
EVT_CLOSE(wxFrame::OnCloseWindow)
+ EVT_MENU_HIGHLIGHT_ALL(wxFrame::OnMenuHighlight)
END_EVENT_TABLE()
IMPLEMENT_DYNAMIC_CLASS(wxFrame,wxWindow)
return m_frameMenuBar;
}
+void wxFrame::OnMenuHighlight(wxMenuEvent& event)
+{
+ if (GetStatusBar())
+ {
+ if (event.GetMenuId() == -1)
+ {
+ SetStatusText("");
+ }
+ else
+ {
+ wxMenuBar *menuBar = GetMenuBar();
+ if (menuBar)
+ {
+ int menuId = event.GetMenuId();
+ wxString helpString;
+ helpString = menuBar->GetHelpString(menuId);
+ if (helpString != "")
+ SetStatusText(helpString);
+ }
+ }
+ }
+}
+
wxToolBar* wxFrame::CreateToolBar(long style, wxWindowID id, const wxString& name)
{
wxASSERT_MSG( (m_widget != NULL), "invalid frame" );
{
wxMenuItem* item = FindMenuItemById( id );
if (item) return item->IsEnabled();
+
return FALSE;
}
if (item) return item->GetText();
- return "";
+ return wxString("");
}
void wxMenuBar::SetLabel( int id, const wxString &label )
menu->SetTitle( label );
}
+void wxMenuBar::SetHelpString( int id, const wxString& helpString )
+{
+ wxMenuItem* item = FindMenuItemById( id );
+
+ if (item) item->SetHelp( helpString );
+}
+
+wxString wxMenuBar::GetHelpString( int id ) const
+{
+ wxMenuItem* item = FindMenuItemById( id );
+
+ if (item)
+ return item->GetHelp();
+ else
+ return wxString("");
+}
+
//-----------------------------------------------------------------------------
// "activate"
//-----------------------------------------------------------------------------
if (!menu->IsEnabled(id)) return;
- wxCommandEvent event( wxEVT_MENU_HIGHLIGHT, id );
+ wxMenuEvent event( wxEVT_MENU_HIGHLIGHT, id );
event.SetEventObject( menu );
- event.SetInt(id );
/* wxMSW doesn't call callback here either
BEGIN_EVENT_TABLE(wxFrame, wxWindow)
EVT_SIZE(wxFrame::OnSize)
EVT_CLOSE(wxFrame::OnCloseWindow)
+ EVT_MENU_HIGHLIGHT_ALL(wxFrame::OnMenuHighlight)
END_EVENT_TABLE()
IMPLEMENT_DYNAMIC_CLASS(wxFrame,wxWindow)
return m_frameMenuBar;
}
+void wxFrame::OnMenuHighlight(wxMenuEvent& event)
+{
+ if (GetStatusBar())
+ {
+ if (event.GetMenuId() == -1)
+ {
+ SetStatusText("");
+ }
+ else
+ {
+ wxMenuBar *menuBar = GetMenuBar();
+ if (menuBar)
+ {
+ int menuId = event.GetMenuId();
+ wxString helpString;
+ helpString = menuBar->GetHelpString(menuId);
+ if (helpString != "")
+ SetStatusText(helpString);
+ }
+ }
+ }
+}
+
wxToolBar* wxFrame::CreateToolBar(long style, wxWindowID id, const wxString& name)
{
wxASSERT_MSG( (m_widget != NULL), "invalid frame" );
{
wxMenuItem* item = FindMenuItemById( id );
if (item) return item->IsEnabled();
+
return FALSE;
}
if (item) return item->GetText();
- return "";
+ return wxString("");
}
void wxMenuBar::SetLabel( int id, const wxString &label )
menu->SetTitle( label );
}
+void wxMenuBar::SetHelpString( int id, const wxString& helpString )
+{
+ wxMenuItem* item = FindMenuItemById( id );
+
+ if (item) item->SetHelp( helpString );
+}
+
+wxString wxMenuBar::GetHelpString( int id ) const
+{
+ wxMenuItem* item = FindMenuItemById( id );
+
+ if (item)
+ return item->GetHelp();
+ else
+ return wxString("");
+}
+
//-----------------------------------------------------------------------------
// "activate"
//-----------------------------------------------------------------------------
if (!menu->IsEnabled(id)) return;
- wxCommandEvent event( wxEVT_MENU_HIGHLIGHT, id );
+ wxMenuEvent event( wxEVT_MENU_HIGHLIGHT, id );
event.SetEventObject( menu );
- event.SetInt(id );
/* wxMSW doesn't call callback here either