GTKMainWindowWidget.cpp
Go to the documentation of this file.
00001 // ****************************************************************************
00002 // Filename:  GTKMainWindowWidget.cpp
00003 // Author:    Florian Hecht
00004 // Date:      2009
00005 // ****************************************************************************
00006 
00007 
00008 #include "GTKMainWindowWidget.h"
00009 #include "GTKMainWindow.h"
00010 
00011 #include "Interfaces/MainWindowEventInterface.h"
00012 #include "Image/ByteImage.h"
00013 
00014 
00015 CGTKMainWindowWidget::CGTKMainWindowWidget(CGTKMainWindow *main_window, GTKWidgetType type)
00016 : m_main_window(main_window), m_type(type), m_widget(NULL), m_obj(NULL)
00017 {
00018 }
00019 
00020 CGTKMainWindowWidget::~CGTKMainWindowWidget()
00021 {
00022         if (m_type == eImage)
00023         {
00024                 delete ((IVTImage*)m_widget)->image;
00025                 ((IVTImage*)m_widget)->image = NULL;
00026         }
00027 }
00028 
00029 void CGTKMainWindowWidget::Clicked()
00030 {
00031         CMainWindowEventInterface *ec = m_main_window->GetEventCallback();
00032         
00033         if (ec != NULL && m_type == eButton)
00034         {
00035                 ec->ButtonPushed(this);
00036         }
00037 }
00038 void CGTKMainWindowWidget::ValueChanged(int value)
00039 {
00040         CMainWindowEventInterface *ec = m_main_window->GetEventCallback();
00041         
00042         if (ec != NULL && (m_type == eSlider || m_type == eComboBox))
00043         {
00044                 ec->ValueChanged(this, value);
00045         }
00046 }
00047 void CGTKMainWindowWidget::Toggled(bool flag)
00048 {
00049         CMainWindowEventInterface *ec = m_main_window->GetEventCallback();
00050         
00051         if (ec != NULL && m_type == eCheckBox)
00052         {
00053                 ec->ValueChanged(this, (flag ? 1 : 0));
00054         }
00055 }
00056 void CGTKMainWindowWidget::TextChanged(const char *str)
00057 {
00058         CMainWindowEventInterface *ec = m_main_window->GetEventCallback();
00059         
00060         if (ec != NULL && m_type == eTextEdit)
00061         {
00062                 ec->ValueChanged(this, -1);
00063         }
00064 }
00065 
00066 
00067 static void ivtimage_class_init          (IVTImageClass *klass);
00068 static void ivtimage_init                (IVTImage      *ttt);
00069 
00070 GType ivtimage_get_type(void)
00071 {
00072   static GType ttt_type = 0;
00073 
00074   if (!ttt_type)
00075     {
00076       static const GTypeInfo ttt_info =
00077       {
00078         sizeof (IVTImageClass),
00079         NULL, /* base_init */
00080         NULL, /* base_finalize */
00081         (GClassInitFunc) ivtimage_class_init,
00082         NULL, /* class_finalize */
00083         NULL, /* class_data */
00084         sizeof (IVTImage),
00085         0,    /* n_preallocs */
00086         (GInstanceInitFunc) ivtimage_init,
00087       };
00088 
00089       ttt_type = g_type_register_static (GTK_TYPE_DRAWING_AREA,
00090                                          "IVTImage",
00091                                          &ttt_info,
00092                                          (GTypeFlags)0);
00093     }
00094 
00095   return ttt_type;
00096 }
00097 
00098 static void ivtimage_class_init (IVTImageClass *klass)
00099 {
00100 
00101 }
00102 
00103 static void ivtimage_init (IVTImage *ttt)
00104 {
00105         ttt->pixmap = NULL;
00106         ttt->image = NULL;
00107         ttt->main_window_widget = NULL;
00108         
00109         ttt->mouse_down = 0;
00110         
00111         GTK_WIDGET_SET_FLAGS(ttt, GTK_CAN_FOCUS);
00112 }
00113 
00114 GtkWidget* ivtimage_new ()
00115 {
00116         return GTK_WIDGET (g_object_new (ivtimage_get_type (), NULL));
00117 }
00118 
00119 
00120 #ifdef USE_OPENGL
00121 
00122 #include "GTKGLContext.h"
00123 
00124 static void ivtglwidget_class_init      (IVTGLWidgetClass       *klass);
00125 static void ivtglwidget_init            (IVTGLWidget            *ttt);
00126 static void ivtglwidget_destroy         (GtkObject              *object);
00127 
00128 static GtkDrawingAreaClass *parent_class = NULL;
00129 
00130 GType ivtglwidget_get_type(void)
00131 {
00132   static GType ttt_type = 0;
00133 
00134   if (!ttt_type)
00135     {
00136       static const GTypeInfo ttt_info =
00137       {
00138         sizeof (IVTGLWidgetClass),
00139         NULL, /* base_init */
00140         NULL, /* base_finalize */
00141         (GClassInitFunc) ivtglwidget_class_init,
00142         NULL, /* class_finalize */
00143         NULL, /* class_data */
00144         sizeof (IVTGLWidget),
00145         0,    /* n_preallocs */
00146         (GInstanceInitFunc) ivtglwidget_init,
00147       };
00148 
00149       ttt_type = g_type_register_static (GTK_TYPE_DRAWING_AREA,
00150                                          "IVTGLWidget",
00151                                          &ttt_info,
00152                                          (GTypeFlags)0);
00153     }
00154 
00155   return ttt_type;
00156 }
00157 
00158 static void ivtglwidget_class_init (IVTGLWidgetClass *klass)
00159 {
00160         GtkObjectClass *object_class;
00161 
00162         parent_class = (GtkDrawingAreaClass*)g_type_class_peek_parent(klass);
00163         object_class = (GtkObjectClass*) klass;
00164 
00165         object_class->destroy = ivtglwidget_destroy;
00166 }
00167 
00168 static void ivtglwidget_init (IVTGLWidget *ttt)
00169 {
00170         ttt->glcontext = NULL;
00171         ttt->main_window_widget = NULL;
00172         
00173         GTK_WIDGET_SET_FLAGS(ttt, GTK_CAN_FOCUS);
00174 }
00175 
00176 static void ivtglwidget_destroy(GtkObject *object)
00177 {
00178         IVTGLWidget *glw;
00179 
00180         g_return_if_fail (object != NULL);
00181         g_return_if_fail (IS_IVTGLWIDGET(object));
00182 
00183         glw = IVTGLWIDGET(object);
00184 
00185         if (glw->glcontext)
00186                 delete glw->glcontext;
00187         glw->glcontext = NULL;
00188 
00189         if (GTK_OBJECT_CLASS (parent_class)->destroy)
00190                 (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
00191 }
00192 GtkWidget* ivtglwidget_new ()
00193 {
00194         IVTGLWidget *glw = (IVTGLWidget*)g_object_new (ivtglwidget_get_type (), NULL);
00195         
00196         return (GtkWidget*)glw;
00197 }
00198 
00199 #endif /* USE_OPENGL */
00200 
00201 


asr_ivt
Author(s): Allgeyer Tobias, Hutmacher Robin, Kleinert Daniel, Meißner Pascal, Scholz Jonas, Stöckle Patrick
autogenerated on Thu Jun 6 2019 21:46:57