示例#1
0
	static void _GuiWindow_child_resizeCallback (GtkWidget *childWidget, gpointer data) {
		GtkAllocation *allocation = (GtkAllocation *) data;
		GtkWidget *parentWidget = gtk_widget_get_parent (childWidget);
		Thing_cast (GuiThing, child, _GuiObject_getUserData (childWidget));
		if (child) {
			GuiControl control = nullptr;
			if (Thing_isa (child, classGuiControl)) {
				control = static_cast <GuiControl> (child);
			} else if (Thing_isa (child, classGuiMenu)) {
				Thing_cast (GuiMenu, menu, child);
				control = menu -> d_cascadeButton;
			}
			if (control) {
				/*
				 * Move and resize.
				 */
				trace (U"moving child of class ", Thing_className (control));
				int left = control -> d_left, right = control -> d_right, top = control -> d_top, bottom = control -> d_bottom;
				if (left   <  0) left   += allocation -> width;   // this replicates structGuiControl :: v_positionInForm ()
				if (right  <= 0) right  += allocation -> width;
				if (top    <  0) top    += allocation -> height;
				if (bottom <= 0) bottom += allocation -> height;
				trace (U"moving child to (", left, U",", top, U")");
				gtk_fixed_move (GTK_FIXED (parentWidget), GTK_WIDGET (childWidget), left, top);
				gtk_widget_set_size_request (GTK_WIDGET (childWidget), right - left, bottom - top);
				trace (U"moved child of class ", Thing_className (control));
			}
		}
	}
示例#2
0
文件: GuiMenu.cpp 项目: psibre/praat
	static void _guiGtkMenuCascadeButton_destroyCallback (GuiObject widget, gpointer void_me) {
		(void) void_me;
		GuiMenu me = (GuiMenu) _GuiObject_getUserData (widget);
		if (! me) return;
		trace (U"destroying GuiButton ", Melder_pointer (my d_cascadeButton));
		gtk_widget_destroy (GTK_WIDGET (my d_widget));
	}
示例#3
0
文件: GuiMenu.cpp 项目: psibre/praat
	static void _guiGtkMenu_destroyCallback (GuiObject widget, gpointer void_me) {
		(void) void_me;
		GuiMenu me = (GuiMenu) _GuiObject_getUserData (widget);
		trace (U"destroying GuiMenu ", Melder_pointer (me));
		if (! me) return;   // we could be destroying me
		my d_widget = NULL;   // undangle
		if (my d_cascadeButton) my d_cascadeButton -> d_widget = NULL;   // undangle
		if (my d_menuItem) my d_menuItem -> d_widget = NULL;   // undangle
		forget (me);
	}
示例#4
0
	static gboolean _GuiWindow_resizeCallback (GuiObject widget, GtkAllocation *allocation, gpointer void_me) {
		(void) widget;
		iam (GuiWindow);
		trace ("fixed received size allocation: (%ld, %ld), %ld x %ld.", (long) allocation -> x, (long) allocation -> y, (long) allocation -> width, (long) allocation -> height);
		if (allocation -> width != my d_width || allocation -> height != my d_height) {
			trace ("user changed the size of the window?");
			/*
			 * Apparently, GTK sends the size allocation message both to the shell and to its fixed-container child.
			 * we could capture the message either from the shell or from the fixed; we choose to do it from the fixed.
			 */
			Melder_assert (GTK_IS_FIXED (widget));
			/*
			 * We move and resize all the children of the fixed.
			 */
			GList *children = GTK_FIXED (widget) -> children;
			for (GList *l = g_list_first (children); l != NULL; l = g_list_next (l)) {
				GtkFixedChild *listElement = (GtkFixedChild *) l -> data;
				GtkWidget *childWidget = listElement -> widget;
				Melder_assert (childWidget);
				Thing_cast (GuiThing, child, _GuiObject_getUserData (childWidget));
				if (child) {
					GuiControl control = NULL;
					if (Thing_member (child, classGuiControl)) {
						control = static_cast <GuiControl> (child);
					} else if (Thing_member (child, classGuiMenu)) {
						Thing_cast (GuiMenu, menu, child);
						control = menu -> d_cascadeButton;
					}
					if (control) {
						/*
						 * Move and resize.
						 */
						trace ("moving child of class %ls", Thing_className (control));
						int left = control -> d_left, right = control -> d_right, top = control -> d_top, bottom = control -> d_bottom;
						if (left   <  0) left   += allocation -> width;   // this replicates structGuiControl :: v_positionInForm ()
						if (right  <= 0) right  += allocation -> width;
						if (top    <  0) top    += allocation -> height;
						if (bottom <= 0) bottom += allocation -> height;
						trace ("moving child to (%d,%d)", left, top);
						gtk_fixed_move (GTK_FIXED (widget), GTK_WIDGET (childWidget), left, top);
						gtk_widget_set_size_request (GTK_WIDGET (childWidget), right - left, bottom - top);
						trace ("moved child of class %ls", Thing_className (control));
					}
				}
			}
			my d_width = allocation -> width;
			my d_height = allocation -> height;
			gtk_widget_set_size_request (GTK_WIDGET (widget), allocation -> width, allocation -> height);
		}
		trace ("end");
		return FALSE;
	}