projects
/
wxWidgets.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
constructing a sentence dynamically is not i18n-friendly, fixed to use two separate...
[wxWidgets.git]
/
src
/
gtk1
/
menu.cpp
diff --git
a/src/gtk1/menu.cpp
b/src/gtk1/menu.cpp
index 9db5c31b275ec409e604f795896bf240d331b60b..fa3f149dd054385613bb75c1d021055647c90e97 100644
(file)
--- a/
src/gtk1/menu.cpp
+++ b/
src/gtk1/menu.cpp
@@
-1,5
+1,5
@@
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
-// Name: menu.cpp
+// Name:
src/gtk1/
menu.cpp
// Purpose:
// Author: Robert Roebling
// Id: $Id$
// Purpose:
// Author: Robert Roebling
// Id: $Id$
@@
-11,10
+11,14
@@
#include "wx/wxprec.h"
#include "wx/menu.h"
#include "wx/wxprec.h"
#include "wx/menu.h"
-#include "wx/log.h"
-#include "wx/intl.h"
-#include "wx/app.h"
-#include "wx/bitmap.h"
+#include "wx/stockitem.h"
+
+#ifndef WX_PRECOMP
+ #include "wx/intl.h"
+ #include "wx/log.h"
+ #include "wx/app.h"
+ #include "wx/bitmap.h"
+#endif
#if wxUSE_ACCEL
#include "wx/accel.h"
#if wxUSE_ACCEL
#include "wx/accel.h"
@@
-140,7
+144,7
@@
IMPLEMENT_DYNAMIC_CLASS(wxMenuBar,wxWindow)
void wxMenuBar::Init(size_t n, wxMenu *menus[], const wxString titles[], long style)
{
// the parent window is known after wxFrame::SetMenu()
void wxMenuBar::Init(size_t n, wxMenu *menus[], const wxString titles[], long style)
{
// the parent window is known after wxFrame::SetMenu()
- m_needParent =
FALSE
;
+ m_needParent =
false
;
m_style = style;
m_invokingWindow = (wxWindow*) NULL;
m_style = style;
m_invokingWindow = (wxWindow*) NULL;
@@
-289,7
+293,7
@@
void wxMenuBar::UnsetInvokingWindow( wxWindow *win )
bool wxMenuBar::Append( wxMenu *menu, const wxString &title )
{
if ( !wxMenuBarBase::Append( menu, title ) )
bool wxMenuBar::Append( wxMenu *menu, const wxString &title )
{
if ( !wxMenuBarBase::Append( menu, title ) )
- return
FALSE
;
+ return
false
;
return GtkAppend(menu, title);
}
return GtkAppend(menu, title);
}
@@
-349,20
+353,20
@@
bool wxMenuBar::GtkAppend(wxMenu *menu, const wxString& title, int pos)
frame->UpdateMenuBarSize();
}
frame->UpdateMenuBarSize();
}
- return
TRUE
;
+ return
true
;
}
bool wxMenuBar::Insert(size_t pos, wxMenu *menu, const wxString& title)
{
if ( !wxMenuBarBase::Insert(pos, menu, title) )
}
bool wxMenuBar::Insert(size_t pos, wxMenu *menu, const wxString& title)
{
if ( !wxMenuBarBase::Insert(pos, menu, title) )
- return
FALSE
;
+ return
false
;
// TODO
if ( !GtkAppend(menu, title, (int)pos) )
// TODO
if ( !GtkAppend(menu, title, (int)pos) )
- return
FALSE
;
+ return
false
;
- return
TRUE
;
+ return
true
;
}
wxMenu *wxMenuBar::Replace(size_t pos, wxMenu *menu, const wxString& title)
}
wxMenu *wxMenuBar::Replace(size_t pos, wxMenu *menu, const wxString& title)
@@
-762,12
+766,20
@@
wxString wxMenuItemBase::GetLabelFromText(const wxString& text)
return label;
}
return label;
}
-void wxMenuItem::SetText( const wxString& str )
+void wxMenuItem::SetText( const wxString& str
ing
)
{
{
+ wxString str = string;
+ if ( str.empty() && !IsSeparator() )
+ {
+ wxASSERT_MSG(wxIsStockID(GetId()), wxT("A non-stock menu item with an empty label?"));
+ str = wxGetStockLabel(GetId(), wxSTOCK_WITH_ACCELERATOR |
+ wxSTOCK_WITH_MNEMONIC);
+ }
+
// Some optimization to avoid flicker
wxString oldLabel = m_text;
oldLabel = wxStripMenuCodes(oldLabel);
// Some optimization to avoid flicker
wxString oldLabel = m_text;
oldLabel = wxStripMenuCodes(oldLabel);
- oldLabel.Replace(wxT("_"), wx
T("")
);
+ oldLabel.Replace(wxT("_"), wx
EmptyString
);
wxString label1 = wxStripMenuCodes(str);
wxString oldhotkey = GetHotKey(); // Store the old hotkey in Ctrl-foo format
wxCharBuffer oldbuf = wxGTK_CONV( GetGtkHotKey(*this) ); // and as <control>foo
wxString label1 = wxStripMenuCodes(str);
wxString oldhotkey = GetHotKey(); // Store the old hotkey in Ctrl-foo format
wxCharBuffer oldbuf = wxGTK_CONV( GetGtkHotKey(*this) ); // and as <control>foo
@@
-847,15
+859,13
@@
void wxMenuItem::DoSetText( const wxString& str )
++pc;
}
++pc;
}
- m_hotKey = wx
T("")
;
+ m_hotKey = wx
EmptyString
;
if(*pc == wxT('\t'))
{
pc++;
m_hotKey = pc;
}
if(*pc == wxT('\t'))
{
pc++;
m_hotKey = pc;
}
-
- // wxPrintf( wxT("DoSetText(): str %s m_text %s hotkey %s\n"), str.c_str(), m_text.c_str(), m_hotKey.c_str() );
}
#if wxUSE_ACCEL
}
#if wxUSE_ACCEL
@@
-868,11
+878,12
@@
wxAcceleratorEntry *wxMenuItem::GetAccel() const
return (wxAcceleratorEntry *)NULL;
}
return (wxAcceleratorEntry *)NULL;
}
- // as wxGetAccelFromString() looks for TAB, insert a dummy one here
+ // accelerator parsing code looks for them after a TAB, so insert a dummy
+ // one here
wxString label;
label << wxT('\t') << GetHotKey();
wxString label;
label << wxT('\t') << GetHotKey();
- return wx
GetAccelFromString
(label);
+ return wx
AcceleratorEntry::Create
(label);
}
#endif // wxUSE_ACCEL
}
#endif // wxUSE_ACCEL
@@
-908,9
+919,9
@@
void wxMenuItem::Enable( bool enable )
bool wxMenuItem::IsChecked() const
{
bool wxMenuItem::IsChecked() const
{
- wxCHECK_MSG( m_menuItem,
FALSE
, wxT("invalid menu item") );
+ wxCHECK_MSG( m_menuItem,
false
, wxT("invalid menu item") );
- wxCHECK_MSG( IsCheckable(),
FALSE
,
+ wxCHECK_MSG( IsCheckable(),
false
,
wxT("can't get state of uncheckable item!") );
return ((GtkCheckMenuItem*)m_menuItem)->active != 0;
wxT("can't get state of uncheckable item!") );
return ((GtkCheckMenuItem*)m_menuItem)->active != 0;
@@
-972,7
+983,7
@@
bool wxMenu::GtkAppend(wxMenuItem *mitem, int pos)
GtkWidget *menuItem;
wxString text;
GtkWidget *menuItem;
wxString text;
- GtkLabel* label;
+ GtkLabel* label
= NULL
;
if ( mitem->IsSeparator() )
{
if ( mitem->IsSeparator() )
{
@@
-984,7
+995,7
@@
bool wxMenu::GtkAppend(wxMenuItem *mitem, int pos)
text = mitem->GetText();
const wxBitmap *bitmap = &mitem->GetBitmap();
text = mitem->GetText();
const wxBitmap *bitmap = &mitem->GetBitmap();
- // TODO
+
// TODO
wxUnusedVar(bitmap);
menuItem = gtk_menu_item_new_with_label( wxGTK_CONV( text ) );
label = GTK_LABEL( GTK_BIN(menuItem)->child );
wxUnusedVar(bitmap);
menuItem = gtk_menu_item_new_with_label( wxGTK_CONV( text ) );
label = GTK_LABEL( GTK_BIN(menuItem)->child );
@@
-1117,7
+1128,7
@@
bool wxMenu::GtkAppend(wxMenuItem *mitem, int pos)
// gtk_widget_lock_accelerators(mitem->GetMenuItem());
}
// gtk_widget_lock_accelerators(mitem->GetMenuItem());
}
- return
TRUE
;
+ return
true
;
}
wxMenuItem* wxMenu::DoAppend(wxMenuItem *mitem)
}
wxMenuItem* wxMenu::DoAppend(wxMenuItem *mitem)
@@
-1233,12
+1244,10
@@
static wxString GetGtkHotKey( const wxMenuItem& item )
hotkey << wxT("Down" );
break;
case WXK_PAGEUP:
hotkey << wxT("Down" );
break;
case WXK_PAGEUP:
- case WXK_PRIOR:
- hotkey << wxT("Prior" );
+ hotkey << wxT("PgUp" );
break;
case WXK_PAGEDOWN:
break;
case WXK_PAGEDOWN:
- case WXK_NEXT:
- hotkey << wxT("Next" );
+ hotkey << wxT("PgDn" );
break;
case WXK_LEFT:
hotkey << wxT("Left" );
break;
case WXK_LEFT:
hotkey << wxT("Left" );
@@
-1355,11
+1364,11
@@
static wxString GetGtkHotKey( const wxMenuItem& item )
case WXK_NUMPAD_DOWN:
hotkey << wxT("KP_Down" );
break;
case WXK_NUMPAD_DOWN:
hotkey << wxT("KP_Down" );
break;
- case WXK_NUMPAD_P
RIOR: case WXK_NUMPAD_P
AGEUP:
- hotkey << wxT("KP_P
rior
" );
+ case WXK_NUMPAD_PAGEUP:
+ hotkey << wxT("KP_P
gUp
" );
break;
break;
- case WXK_NUMPAD_
NEXT: case WXK_NUMPAD_
PAGEDOWN:
- hotkey << wxT("KP_
Next
" );
+ case WXK_NUMPAD_PAGEDOWN:
+ hotkey << wxT("KP_
PgDn
" );
break;
case WXK_NUMPAD_END:
hotkey << wxT("KP_End" );
break;
case WXK_NUMPAD_END:
hotkey << wxT("KP_End" );
@@
-1414,7
+1423,7
@@
static wxString GetGtkHotKey( const wxMenuItem& item )
hotkey += wxString::Format(wxT("Special%d"), code - WXK_SPECIAL1 + 1);
break;
*/
hotkey += wxString::Format(wxT("Special%d"), code - WXK_SPECIAL1 + 1);
break;
*/
- // if there are any other keys wx
GetAccelFromString
() may
+ // if there are any other keys wx
AcceleratorEntry::Create
() may
// return, we should process them here
default:
// return, we should process them here
default:
@@
-1445,13
+1454,13
@@
static wxString GetGtkHotKey( const wxMenuItem& item )
#if wxUSE_MENUS_NATIVE
#if wxUSE_MENUS_NATIVE
-extern "C"
+extern "C"
WXDLLIMPEXP_CORE
void gtk_pop_hide_callback( GtkWidget *WXUNUSED(widget), bool* is_waiting )
{
void gtk_pop_hide_callback( GtkWidget *WXUNUSED(widget), bool* is_waiting )
{
- *is_waiting =
FALSE
;
+ *is_waiting =
false
;
}
}
-void SetInvokingWindow( wxMenu *menu, wxWindow* win )
+
WXDLLIMPEXP_CORE
void SetInvokingWindow( wxMenu *menu, wxWindow* win )
{
menu->SetInvokingWindow( win );
{
menu->SetInvokingWindow( win );
@@
-1468,7
+1477,7
@@
void SetInvokingWindow( wxMenu *menu, wxWindow* win )
}
}
}
}
-extern "C"
+extern "C"
WXDLLIMPEXP_CORE
void wxPopupMenuPositionCallback( GtkMenu *menu,
gint *x, gint *y,
gpointer user_data )
void wxPopupMenuPositionCallback( GtkMenu *menu,
gint *x, gint *y,
gpointer user_data )
@@
-1551,4
+1560,3
@@
bool wxWindowGTK::DoPopupMenu( wxMenu *menu, int x, int y )
}
#endif // wxUSE_MENUS_NATIVE
}
#endif // wxUSE_MENUS_NATIVE
-