gwenhywfar  4.3.1
w_vlayout.mm
Go to the documentation of this file.
00001 /***************************************************************************
00002  begin       : August 10 2010
00003  copyright   : (C) 2010 by Samuel Strupp
00004  
00005  ***************************************************************************
00006  *          Please see toplevel file COPYING for license details           *
00007  ***************************************************************************/
00008 
00009 #import "CocoaVLayout.h"
00010 
00011 
00012 
00013 static GWENHYWFAR_CB
00014 int CocoaGui_WVLayout_SetIntProperty(GWEN_WIDGET *w,
00015                                                                          GWEN_DIALOG_PROPERTY prop,
00016                                                                          int index,
00017                                                                          int value,
00018                                                                          int doSignal) {
00019         CocoaVLayout *vlayout;
00020         
00021         vlayout=(CocoaVLayout*)(GWEN_Widget_GetImplData(w, COCOA_DIALOG_WIDGET_REAL));
00022         assert(vlayout);
00023         
00024         switch(prop) {
00025                 case GWEN_DialogProperty_Enabled:
00026                         //gtk_widget_set_sensitive(GTK_WIDGET(g), (value==0)?FALSE:TRUE);
00027                         return 0;
00028                         
00029                 case GWEN_DialogProperty_Focus:
00030                         //gtk_widget_grab_focus(GTK_WIDGET(g));
00031                         return 0;
00032                         
00033                 default:
00034                         break;
00035         }
00036         
00037         DBG_WARN(GWEN_LOGDOMAIN,
00038                          "Function is not appropriate for this type of widget (%s)",
00039                          GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
00040         return GWEN_ERROR_INVALID;
00041 }
00042 
00043 
00044 
00045 
00046 static GWENHYWFAR_CB
00047 int CocoaGui_WVLayout_GetIntProperty(GWEN_WIDGET *w,
00048                                                                          GWEN_DIALOG_PROPERTY prop,
00049                                                                          int index,
00050                                                                          int defaultValue) {
00051         CocoaVLayout *vlayout;
00052         
00053         vlayout=(CocoaVLayout*)(GWEN_Widget_GetImplData(w, COCOA_DIALOG_WIDGET_REAL));
00054         assert(vlayout);
00055         
00056         switch(prop) {
00057                 case GWEN_DialogProperty_Enabled:
00058                         //return (gtk_widget_get_sensitive(GTK_WIDGET(g))==TRUE)?1:0;
00059                         return 1;
00060                         
00061                 case GWEN_DialogProperty_Focus:
00062                         //return (gtk_widget_has_focus(GTK_WIDGET(g))==TRUE)?1:0;
00063                         return 0;
00064                         
00065                 default:
00066                         break;
00067         }
00068         
00069         DBG_WARN(GWEN_LOGDOMAIN,
00070                          "Function is not appropriate for this type of widget (%s)",
00071                          GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
00072         return defaultValue;
00073 }
00074 
00075 
00076 
00077 static GWENHYWFAR_CB
00078 int CocoaGui_WVLayout_SetCharProperty(GWEN_WIDGET *w,
00079                                                                           GWEN_DIALOG_PROPERTY prop,
00080                                                                           int index,
00081                                                                           const char *value,
00082                                                                           int doSignal) {
00083         /*CocoaVLayout *vlayout;
00084          
00085          vlayout=(CocoaVLayout*)(GWEN_Widget_GetImplData(w, COCOA_DIALOG_WIDGET_REAL));
00086          assert(vlayout);*/
00087         
00088         DBG_WARN(GWEN_LOGDOMAIN,
00089                          "Function is not appropriate for this type of widget (%s)",
00090                          GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
00091         return GWEN_ERROR_INVALID;
00092 }
00093 
00094 
00095 
00096 static GWENHYWFAR_CB
00097 const char* CocoaGui_WVLayout_GetCharProperty(GWEN_WIDGET *w,
00098                                                                                           GWEN_DIALOG_PROPERTY prop,
00099                                                                                           int index,
00100                                                                                           const char *defaultValue) {
00101         /*CocoaVLayout *vlayout;
00102          
00103          vlayout=(CocoaVLayout*)(GWEN_Widget_GetImplData(w, COCOA_DIALOG_WIDGET_REAL));
00104          assert(vlayout);*/
00105         
00106         DBG_WARN(GWEN_LOGDOMAIN,
00107                          "Function is not appropriate for this type of widget (%s)",
00108                          GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
00109         return defaultValue;
00110 }
00111 
00112 
00113 
00114 static GWENHYWFAR_CB
00115 int CocoaGui_WVLayout_AddChildGuiWidget(GWEN_WIDGET *w, GWEN_WIDGET *wChild) {
00116         CocoaVLayout *vlayout;
00117          NSView *childView;
00118          uint32_t cflags;
00119          
00120          vlayout=(CocoaVLayout*)(GWEN_Widget_GetImplData(w, COCOA_DIALOG_WIDGET_REAL));
00121          assert(vlayout);
00122          
00123          childView=(NSView*)(GWEN_Widget_GetImplData(wChild, COCOA_DIALOG_WIDGET_REAL));
00124          assert(childView);
00125          
00126          cflags=GWEN_Widget_GetFlags(wChild);
00127         
00128         
00129         [vlayout addLayoutSubview:childView];
00130          
00131         //Noch richtig implementieren
00132         /*
00133          gtk_box_pack_start(GTK_BOX(g), gChild,
00134          (cflags & GWEN_WIDGET_FLAGS_FILLY)?TRUE:FALSE,
00135          (cflags & GWEN_WIDGET_FLAGS_FILLY)?TRUE:FALSE,
00136          0);*/
00137         
00138         return 0;
00139 }
00140 
00141 
00142 
00143 int CocoaGui_WVLayout_Setup(GWEN_WIDGET *w) {
00144         /*GtkWidget *g;
00145          uint32_t flags;
00146          GWEN_WIDGET *wParent;
00147          
00148          flags=GWEN_Widget_GetFlags(w);
00149          wParent=GWEN_Widget_Tree_GetParent(w);
00150          
00151          g=gtk_vbox_new((flags & GWEN_WIDGET_FLAGS_EQUAL_HEIGHT)?TRUE:FALSE,
00152          GTK2_GUI_DIALOG_DEFAULT_BOX_SPACING);
00153          GWEN_Widget_SetImplData(w, GTK2_DIALOG_WIDGET_REAL, (void*) g);
00154          GWEN_Widget_SetImplData(w, GTK2_DIALOG_WIDGET_CONTENT, (void*) g);
00155          
00156          GWEN_Widget_SetSetIntPropertyFn(w, Gtk2Gui_WVLayout_SetIntProperty);
00157          GWEN_Widget_SetGetIntPropertyFn(w, Gtk2Gui_WVLayout_GetIntProperty);
00158          GWEN_Widget_SetSetCharPropertyFn(w, Gtk2Gui_WVLayout_SetCharProperty);
00159          GWEN_Widget_SetGetCharPropertyFn(w, Gtk2Gui_WVLayout_GetCharProperty);
00160          GWEN_Widget_SetAddChildGuiWidgetFn(w, Gtk2Gui_WVLayout_AddChildGuiWidget);
00161          
00162          if (wParent)
00163          GWEN_Widget_AddChildGuiWidget(wParent, w);*/
00164         
00165         CocoaVLayout *vlayout;
00166         uint32_t flags;
00167         GWEN_WIDGET *wParent;
00168         
00169         flags=GWEN_Widget_GetFlags(w);
00170         wParent=GWEN_Widget_Tree_GetParent(w);
00171         
00172         vlayout = [[[CocoaVLayout alloc] initWithFrame:NSMakeRect(10.0, 10.0, 200.0, 200.0)] autorelease];
00173         if (flags & GWEN_WIDGET_FLAGS_FILLX) vlayout.fillX = YES;
00174         if (flags & GWEN_WIDGET_FLAGS_FILLY) vlayout.fillY = YES;
00175         
00176         GWEN_Widget_SetImplData(w, COCOA_DIALOG_WIDGET_REAL, (void*) vlayout);
00177         GWEN_Widget_SetImplData(w, COCOA_DIALOG_WIDGET_CONTENT, (void*) vlayout);
00178         
00179         GWEN_Widget_SetSetIntPropertyFn(w, CocoaGui_WVLayout_SetIntProperty);
00180         GWEN_Widget_SetGetIntPropertyFn(w, CocoaGui_WVLayout_GetIntProperty);
00181         GWEN_Widget_SetSetCharPropertyFn(w, CocoaGui_WVLayout_SetCharProperty);
00182         GWEN_Widget_SetGetCharPropertyFn(w, CocoaGui_WVLayout_GetCharProperty);
00183         GWEN_Widget_SetAddChildGuiWidgetFn(w, CocoaGui_WVLayout_AddChildGuiWidget);
00184         
00185         if (wParent)
00186                 GWEN_Widget_AddChildGuiWidget(wParent, w);
00187         
00188         return 0;
00189 }
00190 
00191