mirror of
https://github.com/leozide/leocad
synced 2025-01-18 22:26:44 +01:00
Updated Linux dialogs.
This commit is contained in:
parent
93153a5892
commit
9600d069ff
4 changed files with 422 additions and 644 deletions
|
@ -39,132 +39,7 @@ void BaseWnd::EndWait ()
|
||||||
|
|
||||||
int BaseWnd::MessageBox (const char* text, const char* caption, int flags)
|
int BaseWnd::MessageBox (const char* text, const char* caption, int flags)
|
||||||
{
|
{
|
||||||
GtkWidget *window, *w, *vbox, *hbox;
|
return msgbox_execute (text, caption, flags);
|
||||||
GtkAccelGroup *group;
|
|
||||||
int mode = (flags & LC_MB_TYPEMASK), ret, loop = 1;
|
|
||||||
guint tmp_key;
|
|
||||||
|
|
||||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
|
||||||
gtk_signal_connect (GTK_OBJECT (window), "delete_event",
|
|
||||||
GTK_SIGNAL_FUNC (dialog_delete_callback), NULL);
|
|
||||||
// gtk_signal_connect (GTK_OBJECT (window), "destroy",
|
|
||||||
// GTK_SIGNAL_FUNC (gtk_widget_destroy), NULL);
|
|
||||||
gtk_window_set_title (GTK_WINDOW (window), caption);
|
|
||||||
gtk_container_border_width (GTK_CONTAINER (window), 10);
|
|
||||||
gtk_object_set_data (GTK_OBJECT (window), "loop", &loop);
|
|
||||||
gtk_object_set_data (GTK_OBJECT (window), "ret", &ret);
|
|
||||||
|
|
||||||
if (m_pXID != NULL)
|
|
||||||
gtk_window_set_transient_for (GTK_WINDOW (window), GTK_WINDOW (m_pXID));
|
|
||||||
// gtk_widget_realize (window);
|
|
||||||
|
|
||||||
group = gtk_accel_group_new ();
|
|
||||||
gtk_window_add_accel_group (GTK_WINDOW (window), group);
|
|
||||||
|
|
||||||
vbox = gtk_vbox_new (FALSE, 10);
|
|
||||||
gtk_container_add (GTK_CONTAINER (window), vbox);
|
|
||||||
gtk_widget_show (vbox);
|
|
||||||
|
|
||||||
w = gtk_label_new (text);
|
|
||||||
gtk_box_pack_start (GTK_BOX (vbox), w, FALSE, FALSE, 2);
|
|
||||||
gtk_label_set_justify (GTK_LABEL (w), GTK_JUSTIFY_LEFT);
|
|
||||||
gtk_widget_show (w);
|
|
||||||
|
|
||||||
w = gtk_hseparator_new ();
|
|
||||||
gtk_box_pack_start (GTK_BOX (vbox), w, FALSE, FALSE, 2);
|
|
||||||
gtk_widget_show (w);
|
|
||||||
|
|
||||||
hbox = gtk_hbox_new (FALSE, 10);
|
|
||||||
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 2);
|
|
||||||
gtk_widget_show (hbox);
|
|
||||||
|
|
||||||
if (mode == LC_MB_OK)
|
|
||||||
{
|
|
||||||
w = gtk_button_new_with_label ("Ok");
|
|
||||||
gtk_box_pack_start (GTK_BOX (hbox), w, TRUE, TRUE, 0);
|
|
||||||
gtk_signal_connect (GTK_OBJECT (w), "clicked",
|
|
||||||
GTK_SIGNAL_FUNC (dialog_button_callback), GINT_TO_POINTER (LC_OK));
|
|
||||||
GTK_WIDGET_SET_FLAGS (w, GTK_CAN_DEFAULT);
|
|
||||||
gtk_widget_grab_default (w);
|
|
||||||
gtk_widget_show (w);
|
|
||||||
ret = LC_OK;
|
|
||||||
}
|
|
||||||
else if (mode == LC_MB_OKCANCEL)
|
|
||||||
{
|
|
||||||
w = gtk_button_new_with_label ("Ok");
|
|
||||||
gtk_box_pack_start (GTK_BOX (hbox), w, TRUE, TRUE, 0);
|
|
||||||
gtk_signal_connect (GTK_OBJECT (w), "clicked",
|
|
||||||
GTK_SIGNAL_FUNC (dialog_button_callback), GINT_TO_POINTER (LC_OK));
|
|
||||||
GTK_WIDGET_SET_FLAGS (w, GTK_CAN_DEFAULT);
|
|
||||||
gtk_widget_grab_default (w);
|
|
||||||
gtk_widget_show (w);
|
|
||||||
|
|
||||||
w = gtk_button_new_with_label ("Cancel");
|
|
||||||
gtk_box_pack_start (GTK_BOX (hbox), w, TRUE, TRUE, 0);
|
|
||||||
gtk_signal_connect (GTK_OBJECT (w), "clicked",
|
|
||||||
GTK_SIGNAL_FUNC (dialog_button_callback), GINT_TO_POINTER (LC_CANCEL));
|
|
||||||
gtk_widget_show (w);
|
|
||||||
ret = LC_CANCEL;
|
|
||||||
}
|
|
||||||
else if (mode == LC_MB_YESNOCANCEL)
|
|
||||||
{
|
|
||||||
w = gtk_button_new_with_label ("");
|
|
||||||
tmp_key = gtk_label_parse_uline (GTK_LABEL (GTK_BIN (w)->child), "_Yes");
|
|
||||||
gtk_box_pack_start (GTK_BOX (hbox), w, TRUE, TRUE, 0);
|
|
||||||
gtk_signal_connect (GTK_OBJECT (w), "clicked",
|
|
||||||
GTK_SIGNAL_FUNC (dialog_button_callback), GINT_TO_POINTER (LC_YES));
|
|
||||||
gtk_widget_add_accelerator (w, "clicked", group, tmp_key, (GdkModifierType)0, (GtkAccelFlags)0);
|
|
||||||
GTK_WIDGET_SET_FLAGS (w, GTK_CAN_DEFAULT);
|
|
||||||
gtk_widget_grab_default (w);
|
|
||||||
gtk_widget_show (w);
|
|
||||||
gtk_window_set_focus (GTK_WINDOW (window), w);
|
|
||||||
|
|
||||||
w = gtk_button_new_with_label ("");
|
|
||||||
tmp_key = gtk_label_parse_uline (GTK_LABEL (GTK_BIN (w)->child), "_No");
|
|
||||||
gtk_box_pack_start (GTK_BOX (hbox), w, TRUE, TRUE, 0);
|
|
||||||
gtk_signal_connect (GTK_OBJECT (w), "clicked",
|
|
||||||
GTK_SIGNAL_FUNC (dialog_button_callback), GINT_TO_POINTER (LC_NO));
|
|
||||||
gtk_widget_add_accelerator (w, "clicked", group, tmp_key, (GdkModifierType)0, (GtkAccelFlags)0);
|
|
||||||
gtk_widget_show (w);
|
|
||||||
|
|
||||||
w = gtk_button_new_with_label ("");
|
|
||||||
tmp_key = gtk_label_parse_uline (GTK_LABEL (GTK_BIN (w)->child), "_Cancel");
|
|
||||||
gtk_box_pack_start (GTK_BOX (hbox), w, TRUE, TRUE, 0);
|
|
||||||
gtk_signal_connect (GTK_OBJECT (w), "clicked",
|
|
||||||
GTK_SIGNAL_FUNC (dialog_button_callback), GINT_TO_POINTER (LC_CANCEL));
|
|
||||||
gtk_widget_add_accelerator (w, "clicked", group, tmp_key, (GdkModifierType)0, (GtkAccelFlags)0);
|
|
||||||
gtk_widget_add_accelerator (w, "clicked", group, GDK_Escape, (GdkModifierType)0, (GtkAccelFlags)0);
|
|
||||||
gtk_widget_show (w);
|
|
||||||
ret = LC_CANCEL;
|
|
||||||
}
|
|
||||||
else /* if (mode == LC_MB_YESNO) */
|
|
||||||
{
|
|
||||||
w = gtk_button_new_with_label ("Yes");
|
|
||||||
gtk_box_pack_start (GTK_BOX (hbox), w, TRUE, TRUE, 0);
|
|
||||||
gtk_signal_connect (GTK_OBJECT (w), "clicked",
|
|
||||||
GTK_SIGNAL_FUNC (dialog_button_callback), GINT_TO_POINTER (LC_YES));
|
|
||||||
GTK_WIDGET_SET_FLAGS (w, GTK_CAN_DEFAULT);
|
|
||||||
gtk_widget_grab_default (w);
|
|
||||||
gtk_widget_show (w);
|
|
||||||
|
|
||||||
w = gtk_button_new_with_label ("No");
|
|
||||||
gtk_box_pack_start (GTK_BOX (hbox), w, TRUE, TRUE, 0);
|
|
||||||
gtk_signal_connect (GTK_OBJECT (w), "clicked",
|
|
||||||
GTK_SIGNAL_FUNC (dialog_button_callback), GINT_TO_POINTER (LC_NO));
|
|
||||||
gtk_widget_show (w);
|
|
||||||
ret = LC_NO;
|
|
||||||
}
|
|
||||||
|
|
||||||
gtk_widget_show (window);
|
|
||||||
gtk_grab_add (window);
|
|
||||||
|
|
||||||
while (loop)
|
|
||||||
gtk_main_iteration ();
|
|
||||||
|
|
||||||
gtk_grab_remove (window);
|
|
||||||
gtk_widget_destroy (window);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseWnd::ShowMenuItem (int id, bool show)
|
void BaseWnd::ShowMenuItem (int id, bool show)
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,11 +1,9 @@
|
||||||
#ifndef _DIALOGS_H_
|
#ifndef _DIALOGS_H_
|
||||||
#define _DIALOGS_H_
|
#define _DIALOGS_H_
|
||||||
|
|
||||||
// Dialog support functions
|
// TODO: obsolete, delete
|
||||||
void dialog_button_callback(GtkWidget *widget, gpointer data);
|
void dialog_button_callback(GtkWidget *widget, gpointer data);
|
||||||
gint dialog_delete_callback(GtkWidget *widget, GdkEvent* event, gpointer data);
|
gint dialog_delete_callback(GtkWidget *widget, GdkEvent* event, gpointer data);
|
||||||
|
|
||||||
// obsolete
|
|
||||||
int dlg_domodal(GtkWidget* dlg, int def);
|
int dlg_domodal(GtkWidget* dlg, int def);
|
||||||
void dlg_end(int ret);
|
void dlg_end(int ret);
|
||||||
gint dlg_delete_callback(GtkWidget *widget, GdkEvent* event, gpointer data);
|
gint dlg_delete_callback(GtkWidget *widget, GdkEvent* event, gpointer data);
|
||||||
|
@ -18,12 +16,12 @@ int openprojectdlg_execute(char* filename);
|
||||||
int saveprojectdlg_execute(char* filename);
|
int saveprojectdlg_execute(char* filename);
|
||||||
int savepicturedlg_execute(void* param);
|
int savepicturedlg_execute(void* param);
|
||||||
int msgbox_execute(const char* text, const char *caption, int flags);
|
int msgbox_execute(const char* text, const char *caption, int flags);
|
||||||
int filedlg_execute(const char* caption, char* filename);
|
|
||||||
int arraydlg_execute(void* param);
|
int arraydlg_execute(void* param);
|
||||||
int aboutdlg_execute(void* param);
|
int aboutdlg_execute(void* param);
|
||||||
int htmldlg_execute(void* param);
|
int htmldlg_execute(void* param);
|
||||||
int imageoptsdlg_execute(GtkWidget* parent, void* param, bool from_htmldlg);
|
int imageoptsdlg_execute(GtkWidget* parent, void* param, bool from_htmldlg);
|
||||||
int povraydlg_execute(void* param);
|
int povraydlg_execute(void* param);
|
||||||
|
int wavefrontdlg_execute(void* param);
|
||||||
int preferencesdlg_execute(void* param);
|
int preferencesdlg_execute(void* param);
|
||||||
int propertiesdlg_execute(void* param);
|
int propertiesdlg_execute(void* param);
|
||||||
int groupeditdlg_execute(void* param);
|
int groupeditdlg_execute(void* param);
|
||||||
|
|
|
@ -665,7 +665,7 @@ bool SystemDoDialog(int mode, void* param)
|
||||||
return povraydlg_execute(param) == LC_OK;
|
return povraydlg_execute(param) == LC_OK;
|
||||||
|
|
||||||
case LC_DLG_WAVEFRONT:
|
case LC_DLG_WAVEFRONT:
|
||||||
return filedlg_execute("Save File", (char*)param) == LC_OK;
|
return wavefrontdlg_execute(param) == LC_OK;
|
||||||
|
|
||||||
case LC_DLG_PREFERENCES:
|
case LC_DLG_PREFERENCES:
|
||||||
return preferencesdlg_execute(param) == LC_OK;
|
return preferencesdlg_execute(param) == LC_OK;
|
||||||
|
|
Loading…
Reference in a new issue