comparison mac/dw.c @ 418:4be57ee7e006

Fix a crash in dw_window_pointer when the window handle is HWND_DESKTOP.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Thu, 15 May 2003 04:03:03 +0000
parents 2e6c28ee4794
children 4fe2df53ec9f
comparison
equal deleted inserted replaced
417:4ae67c291a8a 418:4be57ee7e006
821 * flStyle: Style flags, see the PM reference. 821 * flStyle: Style flags, see the PM reference.
822 */ 822 */
823 HWND API dw_window_new(HWND hwndOwner, char *title, ULONG flStyle) 823 HWND API dw_window_new(HWND hwndOwner, char *title, ULONG flStyle)
824 { 824 {
825 HWND hwnd = 0; 825 HWND hwnd = 0;
826 826 CreateNewWindow (kDocumentWindowClass, flStyle,
827 &contentRect, &theWindow);
827 return hwnd; 828 return hwnd;
828 } 829 }
829 830
830 /* 831 /*
831 * Create a new Box to be packed. 832 * Create a new Box to be packed.
845 * pad: Number of pixels to pad around the box. 846 * pad: Number of pixels to pad around the box.
846 * title: Text to be displayined in the group outline. 847 * title: Text to be displayined in the group outline.
847 */ 848 */
848 HWND API dw_groupbox_new(int type, int pad, char *title) 849 HWND API dw_groupbox_new(int type, int pad, char *title)
849 { 850 {
850 return 0; 851 OSStatus CreateRadioGroupControl (
852 WindowRef window,
853 const Rect * boundsRect,
854 ControlRef * outControl
855 ); return 0;
851 } 856 }
852 857
853 /* 858 /*
854 * Create a new MDI Frame to be packed. 859 * Create a new MDI Frame to be packed.
855 * Parameters: 860 * Parameters:
865 * Parameters: 870 * Parameters:
866 * id: An ID to be used with dw_window_from_id() or 0L. 871 * id: An ID to be used with dw_window_from_id() or 0L.
867 */ 872 */
868 HWND API dw_bitmap_new(ULONG id) 873 HWND API dw_bitmap_new(ULONG id)
869 { 874 {
870 return 0; 875 OSStatus CreateImageWellControl (
876 WindowRef window,
877 const Rect * boundsRect,
878 const ControlButtonContentInfo * info,
879 ControlRef * outControl
880 ); return 0;
871 } 881 }
872 882
873 /* 883 /*
874 * Create a notebook object to be packed. 884 * Create a notebook object to be packed.
875 * Parameters: 885 * Parameters:
876 * id: An ID to be used for getting the resource from the 886 * id: An ID to be used for getting the resource from the
877 * resource file. 887 * resource file.
878 */ 888 */
879 HWND API dw_notebook_new(ULONG id, int top) 889 HWND API dw_notebook_new(ULONG id, int top)
880 { 890 {
881 return 0; 891 OSStatus CreateTabsControl (
892 WindowRef window,
893 const Rect * boundsRect,
894 ControlTabSize size,
895 ControlTabDirection direction,
896 UInt16 numTabs,
897 const ControlTabEntry * tabArray,
898 ControlRef * outControl
899 ); return 0;
882 } 900 }
883 901
884 /* 902 /*
885 * Create a menu object to be popped up. 903 * Create a menu object to be popped up.
886 * Parameters: 904 * Parameters:
999 * text: The text to be display by the static text widget. 1017 * text: The text to be display by the static text widget.
1000 * id: An ID to be used with dw_window_from_id() or 0L. 1018 * id: An ID to be used with dw_window_from_id() or 0L.
1001 */ 1019 */
1002 HWND API dw_text_new(char *text, ULONG id) 1020 HWND API dw_text_new(char *text, ULONG id)
1003 { 1021 {
1004 return 0; 1022 OSStatus CreateStaticTextControl (
1023 WindowRef window,
1024 const Rect * boundsRect,
1025 CFStringRef text,
1026 const ControlFontStyleRec * style,
1027 ControlRef * outControl
1028 ); return 0;
1005 } 1029 }
1006 1030
1007 /* 1031 /*
1008 * Create a new status text window (widget) to be packed. 1032 * Create a new status text window (widget) to be packed.
1009 * Parameters: 1033 * Parameters:
1010 * text: The text to be display by the static text widget. 1034 * text: The text to be display by the static text widget.
1011 * id: An ID to be used with dw_window_from_id() or 0L. 1035 * id: An ID to be used with dw_window_from_id() or 0L.
1012 */ 1036 */
1013 HWND API dw_status_text_new(char *text, ULONG id) 1037 HWND API dw_status_text_new(char *text, ULONG id)
1014 { 1038 {
1039 OSStatus CreateStaticTextControl (
1040 WindowRef window,
1041 const Rect * boundsRect,
1042 CFStringRef text,
1043 const ControlFontStyleRec * style,
1044 ControlRef * outControl
1015 return 0; 1045 return 0;
1016 } 1046 }
1017 1047
1018 /* 1048 /*
1019 * Create a new Multiline Editbox window (widget) to be packed. 1049 * Create a new Multiline Editbox window (widget) to be packed.
1020 * Parameters: 1050 * Parameters:
1021 * id: An ID to be used with dw_window_from_id() or 0L. 1051 * id: An ID to be used with dw_window_from_id() or 0L.
1022 */ 1052 */
1023 HWND API dw_mle_new(ULONG id) 1053 HWND API dw_mle_new(ULONG id)
1024 { 1054 {
1055 OSStatus CreateScrollingTextBoxControl (
1056 WindowRef window,
1057 const Rect * boundsRect,
1058 SInt16 contentResID,
1059 Boolean autoScroll,
1060 UInt32 delayBeforeAutoScroll,
1061 UInt32 delayBetweenAutoScroll,
1062 UInt16 autoScrollAmount,
1063 ControlRef * outControl
1064 );
1025 return 0; 1065 return 0;
1026 } 1066 }
1027 1067
1028 /* 1068 /*
1029 * Create a new Entryfield window (widget) to be packed. 1069 * Create a new Entryfield window (widget) to be packed.
1031 * text: The default text to be in the entryfield widget. 1071 * text: The default text to be in the entryfield widget.
1032 * id: An ID to be used with dw_window_from_id() or 0L. 1072 * id: An ID to be used with dw_window_from_id() or 0L.
1033 */ 1073 */
1034 HWND API dw_entryfield_new(char *text, ULONG id) 1074 HWND API dw_entryfield_new(char *text, ULONG id)
1035 { 1075 {
1036 1076 OSStatus CreateEditTextControl (
1037 return 0; 1077 WindowRef window,
1078 const Rect * boundsRect,
1079 CFStringRef text,
1080 Boolean isPassword,
1081 Boolean useInlineInput,
1082 const ControlFontStyleRec * style,
1083 ControlRef * outControl
1084 ); return 0;
1038 } 1085 }
1039 1086
1040 /* 1087 /*
1041 * Create a new Entryfield (password) window (widget) to be packed. 1088 * Create a new Entryfield (password) window (widget) to be packed.
1042 * Parameters: 1089 * Parameters:
1043 * text: The default text to be in the entryfield widget. 1090 * text: The default text to be in the entryfield widget.
1044 * id: An ID to be used with dw_window_from_id() or 0L. 1091 * id: An ID to be used with dw_window_from_id() or 0L.
1045 */ 1092 */
1046 HWND API dw_entryfield_password_new(char *text, ULONG id) 1093 HWND API dw_entryfield_password_new(char *text, ULONG id)
1047 { 1094 {
1095 OSStatus CreateEditTextControl (
1096 WindowRef window,
1097 const Rect * boundsRect,
1098 CFStringRef text,
1099 Boolean isPassword,
1100 Boolean useInlineInput,
1101 const ControlFontStyleRec * style,
1102 ControlRef * outControl
1048 return 0; 1103 return 0;
1049 } 1104 }
1050 1105
1051 /* 1106 /*
1052 * Create a new Combobox window (widget) to be packed. 1107 * Create a new Combobox window (widget) to be packed.
1065 * text: The text to be display by the static text widget. 1120 * text: The text to be display by the static text widget.
1066 * id: An ID to be used with dw_window_from_id() or 0L. 1121 * id: An ID to be used with dw_window_from_id() or 0L.
1067 */ 1122 */
1068 HWND API dw_button_new(char *text, ULONG id) 1123 HWND API dw_button_new(char *text, ULONG id)
1069 { 1124 {
1070 return 0; 1125 OSStatus CreatePushButtonControl (
1126 WindowRef window,
1127 const Rect * boundsRect,
1128 CFStringRef title,
1129 ControlRef * outControl
1130 ); return 0;
1071 } 1131 }
1072 1132
1073 /* 1133 /*
1074 * Create a new bitmap button window (widget) to be packed. 1134 * Create a new bitmap button window (widget) to be packed.
1075 * Parameters: 1135 * Parameters:
1076 * text: Bubble help text to be displayed. 1136 * text: Bubble help text to be displayed.
1077 * id: An ID of a bitmap in the resource file. 1137 * id: An ID of a bitmap in the resource file.
1078 */ 1138 */
1079 HWND API dw_bitmapbutton_new(char *text, ULONG id) 1139 HWND API dw_bitmapbutton_new(char *text, ULONG id)
1080 { 1140 {
1081 return 0; 1141 OSStatus CreatePushButtonWithIconControl (
1142 WindowRef window,
1143 const Rect * boundsRect,
1144 CFStringRef title,
1145 ControlButtonContentInfo * icon,
1146 ControlPushButtonIconAlignment iconAlignment,
1147 ControlRef * outControl
1148 ); return 0;
1082 } 1149 }
1083 1150
1084 /* 1151 /*
1085 * Create a new bitmap button window (widget) to be packed from a file. 1152 * Create a new bitmap button window (widget) to be packed from a file.
1086 * Parameters: 1153 * Parameters:
1112 * text: The text to be display by the static text widget. 1179 * text: The text to be display by the static text widget.
1113 * id: An ID to be used with dw_window_from_id() or 0L. 1180 * id: An ID to be used with dw_window_from_id() or 0L.
1114 */ 1181 */
1115 HWND API dw_radiobutton_new(char *text, ULONG id) 1182 HWND API dw_radiobutton_new(char *text, ULONG id)
1116 { 1183 {
1184 OSStatus CreateRadioButtonControl (
1185 WindowRef window,
1186 const Rect * boundsRect,
1187 CFStringRef title,
1188 SInt32 initialValue,
1189 Boolean autoToggle,
1190 ControlRef * outControl
1191 );
1192
1193
1117 return 0; 1194 return 0;
1118 } 1195 }
1119 1196
1120 1197
1121 /* 1198 /*
1125 * increments: Number of increments available. 1202 * increments: Number of increments available.
1126 * id: An ID to be used with dw_window_from_id() or 0L. 1203 * id: An ID to be used with dw_window_from_id() or 0L.
1127 */ 1204 */
1128 HWND API dw_slider_new(int vertical, int increments, ULONG id) 1205 HWND API dw_slider_new(int vertical, int increments, ULONG id)
1129 { 1206 {
1130 return 0; 1207 OSStatus CreateSliderControl (
1208 WindowRef window,
1209 const Rect * boundsRect,
1210 SInt32 value,
1211 SInt32 minimum,
1212 SInt32 maximum,
1213 ControlSliderOrientation orientation,
1214 UInt16 numTickMarks,
1215 Boolean liveTracking,
1216 ControlActionUPP liveTrackingProc,
1217 ControlRef * outControl
1218 ); return 0;
1131 } 1219 }
1132 1220
1133 /* 1221 /*
1134 * Create a new scrollbar window (widget) to be packed. 1222 * Create a new scrollbar window (widget) to be packed.
1135 * Parameters: 1223 * Parameters:
1137 * increments: Number of increments available. 1225 * increments: Number of increments available.
1138 * id: An ID to be used with dw_window_from_id() or 0L. 1226 * id: An ID to be used with dw_window_from_id() or 0L.
1139 */ 1227 */
1140 HWND API dw_scrollbar_new(int vertical, int increments, ULONG id) 1228 HWND API dw_scrollbar_new(int vertical, int increments, ULONG id)
1141 { 1229 {
1142 return 0; 1230 OSStatus CreateScrollBarControl (
1231 WindowRef window,
1232 const Rect * boundsRect,
1233 SInt32 value,
1234 SInt32 minimum,
1235 SInt32 maximum,
1236 SInt32 viewSize,
1237 Boolean liveTracking,
1238 ControlActionUPP liveTrackingProc,
1239 ControlRef * outControl
1240 ); return 0;
1143 } 1241 }
1144 1242
1145 /* 1243 /*
1146 * Create a new percent bar window (widget) to be packed. 1244 * Create a new percent bar window (widget) to be packed.
1147 * Parameters: 1245 * Parameters:
1148 * id: An ID to be used with dw_window_from_id() or 0L. 1246 * id: An ID to be used with dw_window_from_id() or 0L.
1149 */ 1247 */
1150 HWND API dw_percent_new(ULONG id) 1248 HWND API dw_percent_new(ULONG id)
1151 { 1249 {
1152 return 0; 1250 OSStatus CreateProgressBarControl (
1251 WindowRef window,
1252 const Rect * boundsRect,
1253 SInt32 value,
1254 SInt32 minimum,
1255 SInt32 maximum,
1256 Boolean indeterminate,
1257 ControlRef * outControl
1258 ); return 0;
1153 } 1259 }
1154 1260
1155 /* 1261 /*
1156 * Create a new checkbox window (widget) to be packed. 1262 * Create a new checkbox window (widget) to be packed.
1157 * Parameters: 1263 * Parameters:
1158 * text: The text to be display by the static text widget. 1264 * text: The text to be display by the static text widget.
1159 * id: An ID to be used with dw_window_from_id() or 0L. 1265 * id: An ID to be used with dw_window_from_id() or 0L.
1160 */ 1266 */
1161 HWND API dw_checkbox_new(char *text, ULONG id) 1267 HWND API dw_checkbox_new(char *text, ULONG id)
1162 { 1268 {
1163 return 0; 1269 OSStatus CreateCheckBoxControl (
1270 WindowRef window,
1271 const Rect * boundsRect,
1272 CFStringRef title,
1273 SInt32 initialValue,
1274 Boolean autoToggle,
1275 ControlRef * outControl
1276 ); return 0;
1164 } 1277 }
1165 1278
1166 /* 1279 /*
1167 * Create a new listbox window (widget) to be packed. 1280 * Create a new listbox window (widget) to be packed.
1168 * Parameters: 1281 * Parameters:
1169 * id: An ID to be used with dw_window_from_id() or 0L. 1282 * id: An ID to be used with dw_window_from_id() or 0L.
1170 * multi: Multiple select TRUE or FALSE. 1283 * multi: Multiple select TRUE or FALSE.
1171 */ 1284 */
1172 HWND API dw_listbox_new(ULONG id, int multi) 1285 HWND API dw_listbox_new(ULONG id, int multi)
1173 { 1286 {
1174 return 0; 1287 OSStatus CreateListBoxControl (
1288 WindowRef window,
1289 const Rect * boundsRect,
1290 Boolean autoSize,
1291 SInt16 numRows,
1292 SInt16 numColumns,
1293 Boolean horizScroll,
1294 Boolean vertScroll,
1295 SInt16 cellHeight,
1296 SInt16 cellWidth,
1297 Boolean hasGrowSpace,
1298 const ListDefSpec * listDef,
1299 ControlRef * outControl
1300 ); return 0;
1175 } 1301 }
1176 1302
1177 /* 1303 /*
1178 * Sets the icon used for a given window. 1304 * Sets the icon used for a given window.
1179 * Parameters: 1305 * Parameters:
1204 * handle: Handle to the window. 1330 * handle: Handle to the window.
1205 * text: The text associsated with a given window. 1331 * text: The text associsated with a given window.
1206 */ 1332 */
1207 void API dw_window_set_text(HWND handle, char *text) 1333 void API dw_window_set_text(HWND handle, char *text)
1208 { 1334 {
1335 SetControlTitleWithCFString(handle, text);
1209 } 1336 }
1210 1337
1211 /* 1338 /*
1212 * Gets the text used for a given window. 1339 * Gets the text used for a given window.
1213 * Parameters: 1340 * Parameters:
1225 * Parameters: 1352 * Parameters:
1226 * handle: Handle to the window. 1353 * handle: Handle to the window.
1227 */ 1354 */
1228 void API dw_window_disable(HWND handle) 1355 void API dw_window_disable(HWND handle)
1229 { 1356 {
1357 DisableControl(handle);
1230 } 1358 }
1231 1359
1232 /* 1360 /*
1233 * Enables given window (widget). 1361 * Enables given window (widget).
1234 * Parameters: 1362 * Parameters:
1235 * handle: Handle to the window. 1363 * handle: Handle to the window.
1236 */ 1364 */
1237 void API dw_window_enable(HWND handle) 1365 void API dw_window_enable(HWND handle)
1238 { 1366 {
1367 EnableControl(handle);
1239 } 1368 }
1240 1369
1241 /* 1370 /*
1242 * Gets the child window handle with specified ID. 1371 * Gets the child window handle with specified ID.
1243 * Parameters: 1372 * Parameters:
1244 * handle: Handle to the parent window. 1373 * handle: Handle to the parent window.
1245 * id: Integer ID of the child. 1374 * id: Integer ID of the child.
1246 */ 1375 */
1247 HWND API dw_window_from_id(HWND handle, int id) 1376 HWND API dw_window_from_id(HWND handle, int id)
1248 { 1377 {
1378 HWND ret;
1379
1380 ControlID cid = (ControlID)id;
1381 GetControlByID(handle, &cid, &ret);
1382 return ret;
1383 );
1384
1385
1249 return 0; 1386 return 0;
1250 } 1387 }
1251 1388
1252 /* 1389 /*
1253 * Pack windows (widgets) into a box from the end (or bottom). 1390 * Pack windows (widgets) into a box from the end (or bottom).
2772 { 2909 {
2773 if(!dataname) 2910 if(!dataname)
2774 return; 2911 return;
2775 2912
2776 blah = calloc(1, sizeof(WindowData)); 2913 blah = calloc(1, sizeof(WindowData));
2777 WinSetWindowPtr(window, QWP_USER, blah); 2914 SetWindowProperty(window, QWP_USER, blah);
2778 } 2915 }
2779 2916
2780 if(data) 2917 if(data)
2781 _new_userdata(&(blah->root), dataname, data); 2918 _new_userdata(&(blah->root), dataname, data);
2782 else 2919 else