static int gtkFrameMapMethod(Ihandle* ih) { char *value, *title; GtkWidget *inner_parent; if (!ih->parent) return IUP_ERROR; title = iupAttribGet(ih, "TITLE"); ih->handle = gtk_frame_new(NULL); if (!ih->handle) return IUP_ERROR; if (title) iupAttribSetStr(ih, "_IUPFRAME_HAS_TITLE", "1"); else { value = iupAttribGetStr(ih, "SUNKEN"); if (iupStrBoolean(value)) gtk_frame_set_shadow_type((GtkFrame*)ih->handle, GTK_SHADOW_IN); else gtk_frame_set_shadow_type((GtkFrame*)ih->handle, GTK_SHADOW_ETCHED_IN); if (iupAttribGet(ih, "BGCOLOR")) iupAttribSetStr(ih, "_IUPFRAME_HAS_BGCOLOR", "1"); } /* the container that will receive the child element. */ inner_parent = iupgtkNativeContainerNew(); /* must set this so IupFrame will be always a full native containter */ iupgtkNativeContainerSetHasWindow(inner_parent, TRUE); gtk_container_add((GtkContainer*)ih->handle, inner_parent); gtk_widget_show(inner_parent); /* Add to the parent, all GTK controls must call this. */ iupgtkAddToParent(ih); gtk_widget_realize(ih->handle); return IUP_NOERROR; }
static int gtkFrameMapMethod(Ihandle* ih) { char *title; GtkWidget *inner_parent; if (!ih->parent) return IUP_ERROR; title = iupAttribGet(ih, "TITLE"); ih->handle = gtk_frame_new(NULL); if (!ih->handle) return IUP_ERROR; if (title) iupAttribSet(ih, "_IUPFRAME_HAS_TITLE", "1"); else { if (iupAttribGet(ih, "BGCOLOR")) iupAttribSet(ih, "_IUPFRAME_HAS_BGCOLOR", "1"); } /* the container that will receive the child element. */ /* use a window to be a full native containter */ inner_parent = iupgtkNativeContainerNew(1); gtk_container_add((GtkContainer*)ih->handle, inner_parent); gtk_widget_show(inner_parent); /* Add to the parent, all GTK controls must call this. */ iupgtkAddToParent(ih); gtk_widget_realize(ih->handle); #if GTK_CHECK_VERSION(3, 0, 0) if (!iupAttribGet(ih, "_IUPFRAME_HAS_BGCOLOR")) gtkFrameSetBgColorAttrib(ih, NULL); #endif return IUP_NOERROR; }
static int gtkCanvasMapMethod(Ihandle* ih) { GtkWidget* sb_win; #if !GTK_CHECK_VERSION(3, 0, 0) void* visual; #endif if (!ih->parent) return IUP_ERROR; ih->data->sb = iupBaseGetScrollbar(ih); #if !GTK_CHECK_VERSION(3, 0, 0) visual = (void*)IupGetAttribute(ih, "VISUAL"); /* defined by the OpenGL Canvas in X11 or NULL */ if (visual) iupgtkPushVisualAndColormap(visual, (void*)iupAttribGet(ih, "COLORMAP")); #endif ih->handle = iupgtkNativeContainerNew(); /* canvas is also a container */ #if !GTK_CHECK_VERSION(3, 0, 0) if (visual) gtk_widget_pop_colormap(); #endif if (!ih->handle) return IUP_ERROR; /* CD will NOT work properly without this, must use always the CD-GDK driver */ iupgtkNativeContainerSetHasWindow(ih->handle, TRUE); sb_win = iupgtkNativeContainerNew(); if (!sb_win) return IUP_ERROR; iupgtkNativeContainerAdd(sb_win, ih->handle); gtk_widget_show(sb_win); iupAttribSetStr(ih, "_IUP_EXTRAPARENT", (char*)sb_win); /* add to the parent, all GTK controls must call this. */ iupgtkAddToParent(ih); g_signal_connect(G_OBJECT(ih->handle), "focus-in-event", G_CALLBACK(iupgtkFocusInOutEvent), ih); g_signal_connect(G_OBJECT(ih->handle), "focus-out-event", G_CALLBACK(iupgtkFocusInOutEvent), ih); g_signal_connect(G_OBJECT(ih->handle), "key-press-event", G_CALLBACK(iupgtkKeyPressEvent), ih); g_signal_connect(G_OBJECT(ih->handle), "key-release-event", G_CALLBACK(iupgtkKeyReleaseEvent), ih); g_signal_connect(G_OBJECT(ih->handle), "enter-notify-event", G_CALLBACK(iupgtkEnterLeaveEvent), ih); g_signal_connect(G_OBJECT(ih->handle), "leave-notify-event", G_CALLBACK(iupgtkEnterLeaveEvent), ih); g_signal_connect(G_OBJECT(ih->handle), "show-help", G_CALLBACK(iupgtkShowHelp), ih); #if GTK_CHECK_VERSION(3, 0, 0) g_signal_connect(G_OBJECT(ih->handle), "draw", G_CALLBACK(gtkCanvasDraw), ih); #else g_signal_connect(G_OBJECT(ih->handle), "expose-event", G_CALLBACK(gtkCanvasExposeEvent), ih); #endif g_signal_connect(G_OBJECT(ih->handle), "button-press-event", G_CALLBACK(gtkCanvasButtonEvent), ih); g_signal_connect(G_OBJECT(ih->handle), "button-release-event",G_CALLBACK(gtkCanvasButtonEvent), ih); g_signal_connect(G_OBJECT(ih->handle), "motion-notify-event",G_CALLBACK(iupgtkMotionNotifyEvent), ih); g_signal_connect(G_OBJECT(ih->handle), "scroll-event",G_CALLBACK(gtkCanvasScrollEvent), ih); g_signal_connect(G_OBJECT(ih->handle), "size-allocate", G_CALLBACK(gtkCanvasSizeAllocate), ih); /* To receive mouse events on a drawing area, you will need to enable them. */ gtk_widget_add_events(ih->handle, GDK_EXPOSURE_MASK| GDK_POINTER_MOTION_MASK|GDK_POINTER_MOTION_HINT_MASK| GDK_BUTTON_PRESS_MASK|GDK_BUTTON_RELEASE_MASK|GDK_BUTTON_MOTION_MASK| GDK_KEY_PRESS_MASK|GDK_KEY_RELEASE_MASK| GDK_ENTER_NOTIFY_MASK|GDK_LEAVE_NOTIFY_MASK| GDK_FOCUS_CHANGE_MASK|GDK_STRUCTURE_MASK); /* To receive keyboard events, you will need to set the GTK_CAN_FOCUS flag on the drawing area. */ if (ih->iclass->is_interactive) { if (iupAttribGetBoolean(ih, "CANFOCUS")) iupgtkSetCanFocus(ih->handle, 1); } if (iupAttribGetBoolean(ih, "BORDER")) { iupAttribSetInt(ih, "BORDERWIDTH", 1); #if GTK_CHECK_VERSION(3, 0, 0) g_signal_connect(G_OBJECT(sb_win), "draw", G_CALLBACK(gtkCanvasBorderDraw), NULL); #else g_signal_connect(G_OBJECT(sb_win), "expose-event", G_CALLBACK(gtkCanvasBorderExposeEvent), NULL); #endif } gtk_widget_realize(sb_win); if (ih->data->sb & IUP_SB_HORIZ) { #if GTK_CHECK_VERSION(3, 0, 0) GtkWidget* sb_horiz = gtk_scrollbar_new(GTK_ORIENTATION_HORIZONTAL, NULL); #else GtkWidget* sb_horiz = gtk_hscrollbar_new(NULL); #endif iupgtkNativeContainerAdd(sb_win, sb_horiz); gtk_widget_show(sb_horiz); gtk_widget_realize(sb_horiz); g_signal_connect(G_OBJECT(sb_horiz), "change-value",G_CALLBACK(gtkCanvasScrollHorizChangeValue), ih); g_signal_connect(G_OBJECT(gtk_range_get_adjustment(GTK_RANGE(sb_horiz))), "value-changed",G_CALLBACK(gtkCanvasAdjustHorizValueChanged), ih); iupAttribSetStr(ih, "_IUPGTK_SBHORIZ", (char*)sb_horiz); } if (ih->data->sb & IUP_SB_VERT) { #if GTK_CHECK_VERSION(3, 0, 0) GtkWidget* sb_vert = gtk_scrollbar_new(GTK_ORIENTATION_VERTICAL, NULL); #else GtkWidget* sb_vert = gtk_vscrollbar_new(NULL); #endif iupgtkNativeContainerAdd(sb_win, sb_vert); gtk_widget_show(sb_vert); gtk_widget_realize(sb_vert); g_signal_connect(G_OBJECT(sb_vert), "change-value",G_CALLBACK(gtkCanvasScrollVertChangeValue), ih); g_signal_connect(G_OBJECT(gtk_range_get_adjustment(GTK_RANGE(sb_vert))), "value-changed",G_CALLBACK(gtkCanvasAdjustVertValueChanged), ih); iupAttribSetStr(ih, "_IUPGTK_SBVERT", (char*)sb_vert); } gtk_widget_realize(ih->handle); /* configure for DRAG&DROP */ if (IupGetCallback(ih, "DROPFILES_CB")) iupAttribSetStr(ih, "DROPFILESTARGET", "YES"); /* update a mnemonic in a label if necessary */ iupgtkUpdateMnemonic(ih); /* force the update of BGCOLOR here, to let derived classes ignore it if ACTION is defined */ gtkCanvasSetBgColorAttrib(ih, iupAttribGetStr(ih, "BGCOLOR")); return IUP_NOERROR; }
static int gtkDialogMapMethod(Ihandle* ih) { int decorations = 0; int functions = 0; InativeHandle* parent; GtkWidget* inner_parent; int has_titlebar = 0; #ifdef HILDON if (iupAttribGetBoolean(ih, "HILDONWINDOW")) { HildonProgram *program = HILDON_PROGRAM(hildon_program_get_instance()); ih->handle = hildon_window_new(); if (ih->handle) hildon_program_add_window(program, HILDON_WINDOW(ih->handle)); } else { iupAttribSet(ih, "DIALOGHINT", "YES"); /* otherwise not displayed correctly */ ih->handle = gtk_window_new(GTK_WINDOW_TOPLEVEL); } #else ih->handle = gtk_window_new(GTK_WINDOW_TOPLEVEL); #endif if (!ih->handle) return IUP_ERROR; parent = iupDialogGetNativeParent(ih); if (parent) { gtk_window_set_transient_for((GtkWindow*)ih->handle, (GtkWindow*)parent); /* manually remove child windows when parent is destroyed */ g_signal_connect(G_OBJECT(parent), "destroy", G_CALLBACK(gtkDialogChildDestroyEvent), ih); } g_signal_connect(G_OBJECT(ih->handle), "focus-in-event", G_CALLBACK(iupgtkFocusInOutEvent), ih); g_signal_connect(G_OBJECT(ih->handle), "focus-out-event", G_CALLBACK(iupgtkFocusInOutEvent), ih); g_signal_connect(G_OBJECT(ih->handle), "enter-notify-event", G_CALLBACK(iupgtkEnterLeaveEvent), ih); g_signal_connect(G_OBJECT(ih->handle), "leave-notify-event", G_CALLBACK(iupgtkEnterLeaveEvent), ih); g_signal_connect(G_OBJECT(ih->handle), "show-help", G_CALLBACK(iupgtkShowHelp), ih); /* The iupgtkKeyPressEvent of the control with the focus will propagate the key up to the dialog. */ /* Inside iupgtkKeyPressEvent we test this to avoid duplicate calls. */ g_signal_connect(G_OBJECT(ih->handle), "key-press-event", G_CALLBACK(iupgtkKeyPressEvent), ih); g_signal_connect(G_OBJECT(ih->handle), "configure-event", G_CALLBACK(gtkDialogConfigureEvent), ih); g_signal_connect(G_OBJECT(ih->handle), "window-state-event", G_CALLBACK(gtkDialogWindowStateEvent), ih); g_signal_connect(G_OBJECT(ih->handle), "delete-event", G_CALLBACK(iupgtkDialogDeleteEvent), ih); gtk_window_set_default_size((GtkWindow*)ih->handle, 100, 100); /* set this to avoid size calculation problems */ if (iupAttribGetBoolean(ih, "DIALOGHINT")) gtk_window_set_type_hint(GTK_WINDOW(ih->handle), GDK_WINDOW_TYPE_HINT_DIALOG); /* the container that will receive the child element. */ inner_parent = iupgtkNativeContainerNew(0); gtk_container_add((GtkContainer*)ih->handle, inner_parent); gtk_widget_show(inner_parent); /* initialize the widget */ gtk_widget_realize(ih->handle); if (iupAttribGet(ih, "TITLE")) has_titlebar = 1; if (iupAttribGetBoolean(ih, "RESIZE")) { functions |= GDK_FUNC_RESIZE; decorations |= GDK_DECOR_RESIZEH; decorations |= GDK_DECOR_BORDER; /* has_border */ } else iupAttribSet(ih, "MAXBOX", "NO"); if (iupAttribGetBoolean(ih, "MENUBOX")) { functions |= GDK_FUNC_CLOSE; decorations |= GDK_DECOR_MENU; has_titlebar = 1; } if (iupAttribGetBoolean(ih, "MAXBOX")) { functions |= GDK_FUNC_MAXIMIZE; decorations |= GDK_DECOR_MAXIMIZE; has_titlebar = 1; } if (iupAttribGetBoolean(ih, "MINBOX")) { functions |= GDK_FUNC_MINIMIZE; decorations |= GDK_DECOR_MINIMIZE; has_titlebar = 1; } if (has_titlebar) { functions |= GDK_FUNC_MOVE; decorations |= GDK_DECOR_TITLE; gtk_window_set_title((GtkWindow*)ih->handle, ""); } if (iupAttribGetBoolean(ih, "BORDER") || has_titlebar) decorations |= GDK_DECOR_BORDER; /* has_border */ if (decorations == 0) gtk_window_set_decorated((GtkWindow*)ih->handle, FALSE); else { GdkWindow* window = iupgtkGetWindow(ih->handle); if (window) { gdk_window_set_decorations(window, (GdkWMDecoration)decorations); gdk_window_set_functions(window, (GdkWMFunction)functions); } } /* configure for DRAG&DROP */ if (IupGetCallback(ih, "DROPFILES_CB")) iupAttribSet(ih, "DROPFILESTARGET", "YES"); /* configure the size range */ gtkDialogSetMinMax(ih, 1, 1, 65535, 65535); /* MINSIZE and MAXSIZE default values */ /* Ignore VISIBLE before mapping */ iupAttribSet(ih, "VISIBLE", NULL); if (iupStrBoolean(IupGetGlobal("INPUTCALLBACKS"))) gtk_widget_add_events(ih->handle, GDK_POINTER_MOTION_MASK|GDK_BUTTON_PRESS_MASK|GDK_BUTTON_RELEASE_MASK|GDK_BUTTON_MOTION_MASK); return IUP_NOERROR; }