fix for radio items creation

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@17025 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2002-09-06 18:23:09 +00:00
parent 31988931ca
commit 8f262dc567
2 changed files with 84 additions and 82 deletions

View File

@@ -1071,14 +1071,16 @@ bool wxMenu::GtkAppend(wxMenuItem *mitem)
// text has "_" instead of "&" after mitem->SetText() so don't use it // text has "_" instead of "&" after mitem->SetText() so don't use it
wxString text( mitem->GetText() ); wxString text( mitem->GetText() );
// buffer containing the menu text in multibyte form // buffers containing the menu item path and type in multibyte form
char buf[200]; char bufPath[256],
strcpy( buf, "/" ); bufType[256];
strncat( buf, wxGTK_CONV(text), WXSIZEOF(buf) - 2 );
buf[WXSIZEOF(buf) - 1] = '\0'; strcpy( bufPath, "/" );
strncat( bufPath, wxGTK_CONV(text), WXSIZEOF(bufPath) - 2 );
bufPath[WXSIZEOF(bufPath) - 1] = '\0';
GtkItemFactoryEntry entry; GtkItemFactoryEntry entry;
entry.path = buf; entry.path = bufPath;
entry.callback = (GtkItemFactoryCallback) gtk_menu_clicked_callback; entry.callback = (GtkItemFactoryCallback) gtk_menu_clicked_callback;
entry.callback_action = 0; entry.callback_action = 0;
@@ -1095,7 +1097,7 @@ bool wxMenu::GtkAppend(wxMenuItem *mitem)
{ {
// start of a new radio group // start of a new radio group
item_type = "<RadioItem>"; item_type = "<RadioItem>";
m_pathLastRadio = buf + 1; m_pathLastRadio = bufPath + 1;
} }
else // continue the radio group else // continue the radio group
{ {
@@ -1103,10 +1105,9 @@ bool wxMenu::GtkAppend(wxMenuItem *mitem)
pathRadio.Replace(wxT("_"), wxT("")); pathRadio.Replace(wxT("_"), wxT(""));
pathRadio.Prepend(wxT("<main>/")); pathRadio.Prepend(wxT("<main>/"));
char buf2[200]; strncpy(bufType, wxGTK_CONV(pathRadio), WXSIZEOF(bufType));
strncpy(buf2, wxGTK_CONV(pathRadio), WXSIZEOF(buf2)); bufType[WXSIZEOF(bufType) - 1] = '\0';
buf2[WXSIZEOF(buf2) - 1] = '\0'; item_type = bufType;
item_type = buf2;
} }
// continue the existing radio group, if any // continue the existing radio group, if any

View File

@@ -1071,14 +1071,16 @@ bool wxMenu::GtkAppend(wxMenuItem *mitem)
// text has "_" instead of "&" after mitem->SetText() so don't use it // text has "_" instead of "&" after mitem->SetText() so don't use it
wxString text( mitem->GetText() ); wxString text( mitem->GetText() );
// buffer containing the menu text in multibyte form // buffers containing the menu item path and type in multibyte form
char buf[200]; char bufPath[256],
strcpy( buf, "/" ); bufType[256];
strncat( buf, wxGTK_CONV(text), WXSIZEOF(buf) - 2 );
buf[WXSIZEOF(buf) - 1] = '\0'; strcpy( bufPath, "/" );
strncat( bufPath, wxGTK_CONV(text), WXSIZEOF(bufPath) - 2 );
bufPath[WXSIZEOF(bufPath) - 1] = '\0';
GtkItemFactoryEntry entry; GtkItemFactoryEntry entry;
entry.path = buf; entry.path = bufPath;
entry.callback = (GtkItemFactoryCallback) gtk_menu_clicked_callback; entry.callback = (GtkItemFactoryCallback) gtk_menu_clicked_callback;
entry.callback_action = 0; entry.callback_action = 0;
@@ -1095,7 +1097,7 @@ bool wxMenu::GtkAppend(wxMenuItem *mitem)
{ {
// start of a new radio group // start of a new radio group
item_type = "<RadioItem>"; item_type = "<RadioItem>";
m_pathLastRadio = buf + 1; m_pathLastRadio = bufPath + 1;
} }
else // continue the radio group else // continue the radio group
{ {
@@ -1103,10 +1105,9 @@ bool wxMenu::GtkAppend(wxMenuItem *mitem)
pathRadio.Replace(wxT("_"), wxT("")); pathRadio.Replace(wxT("_"), wxT(""));
pathRadio.Prepend(wxT("<main>/")); pathRadio.Prepend(wxT("<main>/"));
char buf2[200]; strncpy(bufType, wxGTK_CONV(pathRadio), WXSIZEOF(bufType));
strncpy(buf2, wxGTK_CONV(pathRadio), WXSIZEOF(buf2)); bufType[WXSIZEOF(bufType) - 1] = '\0';
buf2[WXSIZEOF(buf2) - 1] = '\0'; item_type = bufType;
item_type = buf2;
} }
// continue the existing radio group, if any // continue the existing radio group, if any