Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 static GWENHYWFAR_CB
00023 int CocoaGui_WStack_SetIntProperty(GWEN_WIDGET *w,
00024 GWEN_DIALOG_PROPERTY prop,
00025 int index,
00026 int value,
00027 int doSignal) {
00028 CocoaTabView *stackView;
00029
00030 stackView=(CocoaTabView*)(GWEN_Widget_GetImplData(w, COCOA_DIALOG_WIDGET_REAL));
00031 assert(stackView);
00032
00033 switch(prop) {
00034 case GWEN_DialogProperty_Enabled:
00035 return 0;
00036
00037 case GWEN_DialogProperty_Focus:
00038 return 0;
00039
00040 case GWEN_DialogProperty_Width: {
00041 NSRect frame = [stackView frame];
00042 frame.size.width = value;
00043 [stackView setFrame:frame];
00044 }
00045 return 0;
00046
00047 case GWEN_DialogProperty_Height: {
00048 NSRect frame = [stackView frame];
00049 frame.size.height = value;
00050 [stackView setFrame:frame];
00051 }
00052 return 0;
00053
00054 case GWEN_DialogProperty_Value:
00055 if (value >= 0 && value < [stackView numberOfTabViewItems]) {
00056 [stackView selectTabViewItemAtIndex:value];
00057 }
00058 return 0;
00059
00060 default:
00061 break;
00062 }
00063
00064 DBG_WARN(GWEN_LOGDOMAIN,
00065 "Function is not appropriate for this type of widget (%s)",
00066 GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
00067 return GWEN_ERROR_INVALID;
00068 }
00069
00070
00071
00072
00073 static GWENHYWFAR_CB
00074 int CocoaGui_WStack_GetIntProperty(GWEN_WIDGET *w,
00075 GWEN_DIALOG_PROPERTY prop,
00076 int index,
00077 int defaultValue) {
00078 CocoaTabView *stackView;
00079
00080 stackView=(CocoaTabView*)(GWEN_Widget_GetImplData(w, COCOA_DIALOG_WIDGET_REAL));
00081 assert(stackView);
00082
00083 switch(prop) {
00084 case GWEN_DialogProperty_Enabled:
00085 return 1;
00086
00087 case GWEN_DialogProperty_Focus:
00088 return 0;
00089
00090 case GWEN_DialogProperty_Width:
00091 return [stackView frame].size.width;
00092
00093 case GWEN_DialogProperty_Height:
00094 return [stackView frame].size.height;
00095
00096 case GWEN_DialogProperty_Value:
00097 return [stackView indexOfTabViewItem:[stackView selectedTabViewItem]];
00098
00099 default:
00100 break;
00101 }
00102
00103 DBG_WARN(GWEN_LOGDOMAIN,
00104 "Function is not appropriate for this type of widget (%s)",
00105 GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
00106 return defaultValue;
00107 }
00108
00109
00110
00111 static GWENHYWFAR_CB
00112 int CocoaGui_WStack_SetCharProperty(GWEN_WIDGET *w,
00113 GWEN_DIALOG_PROPERTY prop,
00114 int index,
00115 const char *value,
00116 int doSignal) {
00117 CocoaTabView *stackView;
00118
00119 stackView=(CocoaTabView*)(GWEN_Widget_GetImplData(w, COCOA_DIALOG_WIDGET_REAL));
00120 assert(stackView);
00121
00122 DBG_WARN(GWEN_LOGDOMAIN,
00123 "Function is not appropriate for this type of widget (%s)",
00124 GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
00125 return GWEN_ERROR_INVALID;
00126 }
00127
00128
00129
00130 static GWENHYWFAR_CB
00131 const char* CocoaGui_WStack_GetCharProperty(GWEN_WIDGET *w,
00132 GWEN_DIALOG_PROPERTY prop,
00133 int index,
00134 const char *defaultValue) {
00135 CocoaTabView *stackView;
00136
00137 stackView=(CocoaTabView*)(GWEN_Widget_GetImplData(w, COCOA_DIALOG_WIDGET_REAL));
00138 assert(stackView);
00139
00140 DBG_WARN(GWEN_LOGDOMAIN,
00141 "Function is not appropriate for this type of widget (%s)",
00142 GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
00143 return defaultValue;
00144 }
00145
00146
00147
00148 static GWENHYWFAR_CB
00149 int CocoaGui_WStack_AddChildGuiWidget(GWEN_WIDGET *w, GWEN_WIDGET *wChild) {
00150 CocoaTabView *stackView;
00151
00152 stackView=(CocoaTabView*)(GWEN_Widget_GetImplData(w, COCOA_DIALOG_WIDGET_REAL));
00153 assert(stackView);
00154
00155 NSView *subview =(NSView*)(GWEN_Widget_GetImplData(wChild, COCOA_DIALOG_WIDGET_REAL));
00156 assert(subview);
00157
00158 NSTabViewItem *item = [[NSTabViewItem alloc] init];
00159
00160 [item setView:subview];
00161
00162 [stackView addTabViewItem:item];
00163 [item release];
00164
00165 return 0;
00166 }
00167
00168
00169
00170 int CocoaGui_WStack_Setup(GWEN_WIDGET *w) {
00171 CocoaTabView *stackView;
00172 uint32_t flags;
00173 GWEN_WIDGET *wParent;
00174
00175 flags=GWEN_Widget_GetFlags(w);
00176 wParent=GWEN_Widget_Tree_GetParent(w);
00177
00178 stackView = [[[CocoaTabView alloc] initWithFrame:NSMakeRect(0.0, 0.0, 100.0, 100.0)] autorelease];
00179 [stackView setTabViewType:NSNoTabsNoBorder];
00180 if (flags & GWEN_WIDGET_FLAGS_FILLX) stackView.fillX = YES;
00181 if (flags & GWEN_WIDGET_FLAGS_FILLY) stackView.fillY = YES;
00182
00183
00184 GWEN_Widget_SetImplData(w, COCOA_DIALOG_WIDGET_REAL, (void*) stackView);
00185 GWEN_Widget_SetImplData(w, COCOA_DIALOG_WIDGET_CONTENT, (void*) stackView);
00186
00187 GWEN_Widget_SetSetIntPropertyFn(w, CocoaGui_WStack_SetIntProperty);
00188 GWEN_Widget_SetGetIntPropertyFn(w, CocoaGui_WStack_GetIntProperty);
00189 GWEN_Widget_SetSetCharPropertyFn(w, CocoaGui_WStack_SetCharProperty);
00190 GWEN_Widget_SetGetCharPropertyFn(w, CocoaGui_WStack_GetCharProperty);
00191 GWEN_Widget_SetAddChildGuiWidgetFn(w, CocoaGui_WStack_AddChildGuiWidget);
00192
00193 if (wParent)
00194 GWEN_Widget_AddChildGuiWidget(wParent, w);
00195
00196 return 0;
00197 }
00198
00199