39 int state = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
51 int value = (int)gtk_adjustment_get_value(GTK_ADJUSTMENT(ptr->
m_obj));
62 int value = gtk_combo_box_get_active(GTK_COMBO_BOX(ptr->
m_widget));
82 g_object_unref(ptr->
pixmap);
84 ptr->
pixmap = gdk_pixmap_new(widget->window,
85 widget->allocation.width,
86 widget->allocation.height,
88 gdk_draw_rectangle(ptr->
pixmap,
89 widget->style->black_gc,
92 widget->allocation.width,
93 widget->allocation.height);
106 gdk_draw_drawable(widget->window,
107 widget->style->fg_gc[GTK_WIDGET_STATE(widget)],
109 event->area.x, event->area.y,
110 event->area.x, event->area.y,
111 event->area.width, event->area.height);
115 gdk_draw_rgb_image(widget->window,
116 widget->style->fg_gc[GTK_WIDGET_STATE(widget)],
144 GdkGC *gc = widget->style->white_gc;
145 gdk_gc_set_function(gc, GDK_XOR);
146 gdk_draw_rectangle(widget->window,
151 gdk_gc_set_function(gc, GDK_COPY);
161 guint modifiers = gtk_accelerator_get_default_mod_mask();
164 gtk_widget_grab_focus(widget);
177 if (event->button == 1)
193 guint modifiers = gtk_accelerator_get_default_mod_mask();
207 if (ptr->
mouse_down == 1 && event->button == 1)
235 if (dx < 5 && dy < 5)
245 gtk_widget_queue_draw_area(widget, x0, y0, dx, dy);
256 guint modifiers = gtk_accelerator_get_default_mod_mask();
263 GdkModifierType state;
266 gdk_window_get_pointer(event->window, &x, &y, &state);
271 state = (GdkModifierType)event->state;
281 GdkModifierType state;
284 gdk_window_get_pointer(event->window, &x, &y, &state);
289 state = (GdkModifierType)event->state;
292 if (state & GDK_BUTTON1_MASK)
307 guint modifiers = gtk_accelerator_get_default_mod_mask();
313 if (event->length != 1)
330 guint modifiers = gtk_accelerator_get_default_mod_mask();
336 if (event->length != 1)
353 static gboolean ivtglwidget_configure_event(GtkWidget *widget, GdkEventConfigure *event)
355 IVTGLWidget *ptr = (IVTGLWidget *)widget;
360 ptr->glcontext->MakeCurrent(widget->window);
366 static gboolean ivtglwidget_button_press_event(GtkWidget *widget, GdkEventButton *event)
368 IVTGLWidget *ptr = (IVTGLWidget *)widget;
370 guint modifiers = gtk_accelerator_get_default_mod_mask();
373 gtk_widget_grab_focus(widget);
389 static gboolean ivtglwidget_button_release_event(GtkWidget *widget, GdkEventButton *event)
391 IVTGLWidget *ptr = (IVTGLWidget *)widget;
393 guint modifiers = gtk_accelerator_get_default_mod_mask();
410 static gboolean ivtglwidget_motion_notify_event(GtkWidget *widget, GdkEventMotion *event)
412 IVTGLWidget *ptr = (IVTGLWidget *)widget;
414 guint modifiers = gtk_accelerator_get_default_mod_mask();
421 GdkModifierType state;
424 gdk_window_get_pointer(event->window, &x, &y, &state);
429 state = (GdkModifierType)event->state;
438 static gboolean ivtglwidget_key_press_event(GtkWidget *widget, GdkEventKey *event)
440 IVTGLWidget *ptr = (IVTGLWidget *)widget;
442 guint modifiers = gtk_accelerator_get_default_mod_mask();
448 if (event->length != 1)
461 static gboolean ivtglwidget_key_release_event(GtkWidget *widget, GdkEventKey *event)
463 IVTGLWidget *ptr = (IVTGLWidget *)widget;
465 guint modifiers = gtk_accelerator_get_default_mod_mask();
471 if (event->length != 1)
494 gtk_widget_destroy(widget);
511 if (pApplicationHandler)
512 pApplicationHandler->
SetExit(
true);
521 gtk_window_set_default_size(GTK_WINDOW(
m_main_window), width, height);
522 gtk_window_set_position(GTK_WINDOW(
m_main_window), GTK_WIN_POS_NONE);
541 for (
int i = nWidgets - 1; i >= 0; i--)
554 while (gtk_events_pending())
555 gtk_main_iteration();
575 gtk_widget_set_events(image, GDK_EXPOSURE_MASK
576 | GDK_LEAVE_NOTIFY_MASK
577 | GDK_BUTTON_PRESS_MASK
578 | GDK_BUTTON_RELEASE_MASK
579 | GDK_POINTER_MOTION_MASK
580 | GDK_POINTER_MOTION_HINT_MASK
582 | GDK_KEY_RELEASE_MASK);
586 gtk_drawing_area_size(GTK_DRAWING_AREA(image), width, height);
589 ((
IVTImage*)image)->main_window_widget =
w;
591 gtk_widget_show(image);
605 button = gtk_button_new_with_label(text);
608 gtk_widget_set_size_request(button, width, height);
609 gtk_widget_show(button);
623 label = gtk_label_new(text);
624 gtk_misc_set_alignment(GTK_MISC(label), 0.0f, 0.5f);
626 gtk_widget_set_size_request(label, width, height);
627 gtk_widget_show(label);
640 GtkWidget *check_button;
641 check_button = gtk_check_button_new_with_label(text);
644 gtk_widget_set_size_request(check_button, width, height);
645 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check_button), checked);
646 gtk_widget_show(check_button);
660 edit = gtk_entry_new();
662 gtk_entry_set_text(GTK_ENTRY(edit), text);
667 gtk_widget_set_size_request(edit, width, height);
668 gtk_widget_show(edit);
681 GtkObject *adjustment;
682 adjustment = gtk_adjustment_new(value, min_value, max_value, 1.0, step, 1.0);
686 slider = gtk_hscale_new(GTK_ADJUSTMENT(adjustment));
687 gtk_scale_set_draw_value(GTK_SCALE(slider), FALSE);
690 gtk_widget_set_size_request(slider, width, height);
691 gtk_widget_show(slider);
694 w->
m_obj = adjustment;
706 cbox = gtk_combo_box_new_text();
708 for (
int i = 0; i < num_entries; i++)
710 gtk_combo_box_append_text(GTK_COMBO_BOX(cbox), entries[i]);
713 gtk_combo_box_set_active(GTK_COMBO_BOX(cbox), current_entry);
718 gtk_widget_set_size_request(cbox, width, height);
719 gtk_widget_show(cbox);
736 printf(
"CGTKMainWindow::AddGLWidget: creation of GLWidget failed\n");
744 gtk_widget_push_colormap(gdk_colormap_new(visual, TRUE));
745 gtk_widget_push_visual(visual);
748 glw = ivtglwidget_new();
751 gtk_widget_pop_visual();
752 gtk_widget_pop_colormap();
754 gtk_signal_connect(GTK_OBJECT(glw),
"configure_event", (GtkSignalFunc)ivtglwidget_configure_event, NULL);
755 gtk_signal_connect(GTK_OBJECT(glw),
"motion_notify_event", (GtkSignalFunc)ivtglwidget_motion_notify_event, NULL);
756 gtk_signal_connect(GTK_OBJECT(glw),
"button_press_event", (GtkSignalFunc)ivtglwidget_button_press_event, NULL);
757 gtk_signal_connect(GTK_OBJECT(glw),
"button_release_event", (GtkSignalFunc)ivtglwidget_button_release_event, NULL);
758 gtk_signal_connect(GTK_OBJECT(glw),
"key_press_event", (GtkSignalFunc)ivtglwidget_key_press_event, NULL);
759 gtk_signal_connect(GTK_OBJECT(glw),
"key_release_event", (GtkSignalFunc)ivtglwidget_key_release_event, NULL);
761 gtk_widget_set_events(glw, GDK_LEAVE_NOTIFY_MASK
762 | GDK_BUTTON_PRESS_MASK
763 | GDK_BUTTON_RELEASE_MASK
764 | GDK_POINTER_MOTION_MASK
765 | GDK_POINTER_MOTION_HINT_MASK
767 | GDK_KEY_RELEASE_MASK);
771 gtk_drawing_area_size(GTK_DRAWING_AREA(glw), width, height);
773 ((IVTGLWidget*)glw)->main_window_widget =
w;
774 ((IVTGLWidget*)glw)->glcontext = glcontext;
776 gtk_widget_show(glw);
779 gtk_widget_realize(glw);
780 ((IVTGLWidget*)glw)->glcontext->MakeCurrent(glw->window);
788 printf(
"WARNING: CGTKMainWindow::AddGLWidget has been called, but USE_OPENGL = 0 in Makefile.base\n");
805 const char *ptr = gtk_label_get_text(GTK_LABEL(w->
m_widget));
806 strncpy(text, ptr, len);
812 const char *ptr = gtk_button_get_label(GTK_BUTTON(w->
m_widget));
813 strncpy(text, ptr, len);
819 const char *ptr = gtk_entry_get_text(GTK_ENTRY(w->
m_widget));
820 strncpy(text, ptr, len);
836 gtk_label_set_text(GTK_LABEL(w->
m_widget), text);
842 gtk_button_set_label(GTK_BUTTON(w->
m_widget), text);
848 gtk_entry_set_text(GTK_ENTRY(w->
m_widget), text);
869 printf(
"error: SetImage: image size does not match size of image widget\n");
899 value = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w->
m_widget));
904 value = (int)gtk_adjustment_get_value(GTK_ADJUSTMENT(w->
m_obj));
909 value = gtk_combo_box_get_active(GTK_COMBO_BOX(w->
m_widget));
925 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w->
m_widget), value);
930 gtk_adjustment_set_value(GTK_ADJUSTMENT(w->
m_obj), (
double)value);
935 gtk_combo_box_set_active(GTK_COMBO_BOX(w->
m_widget), value);
952 IVTGLWidget* glw = (IVTGLWidget*)w->
m_widget;
955 glw->glcontext->SwapBuffers(GTK_WIDGET(glw)->window);
974 IVTGLWidget* glw = (IVTGLWidget*)w->
m_widget;
977 glw->glcontext->MakeCurrent(GTK_WIDGET(glw)->window);
GtkWidget * m_fixed_container
virtual void KeyUp(WIDGET_HANDLE widget, int key)
static gboolean ivtimage_key_press_event(GtkWidget *widget, GdkEventKey *event)
void Destroy(GtkWidget *widget)
WIDGET_HANDLE AddLabel(int x, int y, int width, int height, const char *text, WIDGET_HANDLE parent=0)
static CGTKApplicationHandler * GetApplicationHandler()
static void checkbox_toggled_callback(GtkWidget *widget, gpointer data)
virtual void KeyDown(WIDGET_HANDLE widget, int key)
GtkWidget * m_main_window
CMainWindowEventInterface * m_event_callback
int width
The width of the image in pixels.
static unsigned int last_modifier_key_state
CGTKMainWindow(int x, int y, int width, int height, const char *title)
bool SetImage(WIDGET_HANDLE widget, const CByteImage *pImage)
virtual ~CGTKMainWindow()
GLenum GLsizei GLenum GLenum const GLvoid * image
WIDGET_HANDLE AddImage(int x, int y, int width, int height, WIDGET_HANDLE parent=0)
WIDGET_HANDLE AddComboBox(int x, int y, int width, int height, int num_entries, const char **entries, int current_entry, WIDGET_HANDLE parent=0)
static gboolean ivtimage_key_release_event(GtkWidget *widget, GdkEventKey *event)
Data structure for the representation of 8-bit grayscale images and 24-bit RGB (or HSV) color images ...
virtual void MouseDown(WIDGET_HANDLE widget, int button, int x, int y)
unsigned char * pixels
The pointer to the the pixels.
bool ConvertImage(const CByteImage *pInputImage, CByteImage *pOutputImage, bool bFast=false, const MyRegion *pROI=0)
Converts a grayscale CByteImage to an RGB CByteImage image and vice versa.
static void slider_changed_callback(GtkWidget *widget, gpointer data)
static int destroy_window_callback(GtkWidget *widget, gpointer data)
WIDGET_HANDLE AddTextEdit(int x, int y, int width, int height, const char *text, WIDGET_HANDLE parent=0)
static void combo_box_changed_callback(GtkWidget *widget, gpointer data)
WIDGET_HANDLE AddSlider(int x, int y, int width, int height, int min_value, int max_value, int step, int value, WIDGET_HANDLE parent=0)
static gboolean ivtimage_expose_event(GtkWidget *widget, GdkEventExpose *event)
void ValueChanged(int value)
GtkWidget * ivtimage_new()
int GetModifierKeyState()
GLsizei const GLfloat * value
GLsizei GLsizei GLenum GLenum const GLvoid * data
virtual void MouseMove(WIDGET_HANDLE widget, int x, int y)
bool CopyImage(const CByteImage *pInputImage, CByteImage *pOutputImage, const MyRegion *pROI=0, bool bUseSameSize=false)
Copies one CByteImage to another.
bool SetText(WIDGET_HANDLE widget, const char *text)
virtual void PointClicked(WIDGET_HANDLE widget, int x, int y)
bool GetText(WIDGET_HANDLE widget, char *text, int len)
int height
The height of the image in pixels.
static gboolean ivtimage_motion_notify_event(GtkWidget *widget, GdkEventMotion *event)
CGTKMainWindowWidget * main_window_widget
bool GetValue(WIDGET_HANDLE widget, int &value)
GLenum GLsizei GLsizei height
static gboolean ivtimage_configure_event(GtkWidget *widget, GdkEventConfigure *event)
#define IVT_MIDDLE_BUTTON
ImageType type
The type of the image.
CMainWindowEventInterface * GetEventCallback()
void TextChanged(const char *str)
void Hide(WIDGET_HANDLE widget=0)
static gboolean ivtimage_button_release_event(GtkWidget *widget, GdkEventButton *event)
static gboolean ivtimage_button_press_event(GtkWidget *widget, GdkEventButton *event)
bool SetValue(WIDGET_HANDLE widget, int value)
bool SwapBuffersGLWidget(WIDGET_HANDLE widget)
static void text_edit_changed_callback(GtkWidget *widget, gpointer data)
bool MakeCurrentGLWidget(WIDGET_HANDLE widget)
void Show(WIDGET_HANDLE widget=0)
CGTKMainWindow * m_main_window
Interface for the event mechanism of GUIs using the GUI toolkit of the IVT.
GLubyte GLubyte GLubyte GLubyte w
virtual void RectSelected(WIDGET_HANDLE widget, int x0, int y0, int x1, int y1)
static void callback(IplImage *pIplImage)
WIDGET_HANDLE AddGLWidget(int x, int y, int width, int height, WIDGET_HANDLE parent=0)
static void button_pressed_callback(GtkWidget *widget, gpointer data)
std::vector< CGTKMainWindowWidget * > m_widgets
virtual void MouseUp(WIDGET_HANDLE widget, int button, int x, int y)
WIDGET_HANDLE AddButton(int x, int y, int width, int height, const char *text, WIDGET_HANDLE parent=0)
WIDGET_HANDLE AddCheckBox(int x, int y, int width, int height, const char *text, bool checked, WIDGET_HANDLE parent=0)