Gtk--: optionmenu troubles
- From: Robert_Gasch peoplesoft com
- To: gtk-list redhat com
- Subject: Gtk--: optionmenu troubles
- Date: Thu, 13 Aug 1998 10:36:12 +0200
Hi Guys,
I'm trying to create an optionmenu and while the general idea seems to work
OK, I have a problem
with the optionmenu buttons not belonging to the right parent window when
the dialog is opened. If
you then click on the optionmenu a few times, the child widgets are
're-patriated' by the correct
window.
If anybody can tell me what I'm doing wrong, I'd very much appreciate it
...
Thanks
--> Robert
----------------------------------------------------- cut here
------------------------------------------------------------
/* test to see if we can build an optionmenu - RNG */
#include <string.h>
#include <gtk--.h>
#include <gtk/gtk.h>
class testoptmenu : public Gtk_Dialog
{
public:
testoptmenu (char *title=NULL, char
*message=NULL);
~testoptmenu ();
virtual void buildDialogWindow ();
protected:
virtual void fillVBox ();
virtual void fillActionArea ();
virtual void buttonCallbackOK ();
virtual void buttonCallbackApply ();
virtual void buttonCallbackCancel ();
virtual gint delete_event_impl (GdkEventAny *e);
Gtk_Button d_buttonOK,
d_buttonApply,
d_buttonCancel;
Gtk_Label d_msgColormap;
Gtk_OptionMenu d_colormapOptMenu;
Gtk_Menu d_colormapMenu;
Gtk_RadioMenuItem *d_rmiGrayscale,
*d_rmiColorBands;
GSList *d_colormapMenuGroup;
char *d_title,
*d_message;
private:
Gtk_HBox *d_defaultHBox;
};
testoptmenu::testoptmenu(char *title, char *message)
: Gtk_Dialog (),
d_buttonOK ("OK"),
d_buttonApply ("Apply"),
d_buttonCancel ("Cancel"),
d_msgColormap ("Colormap")
{
printf ("+++ testoptmenu\n");
char *s;
if (title)
s = title;
else
s = "testoptmenu Window";
d_title = strdup (s);
d_message = message;
this->position (GTK_WIN_POS_MOUSE);
}
testoptmenu::~testoptmenu()
{
if (d_title) delete d_title;
printf ("--- testoptmenu\n");
}
void testoptmenu::buildDialogWindow ()
{
this->set_usize (300, 120);
this->set_title (d_title);
this->vbox()->border_width (2);
fillVBox ();
fillActionArea ();
this->show ();
}
void testoptmenu::fillVBox ()
{
d_defaultHBox = new Gtk_HBox (TRUE, 5);
d_msgColormap.set_justify (GTK_JUSTIFY_LEFT);
d_defaultHBox->pack_start (&d_msgColormap, TRUE, FALSE, 10);
d_msgColormap.show ();
d_rmiColorBands = new Gtk_RadioMenuItem (d_colormapMenuGroup,
"ColorBands");
d_colormapMenuGroup = d_rmiColorBands->group ();
d_colormapMenu.append (d_rmiColorBands);
d_rmiColorBands->show ();
d_rmiGrayscale = new Gtk_RadioMenuItem (d_colormapMenuGroup,
"Grayscale");
d_colormapMenuGroup = d_rmiGrayscale->group ();
d_colormapMenu.append (d_rmiGrayscale);
d_rmiGrayscale->show ();
d_colormapMenu.show ();
d_colormapOptMenu.set_menu (&d_colormapMenu);
d_defaultHBox->pack_end (&d_colormapOptMenu, TRUE, FALSE, 10);
d_colormapOptMenu.show ();
this->vbox()->pack_start (d_defaultHBox, TRUE, TRUE, 0);
d_defaultHBox->show ();
}
void testoptmenu::fillActionArea ()
{
// create new hbox and add buttons to it
connect_to_method (d_buttonOK.clicked, this, &buttonCallbackOK);
this->action_area()->pack_start (&d_buttonOK, TRUE, TRUE, 0);
d_buttonOK.show ();
connect_to_method (d_buttonApply.clicked, this, &buttonCallbackApply);
this->action_area()->pack_start (&d_buttonApply, TRUE, TRUE, 0);
d_buttonApply.show ();
connect_to_method (d_buttonCancel.clicked, this,
&buttonCallbackCancel);
this->action_area()->pack_start (&d_buttonCancel, TRUE, TRUE, 0);
d_buttonCancel.show ();
}
void testoptmenu::buttonCallbackOK ()
{
printf ("testoptmenu: Default Callback OK\n");
}
void testoptmenu::buttonCallbackApply ()
{
printf ("testoptmenu: Default Callback Apply\n");
}
void testoptmenu::buttonCallbackCancel ()
{
this->hide ();
exit (0);
}
gint testoptmenu::delete_event_impl(GdkEventAny *)
{
this->hide ();
return (0);
}
int main (int argc, char *argv[])
{
Gtk_Main gtkMain (&argc, &argv);
testoptmenu *testDialog;
testoptmenu *testDialog2;
testDialog = new testoptmenu ("Default Title", "Default Message");
testDialog->buildDialogWindow ();
testDialog->show ();
gtkMain.run ();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]