+
+ wxString pathRadio;
+ const char *item_type;
+ switch ( mitem->GetKind() )
+ {
+ case wxITEM_CHECK:
+ item_type = "<CheckItem>";
+ break;
+
+ case wxITEM_RADIO:
+ if ( m_pathLastRadio.empty() )
+ {
+ // start of a new radio group
+ item_type = "<RadioItem>";
+ wxString tmp( wxGTK_CONV_BACK( bufPath ) );
+ tmp.Remove(0,1);
+ m_pathLastRadio = tmp;
+ }
+ else // continue the radio group
+ {
+ pathRadio = m_pathLastRadio;
+ pathRadio.Replace(wxT("_"), wxT(""));
+ pathRadio.Prepend(wxT("<main>/"));
+
+ strncpy(bufType, wxGTK_CONV(pathRadio), WXSIZEOF(bufType));
+ bufType[WXSIZEOF(bufType) - 1] = '\0';
+ item_type = bufType;
+ }
+
+ // continue the existing radio group, if any
+ endOfRadioGroup = FALSE;
+ break;
+
+ default:
+ wxFAIL_MSG( _T("unexpected menu item kind") );
+ // fall through
+
+ case wxITEM_NORMAL:
+ item_type = "<Item>";
+#if defined(__WXGTK20__) && wxUSE_IMAGE
+ if (mitem->GetBitmap().Ok())
+ {
+ item_type = "<ImageItem>";
+ // GTK2's image factory know about image items, but they need to
+ // get a GdkPixbuf structure, which we need to create on the fly.
+ // This Pixbuf structure needs to be static so we create it and
+ // just make it a memory leak...
+ wxImage image( mitem->GetBitmap().ConvertToImage() );
+ size_t size = 4 + // magic
+ 20 + // header
+ image.GetHeight() * image.GetWidth() * 4; // RGBA
+
+ unsigned char *dest = new unsigned char[size];
+ entry.extra_data = dest;
+
+ unsigned char *source = image.GetData();
+ bool has_mask = image.HasMask();
+ unsigned char mask_r = image.GetMaskRed();
+ unsigned char mask_b = image.GetMaskBlue();
+ unsigned char mask_g = image.GetMaskGreen();
+ wxUint32 tmp;
+
+ // Magic
+ *dest = 'G'; dest++; *dest = 'd'; dest++; *dest = 'k'; dest++; *dest = 'P'; dest++;
+ // Data size
+ tmp = size;
+ *dest = tmp >> 24; dest++; *dest = tmp >> 16; dest++; *dest = tmp >> 8; dest++; *dest = tmp; dest++;
+ // Pixdata type
+ *dest = 1; dest++; *dest = 1; dest++; *dest = 0; dest++; *dest = 2; dest++;
+ // Rowstride
+ tmp = image.GetWidth()*4;
+ *dest = tmp >> 24; dest++; *dest = tmp >> 16; dest++; *dest = tmp >> 8; dest++; *dest = tmp; dest++;
+ // Width
+ tmp = image.GetWidth();
+ *dest = tmp >> 24; dest++; *dest = tmp >> 16; dest++; *dest = tmp >> 8; dest++; *dest = tmp; dest++;
+ // Height
+ tmp = image.GetHeight();
+ *dest = tmp >> 24; dest++; *dest = tmp >> 16; dest++; *dest = tmp >> 8; dest++; *dest = tmp; dest++;
+
+ for (int i = 0; i < image.GetWidth()*image.GetHeight(); i++)
+ {
+ unsigned char r = *source; source++;
+ unsigned char g = *source; source++;
+ unsigned char b = *source; source++;
+ *dest = r; dest++;
+ *dest = g; dest++;
+ *dest = b; dest++;
+ if (has_mask && (r == mask_r) && (g == mask_g) && (b == mask_b))
+ *dest = 0;
+ else
+ *dest = 255;
+ dest++;
+ }
+ break;
+ }
+#endif // GTK 2.0+
+ break;
+ }
+
+ entry.item_type = (char *)item_type; // cast needed for GTK+