gwenhywfar 4.0.3

w_hlayout.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 
00010 
00011 #import "CocoaHLayout.h"
00012 
00013 
00014 
00015 static GWENHYWFAR_CB
00016 int CocoaGui_WHLayout_SetIntProperty(GWEN_WIDGET *w,
00017                                                                          GWEN_DIALOG_PROPERTY prop,
00018                                                                          int index,
00019                                                                          int value,
00020                                                                          int doSignal) {
00021         CocoaHLayout *hlayout;
00022         
00023         hlayout=(CocoaHLayout*)(GWEN_Widget_GetImplData(w, COCOA_DIALOG_WIDGET_REAL));
00024         assert(hlayout);
00025         
00026         switch(prop) {
00027                 case GWEN_DialogProperty_Enabled:
00028                         //gtk_widget_set_sensitive(GTK_WIDGET(g), (value==0)?FALSE:TRUE);
00029                         return 0;
00030                         
00031                 case GWEN_DialogProperty_Focus:
00032                         //gtk_widget_grab_focus(GTK_WIDGET(g));
00033                         return 0;
00034                         
00035                 default:
00036                         break;
00037         }
00038         
00039         DBG_WARN(GWEN_LOGDOMAIN,
00040                          "Function is not appropriate for this type of widget (%s)",
00041                          GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
00042         return GWEN_ERROR_INVALID;
00043 }
00044 
00045 
00046 
00047 
00048 static GWENHYWFAR_CB
00049 int CocoaGui_WHLayout_GetIntProperty(GWEN_WIDGET *w,
00050                                                                          GWEN_DIALOG_PROPERTY prop,
00051                                                                          int index,
00052                                                                          int defaultValue) {
00053         CocoaHLayout *hlayout;
00054         
00055         hlayout=(CocoaHLayout*)(GWEN_Widget_GetImplData(w, COCOA_DIALOG_WIDGET_REAL));
00056         assert(hlayout);
00057         
00058         switch(prop) {
00059                 case GWEN_DialogProperty_Enabled:
00060                         //return (gtk_widget_get_sensitive(GTK_WIDGET(g))==TRUE)?1:0;
00061                         return 1;
00062                         
00063                 case GWEN_DialogProperty_Focus:
00064                         //return (gtk_widget_has_focus(GTK_WIDGET(g))==TRUE)?1:0;
00065                         return 0;
00066                         
00067                 default:
00068                         break;
00069         }       
00070         DBG_WARN(GWEN_LOGDOMAIN,
00071                          "Function is not appropriate for this type of widget (%s)",
00072                          GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
00073         return defaultValue;
00074 }
00075 
00076 
00077 
00078 static GWENHYWFAR_CB
00079 int CocoaGui_WHLayout_SetCharProperty(GWEN_WIDGET *w,
00080                                                                           GWEN_DIALOG_PROPERTY prop,
00081                                                                           int index,
00082                                                                           const char *value,
00083                                                                           int doSignal) {
00084         /*CocoaHLayout *hlayout;
00085         
00086         hlayout=(CocoaHLayout*)(GWEN_Widget_GetImplData(w, COCOA_DIALOG_WIDGET_REAL));
00087         assert(hlayout);*/
00088         
00089         DBG_WARN(GWEN_LOGDOMAIN,
00090                          "Function is not appropriate for this type of widget (%s)",
00091                          GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
00092         return GWEN_ERROR_INVALID;
00093 }
00094 
00095 
00096 
00097 static GWENHYWFAR_CB
00098 const char* CocoaGui_WHLayout_GetCharProperty(GWEN_WIDGET *w,
00099                                                                                           GWEN_DIALOG_PROPERTY prop,
00100                                                                                           int index,
00101                                                                                           const char *defaultValue) {
00102         /*CocoaHLayout *hlayout;
00103         
00104         hlayout=(CocoaHLayout*)(GWEN_Widget_GetImplData(w, COCOA_DIALOG_WIDGET_REAL));
00105         assert(hlayout);*/
00106         
00107         DBG_WARN(GWEN_LOGDOMAIN,
00108                          "Function is not appropriate for this type of widget (%s)",
00109                          GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
00110         return defaultValue;
00111 }
00112 
00113 
00114 
00115 static GWENHYWFAR_CB
00116 int CocoaGui_WHLayout_AddChildGuiWidget(GWEN_WIDGET *w, GWEN_WIDGET *wChild) {
00117         CocoaHLayout *hlayout;
00118         NSView *childView;
00119         uint32_t cflags;
00120         
00121         hlayout=(CocoaHLayout*)(GWEN_Widget_GetImplData(w, COCOA_DIALOG_WIDGET_REAL));
00122         assert(hlayout);
00123         
00124         childView=(NSView*)(GWEN_Widget_GetImplData(wChild, COCOA_DIALOG_WIDGET_REAL));
00125         assert(childView);
00126         
00127         cflags=GWEN_Widget_GetFlags(wChild);
00128         
00129         [hlayout addLayoutSubview:childView];
00130         
00131         /*gtk_box_pack_start(GTK_BOX(g), gChild,
00132                                            (cflags & GWEN_WIDGET_FLAGS_FILLX)?TRUE:FALSE,
00133                                            (cflags & GWEN_WIDGET_FLAGS_FILLX)?TRUE:FALSE,
00134                                            0);*/
00135         
00136         return 0;
00137 }
00138 
00139 
00140 
00141 int CocoaGui_WHLayout_Setup(GWEN_WIDGET *w) {
00142         CocoaHLayout *hlayout;
00143         uint32_t flags;
00144         GWEN_WIDGET *wParent;
00145         
00146         flags=GWEN_Widget_GetFlags(w);
00147         wParent=GWEN_Widget_Tree_GetParent(w);
00148         
00149         
00150         hlayout = [[[CocoaHLayout alloc] initWithFrame:NSMakeRect(10.0, 10.0, 200.0, 200.0)] autorelease];
00151         if (flags & GWEN_WIDGET_FLAGS_FILLX) hlayout.fillX = YES;
00152         if (flags & GWEN_WIDGET_FLAGS_FILLY) hlayout.fillY = YES;
00153         /*#if 0
00154          // using equal width here doesn't seem to be working as expected:
00155          // I would expect al children be of equal width, but instead all children are
00156          // equally distant to each other while still being of different width...
00157          //
00158          g=gtk_hbox_new((flags & GWEN_WIDGET_FLAGS_EQUAL_WIDTH)?TRUE:FALSE,
00159          GTK2_GUI_DIALOG_DEFAULT_BOX_SPACING);
00160          #else
00161          g=gtk_hbox_new(FALSE, GTK2_GUI_DIALOG_DEFAULT_BOX_SPACING);
00162          #endif*/
00163         GWEN_Widget_SetImplData(w, COCOA_DIALOG_WIDGET_REAL, (void*) hlayout);
00164         GWEN_Widget_SetImplData(w, COCOA_DIALOG_WIDGET_CONTENT, (void*) hlayout);
00165         
00166         GWEN_Widget_SetSetIntPropertyFn(w, CocoaGui_WHLayout_SetIntProperty);
00167         GWEN_Widget_SetGetIntPropertyFn(w, CocoaGui_WHLayout_GetIntProperty);
00168         GWEN_Widget_SetSetCharPropertyFn(w, CocoaGui_WHLayout_SetCharProperty);
00169         GWEN_Widget_SetGetCharPropertyFn(w, CocoaGui_WHLayout_GetCharProperty);
00170         GWEN_Widget_SetAddChildGuiWidgetFn(w, CocoaGui_WHLayout_AddChildGuiWidget);
00171         
00172         if (wParent)
00173                 GWEN_Widget_AddChildGuiWidget(wParent, w);
00174         
00175         return 0;
00176 }
00177 
00178