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