GuiDrawingArea GuiDrawingArea_create (GuiForm parent, int left, int right, int top, int bottom, void (*exposeCallback) (void *boss, GuiDrawingAreaExposeEvent event), void (*clickCallback) (void *boss, GuiDrawingAreaClickEvent event), void (*keyCallback) (void *boss, GuiDrawingAreaKeyEvent event), void (*resizeCallback) (void *boss, GuiDrawingAreaResizeEvent event), void *boss, unsigned long flags) { GuiDrawingArea me = Thing_new (GuiDrawingArea); my d_shell = parent -> d_shell; my d_parent = parent; my d_exposeCallback = exposeCallback; my d_exposeBoss = boss; my d_clickCallback = clickCallback; my d_clickBoss = boss; my d_keyCallback = keyCallback; my d_keyBoss = boss; my d_resizeCallback = resizeCallback; my d_resizeBoss = boss; #if gtk my d_widget = gtk_drawing_area_new (); GdkEventMask mask = (GdkEventMask) (GDK_EXPOSURE_MASK // receive exposure events | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK // receive click events | GDK_BUTTON_MOTION_MASK // receive motion notifies when a button is pressed | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_POINTER_MOTION_HINT_MASK); // receive fewer motion notify events (the cb might take time) gtk_widget_set_events (GTK_WIDGET (my d_widget), mask); g_signal_connect (G_OBJECT (my d_widget), "expose-event", G_CALLBACK (_GuiGtkDrawingArea_exposeCallback), me); g_signal_connect (G_OBJECT (my d_widget), "destroy", G_CALLBACK (_GuiGtkDrawingArea_destroyCallback), me); g_signal_connect (G_OBJECT (my d_widget), "button-press-event", G_CALLBACK (_GuiGtkDrawingArea_clickCallback), me); g_signal_connect (G_OBJECT (my d_widget), "button-release-event", G_CALLBACK (_GuiGtkDrawingArea_clickCallback), me); g_signal_connect (G_OBJECT (my d_widget), "motion-notify-event", G_CALLBACK (_GuiGtkDrawingArea_clickCallback), me); if (parent != NULL) { Melder_assert (parent -> d_widget); g_signal_connect (G_OBJECT (gtk_widget_get_toplevel (GTK_WIDGET (parent -> d_widget))), "key-press-event", G_CALLBACK (_GuiGtkDrawingArea_keyCallback), me); } g_signal_connect (G_OBJECT (my d_widget), "size-allocate", G_CALLBACK (_GuiGtkDrawingArea_resizeCallback), me); // g_signal_connect (GTK_WIDGET (my d_widget), "activate", G_CALLBACK (_GuiGtkDrawingArea_activateCallback), me); _GuiObject_setUserData (my d_widget, me); my v_positionInForm (my d_widget, left, right, top, bottom, parent); gtk_widget_set_double_buffered (GTK_WIDGET (my d_widget), FALSE); #elif cocoa #elif win my d_widget = _Gui_initializeWidget (xmDrawingAreaWidgetClass, parent -> d_widget, L"drawingArea"); _GuiObject_setUserData (my d_widget, me); my d_widget -> window = CreateWindowEx (0, _GuiWin_getDrawingAreaClassName (), L"drawingArea", WS_CHILD | WS_BORDER | WS_CLIPSIBLINGS, my d_widget -> x, my d_widget -> y, my d_widget -> width, my d_widget -> height, my d_widget -> parent -> window, NULL, theGui.instance, NULL); SetWindowLongPtr (my d_widget -> window, GWLP_USERDATA, (LONG_PTR) my d_widget); my v_positionInForm (my d_widget, left, right, top, bottom, parent); #elif mac my d_widget = _Gui_initializeWidget (xmDrawingAreaWidgetClass, parent -> d_widget, L"drawingArea"); _GuiObject_setUserData (my d_widget, me); my v_positionInForm (my d_widget, left, right, top, bottom, parent); #endif return me; }
GuiCheckButton GuiCheckButton_create (GuiForm parent, int left, int right, int top, int bottom, const wchar_t *buttonText, void (*valueChangedCallback) (void *boss, GuiCheckButtonEvent event), void *valueChangedBoss, unsigned long flags) { GuiCheckButton me = Thing_new (GuiCheckButton); my d_shell = parent -> d_shell; my d_parent = parent; my d_valueChangedCallback = valueChangedCallback; my d_valueChangedBoss = valueChangedBoss; #if gtk my d_widget = gtk_check_button_new_with_label (Melder_peekWcsToUtf8 (buttonText)); _GuiObject_setUserData (my d_widget, me); my v_positionInForm (my d_widget, left, right, top, bottom, parent); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (my d_widget), (flags & GuiCheckButton_SET) != 0); if (flags & GuiCheckButton_INSENSITIVE) { my f_setSensitive (false); } g_signal_connect (G_OBJECT (my d_widget), "destroy", G_CALLBACK (_GuiGtkCheckButton_destroyCallback), me); my d_valueChangedHandlerId = g_signal_connect (GTK_TOGGLE_BUTTON (my d_widget), "toggled", G_CALLBACK (_GuiGtkCheckButton_valueChangedCallback), me); #elif cocoa #elif win my d_widget = _Gui_initializeWidget (xmToggleButtonWidgetClass, parent -> d_widget, buttonText); _GuiObject_setUserData (my d_widget, me); my d_widget -> isRadioButton = false; my d_widget -> window = CreateWindow (L"button", _GuiWin_expandAmpersands (buttonText), WS_CHILD | BS_AUTOCHECKBOX | WS_CLIPSIBLINGS, my d_widget -> x, my d_widget -> y, my d_widget -> width, my d_widget -> height, my d_widget -> parent -> window, (HMENU) 1, theGui.instance, NULL); SetWindowLongPtr (my d_widget -> window, GWLP_USERDATA, (LONG_PTR) my d_widget); SetWindowFont (my d_widget -> window, GetStockFont (ANSI_VAR_FONT), FALSE); my v_positionInForm (my d_widget, left, right, top, bottom, parent); if (flags & GuiCheckButton_SET) { Button_SetCheck (my d_widget -> window, BST_CHECKED); } if (flags & GuiCheckButton_INSENSITIVE) { my f_setSensitive (false); } #elif mac my d_widget = _Gui_initializeWidget (xmToggleButtonWidgetClass, parent -> d_widget, buttonText); _GuiObject_setUserData (my d_widget, me); my d_widget -> isRadioButton = false; CreateCheckBoxControl (my d_widget -> macWindow, & my d_widget -> rect, NULL, (flags & GuiCheckButton_SET) != 0, true, & my d_widget -> nat.control.handle); Melder_assert (my d_widget -> nat.control.handle != NULL); SetControlReference (my d_widget -> nat.control.handle, (long) my d_widget); my d_widget -> isControl = true; _GuiNativeControl_setFont (my d_widget, 0, 13); _GuiNativeControl_setTitle (my d_widget); my v_positionInForm (my d_widget, left, right, top, bottom, parent); if (flags & GuiCheckButton_INSENSITIVE) { my f_setSensitive (false); } #endif return me; }