Mercurial > dwindows
comparison os2/dw.c @ 174:75bf3051235f
Fixes so you can mix compilers.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Sun, 01 Dec 2002 12:59:24 +0000 |
parents | 0fc45e386376 |
children | d78d08440246 |
comparison
equal
deleted
inserted
replaced
173:c2b5d0019ec3 | 174:75bf3051235f |
---|---|
2932 * Initializes the Dynamic Windows engine. | 2932 * Initializes the Dynamic Windows engine. |
2933 * Parameters: | 2933 * Parameters: |
2934 * newthread: True if this is the only thread. | 2934 * newthread: True if this is the only thread. |
2935 * False if there is already a message loop running. | 2935 * False if there is already a message loop running. |
2936 */ | 2936 */ |
2937 int dw_init(int newthread, int argc, char *argv[]) | 2937 int API dw_init(int newthread, int argc, char *argv[]) |
2938 { | 2938 { |
2939 APIRET rc; | 2939 APIRET rc; |
2940 | 2940 |
2941 if(newthread) | 2941 if(newthread) |
2942 { | 2942 { |
2954 } | 2954 } |
2955 | 2955 |
2956 /* | 2956 /* |
2957 * Runs a message loop for Dynamic Windows. | 2957 * Runs a message loop for Dynamic Windows. |
2958 */ | 2958 */ |
2959 void dw_main(void) | 2959 void API dw_main(void) |
2960 { | 2960 { |
2961 QMSG qmsg; | 2961 QMSG qmsg; |
2962 | 2962 |
2963 _dwtid = dw_thread_id(); | 2963 _dwtid = dw_thread_id(); |
2964 | 2964 |
2972 /* | 2972 /* |
2973 * Runs a message loop for Dynamic Windows, for a period of milliseconds. | 2973 * Runs a message loop for Dynamic Windows, for a period of milliseconds. |
2974 * Parameters: | 2974 * Parameters: |
2975 * milliseconds: Number of milliseconds to run the loop for. | 2975 * milliseconds: Number of milliseconds to run the loop for. |
2976 */ | 2976 */ |
2977 void dw_main_sleep(int milliseconds) | 2977 void API dw_main_sleep(int milliseconds) |
2978 { | 2978 { |
2979 QMSG qmsg; | 2979 QMSG qmsg; |
2980 double start = (double)clock(); | 2980 double start = (double)clock(); |
2981 | 2981 |
2982 while(((clock() - start) / (CLOCKS_PER_SEC/1000)) <= milliseconds) | 2982 while(((clock() - start) / (CLOCKS_PER_SEC/1000)) <= milliseconds) |
2995 * Free's memory allocated by dynamic windows. | 2995 * Free's memory allocated by dynamic windows. |
2996 * Parameters: | 2996 * Parameters: |
2997 * ptr: Pointer to dynamic windows allocated | 2997 * ptr: Pointer to dynamic windows allocated |
2998 * memory to be free()'d. | 2998 * memory to be free()'d. |
2999 */ | 2999 */ |
3000 void dw_free(void *ptr) | 3000 void API dw_free(void *ptr) |
3001 { | 3001 { |
3002 free(ptr); | 3002 free(ptr); |
3003 } | 3003 } |
3004 | 3004 |
3005 /* | 3005 /* |
3006 * Allocates and initializes a dialog struct. | 3006 * Allocates and initializes a dialog struct. |
3007 * Parameters: | 3007 * Parameters: |
3008 * data: User defined data to be passed to functions. | 3008 * data: User defined data to be passed to functions. |
3009 */ | 3009 */ |
3010 DWDialog *dw_dialog_new(void *data) | 3010 DWDialog * API dw_dialog_new(void *data) |
3011 { | 3011 { |
3012 DWDialog *tmp = malloc(sizeof(DWDialog)); | 3012 DWDialog *tmp = malloc(sizeof(DWDialog)); |
3013 | 3013 |
3014 tmp->eve = dw_event_new(); | 3014 tmp->eve = dw_event_new(); |
3015 dw_event_reset(tmp->eve); | 3015 dw_event_reset(tmp->eve); |
3025 * initial called of dw_dialog_wait(). | 3025 * initial called of dw_dialog_wait(). |
3026 * Parameters: | 3026 * Parameters: |
3027 * dialog: Pointer to a dialog struct aquired by dw_dialog_new). | 3027 * dialog: Pointer to a dialog struct aquired by dw_dialog_new). |
3028 * result: Data to be returned by dw_dialog_wait(). | 3028 * result: Data to be returned by dw_dialog_wait(). |
3029 */ | 3029 */ |
3030 int dw_dialog_dismiss(DWDialog *dialog, void *result) | 3030 int API dw_dialog_dismiss(DWDialog *dialog, void *result) |
3031 { | 3031 { |
3032 dialog->result = result; | 3032 dialog->result = result; |
3033 dw_event_post(dialog->eve); | 3033 dw_event_post(dialog->eve); |
3034 dialog->done = TRUE; | 3034 dialog->done = TRUE; |
3035 return 0; | 3035 return 0; |
3039 * Accepts a dialog struct waits for dw_dialog_dismiss() to be | 3039 * Accepts a dialog struct waits for dw_dialog_dismiss() to be |
3040 * called by a signal handler with the given dialog struct. | 3040 * called by a signal handler with the given dialog struct. |
3041 * Parameters: | 3041 * Parameters: |
3042 * dialog: Pointer to a dialog struct aquired by dw_dialog_new). | 3042 * dialog: Pointer to a dialog struct aquired by dw_dialog_new). |
3043 */ | 3043 */ |
3044 void *dw_dialog_wait(DWDialog *dialog) | 3044 void * API dw_dialog_wait(DWDialog *dialog) |
3045 { | 3045 { |
3046 QMSG qmsg; | 3046 QMSG qmsg; |
3047 void *tmp; | 3047 void *tmp; |
3048 | 3048 |
3049 while (WinGetMsg(dwhab, &qmsg, 0, 0, 0)) | 3049 while (WinGetMsg(dwhab, &qmsg, 0, 0, 0)) |
3064 * Parameters: | 3064 * Parameters: |
3065 * title: The title of the message box. | 3065 * title: The title of the message box. |
3066 * format: printf style format string. | 3066 * format: printf style format string. |
3067 * ...: Additional variables for use in the format. | 3067 * ...: Additional variables for use in the format. |
3068 */ | 3068 */ |
3069 int dw_messagebox(char *title, char *format, ...) | 3069 int API dw_messagebox(char *title, char *format, ...) |
3070 { | 3070 { |
3071 va_list args; | 3071 va_list args; |
3072 char outbuf[1024]; | 3072 char outbuf[1024]; |
3073 | 3073 |
3074 va_start(args, format); | 3074 va_start(args, format); |
3086 * title: The title of the message box. | 3086 * title: The title of the message box. |
3087 * text: The text to display in the box. | 3087 * text: The text to display in the box. |
3088 * Returns: | 3088 * Returns: |
3089 * True if YES False of NO. | 3089 * True if YES False of NO. |
3090 */ | 3090 */ |
3091 int dw_yesno(char *title, char *text) | 3091 int API dw_yesno(char *title, char *text) |
3092 { | 3092 { |
3093 if(WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, text, title, 0, MB_YESNO | MB_INFORMATION | MB_MOVEABLE | MB_SYSTEMMODAL)==MBID_YES) | 3093 if(WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, text, title, 0, MB_YESNO | MB_INFORMATION | MB_MOVEABLE | MB_SYSTEMMODAL)==MBID_YES) |
3094 return TRUE; | 3094 return TRUE; |
3095 return FALSE; | 3095 return FALSE; |
3096 } | 3096 } |
3098 /* | 3098 /* |
3099 * Makes the window topmost. | 3099 * Makes the window topmost. |
3100 * Parameters: | 3100 * Parameters: |
3101 * handle: The window handle to make topmost. | 3101 * handle: The window handle to make topmost. |
3102 */ | 3102 */ |
3103 int dw_window_raise(HWND handle) | 3103 int API dw_window_raise(HWND handle) |
3104 { | 3104 { |
3105 return WinSetWindowPos(handle, HWND_TOP, 0, 0, 0, 0, SWP_ZORDER); | 3105 return WinSetWindowPos(handle, HWND_TOP, 0, 0, 0, 0, SWP_ZORDER); |
3106 } | 3106 } |
3107 | 3107 |
3108 /* | 3108 /* |
3109 * Makes the window bottommost. | 3109 * Makes the window bottommost. |
3110 * Parameters: | 3110 * Parameters: |
3111 * handle: The window handle to make bottommost. | 3111 * handle: The window handle to make bottommost. |
3112 */ | 3112 */ |
3113 int dw_window_lower(HWND handle) | 3113 int API dw_window_lower(HWND handle) |
3114 { | 3114 { |
3115 return WinSetWindowPos(handle, HWND_BOTTOM, 0, 0, 0, 0, SWP_ZORDER); | 3115 return WinSetWindowPos(handle, HWND_BOTTOM, 0, 0, 0, 0, SWP_ZORDER); |
3116 } | 3116 } |
3117 | 3117 |
3118 /* | 3118 /* |
3119 * Makes the window visible. | 3119 * Makes the window visible. |
3120 * Parameters: | 3120 * Parameters: |
3121 * handle: The window handle to make visible. | 3121 * handle: The window handle to make visible. |
3122 */ | 3122 */ |
3123 int dw_window_show(HWND handle) | 3123 int API dw_window_show(HWND handle) |
3124 { | 3124 { |
3125 int rc = WinSetWindowPos(handle, NULLHANDLE, 0, 0, 0, 0, SWP_SHOW); | 3125 int rc = WinSetWindowPos(handle, NULLHANDLE, 0, 0, 0, 0, SWP_SHOW); |
3126 HSWITCH hswitch; | 3126 HSWITCH hswitch; |
3127 SWCNTRL swcntrl; | 3127 SWCNTRL swcntrl; |
3128 | 3128 |
3175 /* | 3175 /* |
3176 * Minimizes or Iconifies a top-level window. | 3176 * Minimizes or Iconifies a top-level window. |
3177 * Parameters: | 3177 * Parameters: |
3178 * handle: The window handle to minimize. | 3178 * handle: The window handle to minimize. |
3179 */ | 3179 */ |
3180 int dw_window_minimize(HWND handle) | 3180 int API dw_window_minimize(HWND handle) |
3181 { | 3181 { |
3182 HWND hwndclient = WinWindowFromID(handle, FID_CLIENT); | 3182 HWND hwndclient = WinWindowFromID(handle, FID_CLIENT); |
3183 | 3183 |
3184 if(hwndclient) | 3184 if(hwndclient) |
3185 { | 3185 { |
3198 /* | 3198 /* |
3199 * Makes the window invisible. | 3199 * Makes the window invisible. |
3200 * Parameters: | 3200 * Parameters: |
3201 * handle: The window handle to make visible. | 3201 * handle: The window handle to make visible. |
3202 */ | 3202 */ |
3203 int dw_window_hide(HWND handle) | 3203 int API dw_window_hide(HWND handle) |
3204 { | 3204 { |
3205 HSWITCH hswitch; | 3205 HSWITCH hswitch; |
3206 SWCNTRL swcntrl; | 3206 SWCNTRL swcntrl; |
3207 | 3207 |
3208 /* If this window has a switch list entry make sure it is invisible */ | 3208 /* If this window has a switch list entry make sure it is invisible */ |
3219 /* | 3219 /* |
3220 * Destroys a window and all of it's children. | 3220 * Destroys a window and all of it's children. |
3221 * Parameters: | 3221 * Parameters: |
3222 * handle: The window handle to destroy. | 3222 * handle: The window handle to destroy. |
3223 */ | 3223 */ |
3224 int dw_window_destroy(HWND handle) | 3224 int API dw_window_destroy(HWND handle) |
3225 { | 3225 { |
3226 HWND parent = WinQueryWindow(handle, QW_PARENT); | 3226 HWND parent = WinQueryWindow(handle, QW_PARENT); |
3227 Box *thisbox = WinQueryWindowPtr(parent, QWP_USER); | 3227 Box *thisbox = WinQueryWindowPtr(parent, QWP_USER); |
3228 | 3228 |
3229 if(!handle) | 3229 if(!handle) |
3265 | 3265 |
3266 /* Causes entire window to be invalidated and redrawn. | 3266 /* Causes entire window to be invalidated and redrawn. |
3267 * Parameters: | 3267 * Parameters: |
3268 * handle: Toplevel window handle to be redrawn. | 3268 * handle: Toplevel window handle to be redrawn. |
3269 */ | 3269 */ |
3270 void dw_window_redraw(HWND handle) | 3270 void API dw_window_redraw(HWND handle) |
3271 { | 3271 { |
3272 HWND client = WinWindowFromID(handle, FID_CLIENT); | 3272 HWND client = WinWindowFromID(handle, FID_CLIENT); |
3273 HWND window = client ? client : handle; | 3273 HWND window = client ? client : handle; |
3274 Box *mybox = (Box *)WinQueryWindowPtr(window, QWP_USER); | 3274 Box *mybox = (Box *)WinQueryWindowPtr(window, QWP_USER); |
3275 | 3275 |
3289 * Changes a window's parent to newparent. | 3289 * Changes a window's parent to newparent. |
3290 * Parameters: | 3290 * Parameters: |
3291 * handle: The window handle to destroy. | 3291 * handle: The window handle to destroy. |
3292 * newparent: The window's new parent window. | 3292 * newparent: The window's new parent window. |
3293 */ | 3293 */ |
3294 void dw_window_reparent(HWND handle, HWND newparent) | 3294 void API dw_window_reparent(HWND handle, HWND newparent) |
3295 { | 3295 { |
3296 HWND blah = WinWindowFromID(newparent, FID_CLIENT); | 3296 HWND blah = WinWindowFromID(newparent, FID_CLIENT); |
3297 WinSetParent(handle, blah ? blah : newparent, TRUE); | 3297 WinSetParent(handle, blah ? blah : newparent, TRUE); |
3298 } | 3298 } |
3299 | 3299 |
3301 * Sets the font used by a specified window (widget) handle. | 3301 * Sets the font used by a specified window (widget) handle. |
3302 * Parameters: | 3302 * Parameters: |
3303 * handle: The window (widget) handle. | 3303 * handle: The window (widget) handle. |
3304 * fontname: Name and size of the font in the form "size.fontname" | 3304 * fontname: Name and size of the font in the form "size.fontname" |
3305 */ | 3305 */ |
3306 int dw_window_set_font(HWND handle, char *fontname) | 3306 int API dw_window_set_font(HWND handle, char *fontname) |
3307 { | 3307 { |
3308 return WinSetPresParam(handle, PP_FONTNAMESIZE, strlen(fontname)+1, fontname); | 3308 return WinSetPresParam(handle, PP_FONTNAMESIZE, strlen(fontname)+1, fontname); |
3309 } | 3309 } |
3310 | 3310 |
3311 /* Internal version */ | 3311 /* Internal version */ |
3360 * Parameters: | 3360 * Parameters: |
3361 * handle: The window (widget) handle. | 3361 * handle: The window (widget) handle. |
3362 * fore: Foreground color in DW_RGB format or a default color index. | 3362 * fore: Foreground color in DW_RGB format or a default color index. |
3363 * back: Background color in DW_RGB format or a default color index. | 3363 * back: Background color in DW_RGB format or a default color index. |
3364 */ | 3364 */ |
3365 int dw_window_set_color(HWND handle, ULONG fore, ULONG back) | 3365 int API dw_window_set_color(HWND handle, ULONG fore, ULONG back) |
3366 { | 3366 { |
3367 dw_window_set_data(handle, "_dw_fore", (void *)fore); | 3367 dw_window_set_data(handle, "_dw_fore", (void *)fore); |
3368 dw_window_set_data(handle, "_dw_back", (void *)back); | 3368 dw_window_set_data(handle, "_dw_back", (void *)back); |
3369 | 3369 |
3370 return _dw_window_set_color(handle, fore, back); | 3370 return _dw_window_set_color(handle, fore, back); |
3374 * Sets the font used by a specified window (widget) handle. | 3374 * Sets the font used by a specified window (widget) handle. |
3375 * Parameters: | 3375 * Parameters: |
3376 * handle: The window (widget) handle. | 3376 * handle: The window (widget) handle. |
3377 * border: Size of the window border in pixels. | 3377 * border: Size of the window border in pixels. |
3378 */ | 3378 */ |
3379 int dw_window_set_border(HWND handle, int border) | 3379 int API dw_window_set_border(HWND handle, int border) |
3380 { | 3380 { |
3381 WinSendMsg(handle, WM_SETBORDERSIZE, MPFROMSHORT(border), MPFROMSHORT(border)); | 3381 WinSendMsg(handle, WM_SETBORDERSIZE, MPFROMSHORT(border), MPFROMSHORT(border)); |
3382 return 0; | 3382 return 0; |
3383 } | 3383 } |
3384 | 3384 |
3385 /* | 3385 /* |
3386 * Captures the mouse input to this window. | 3386 * Captures the mouse input to this window. |
3387 * Parameters: | 3387 * Parameters: |
3388 * handle: Handle to receive mouse input. | 3388 * handle: Handle to receive mouse input. |
3389 */ | 3389 */ |
3390 void dw_window_capture(HWND handle) | 3390 void API dw_window_capture(HWND handle) |
3391 { | 3391 { |
3392 WinSetCapture(HWND_DESKTOP, handle); | 3392 WinSetCapture(HWND_DESKTOP, handle); |
3393 } | 3393 } |
3394 | 3394 |
3395 /* | 3395 /* |
3396 * Releases previous mouse capture. | 3396 * Releases previous mouse capture. |
3397 */ | 3397 */ |
3398 void dw_window_release(void) | 3398 void API dw_window_release(void) |
3399 { | 3399 { |
3400 WinSetCapture(HWND_DESKTOP, NULLHANDLE); | 3400 WinSetCapture(HWND_DESKTOP, NULLHANDLE); |
3401 } | 3401 } |
3402 | 3402 |
3403 /* | 3403 /* |
3404 * Tracks this window movement. | 3404 * Tracks this window movement. |
3405 * Parameters: | 3405 * Parameters: |
3406 * handle: Handle to frame to be tracked. | 3406 * handle: Handle to frame to be tracked. |
3407 */ | 3407 */ |
3408 void dw_window_track(HWND handle) | 3408 void API dw_window_track(HWND handle) |
3409 { | 3409 { |
3410 WinSendMsg(handle, WM_TRACKFRAME, MPFROMSHORT(TF_MOVE), 0); | 3410 WinSendMsg(handle, WM_TRACKFRAME, MPFROMSHORT(TF_MOVE), 0); |
3411 } | 3411 } |
3412 | 3412 |
3413 /* | 3413 /* |
3414 * Changes the appearance of the mouse pointer. | 3414 * Changes the appearance of the mouse pointer. |
3415 * Parameters: | 3415 * Parameters: |
3416 * handle: Handle to widget for which to change. | 3416 * handle: Handle to widget for which to change. |
3417 * cursortype: ID of the pointer you want. | 3417 * cursortype: ID of the pointer you want. |
3418 */ | 3418 */ |
3419 void dw_window_pointer(HWND handle, int pointertype) | 3419 void API dw_window_pointer(HWND handle, int pointertype) |
3420 { | 3420 { |
3421 WinSetPointer(handle, | 3421 WinSetPointer(handle, |
3422 WinQuerySysPointer(HWND_DESKTOP, | 3422 WinQuerySysPointer(HWND_DESKTOP, |
3423 pointertype, | 3423 pointertype, |
3424 FALSE)); | 3424 FALSE)); |
3429 * Parameters: | 3429 * Parameters: |
3430 * owner: The Owner's window handle or HWND_DESKTOP. | 3430 * owner: The Owner's window handle or HWND_DESKTOP. |
3431 * title: The Window title. | 3431 * title: The Window title. |
3432 * flStyle: Style flags, see the PM reference. | 3432 * flStyle: Style flags, see the PM reference. |
3433 */ | 3433 */ |
3434 HWND dw_window_new(HWND hwndOwner, char *title, ULONG flStyle) | 3434 HWND API dw_window_new(HWND hwndOwner, char *title, ULONG flStyle) |
3435 { | 3435 { |
3436 HWND hwndclient = 0, hwndframe; | 3436 HWND hwndclient = 0, hwndframe; |
3437 Box *newbox = calloc(1, sizeof(Box)); | 3437 Box *newbox = calloc(1, sizeof(Box)); |
3438 WindowData *blah = calloc(1, sizeof(WindowData)); | 3438 WindowData *blah = calloc(1, sizeof(WindowData)); |
3439 | 3439 |
3466 * Create a new Box to be packed. | 3466 * Create a new Box to be packed. |
3467 * Parameters: | 3467 * Parameters: |
3468 * type: Either BOXVERT (vertical) or BOXHORZ (horizontal). | 3468 * type: Either BOXVERT (vertical) or BOXHORZ (horizontal). |
3469 * pad: Number of pixels to pad around the box. | 3469 * pad: Number of pixels to pad around the box. |
3470 */ | 3470 */ |
3471 HWND dw_box_new(int type, int pad) | 3471 HWND API dw_box_new(int type, int pad) |
3472 { | 3472 { |
3473 Box *newbox = calloc(1, sizeof(Box)); | 3473 Box *newbox = calloc(1, sizeof(Box)); |
3474 HWND hwndframe; | 3474 HWND hwndframe; |
3475 | 3475 |
3476 newbox->pad = pad; | 3476 newbox->pad = pad; |
3501 * Parameters: | 3501 * Parameters: |
3502 * type: Either BOXVERT (vertical) or BOXHORZ (horizontal). | 3502 * type: Either BOXVERT (vertical) or BOXHORZ (horizontal). |
3503 * pad: Number of pixels to pad around the box. | 3503 * pad: Number of pixels to pad around the box. |
3504 * title: Text to be displayined in the group outline. | 3504 * title: Text to be displayined in the group outline. |
3505 */ | 3505 */ |
3506 HWND dw_groupbox_new(int type, int pad, char *title) | 3506 HWND API dw_groupbox_new(int type, int pad, char *title) |
3507 { | 3507 { |
3508 Box *newbox = calloc(1, sizeof(Box)); | 3508 Box *newbox = calloc(1, sizeof(Box)); |
3509 HWND hwndframe; | 3509 HWND hwndframe; |
3510 | 3510 |
3511 newbox->pad = pad; | 3511 newbox->pad = pad; |
3546 /* | 3546 /* |
3547 * Create a new MDI Frame to be packed. | 3547 * Create a new MDI Frame to be packed. |
3548 * Parameters: | 3548 * Parameters: |
3549 * id: An ID to be used with dw_window_from_id or 0L. | 3549 * id: An ID to be used with dw_window_from_id or 0L. |
3550 */ | 3550 */ |
3551 HWND dw_mdi_new(unsigned long id) | 3551 HWND API dw_mdi_new(unsigned long id) |
3552 { | 3552 { |
3553 HWND hwndframe; | 3553 HWND hwndframe; |
3554 | 3554 |
3555 hwndframe = WinCreateWindow(HWND_OBJECT, | 3555 hwndframe = WinCreateWindow(HWND_OBJECT, |
3556 WC_FRAME, | 3556 WC_FRAME, |
3569 /* | 3569 /* |
3570 * Create a bitmap object to be packed. | 3570 * Create a bitmap object to be packed. |
3571 * Parameters: | 3571 * Parameters: |
3572 * id: An ID to be used with WinWindowFromID() or 0L. | 3572 * id: An ID to be used with WinWindowFromID() or 0L. |
3573 */ | 3573 */ |
3574 HWND dw_bitmap_new(ULONG id) | 3574 HWND API dw_bitmap_new(ULONG id) |
3575 { | 3575 { |
3576 return WinCreateWindow(HWND_OBJECT, | 3576 return WinCreateWindow(HWND_OBJECT, |
3577 WC_STATIC, | 3577 WC_STATIC, |
3578 NULL, | 3578 NULL, |
3579 WS_VISIBLE | SS_TEXT, | 3579 WS_VISIBLE | SS_TEXT, |
3589 * Create a notebook object to be packed. | 3589 * Create a notebook object to be packed. |
3590 * Parameters: | 3590 * Parameters: |
3591 * id: An ID to be used for getting the resource from the | 3591 * id: An ID to be used for getting the resource from the |
3592 * resource file. | 3592 * resource file. |
3593 */ | 3593 */ |
3594 HWND dw_notebook_new(ULONG id, int top) | 3594 HWND API dw_notebook_new(ULONG id, int top) |
3595 { | 3595 { |
3596 ULONG flags; | 3596 ULONG flags; |
3597 HWND tmp; | 3597 HWND tmp; |
3598 | 3598 |
3599 if(top) | 3599 if(top) |
3629 * Create a menu object to be popped up. | 3629 * Create a menu object to be popped up. |
3630 * Parameters: | 3630 * Parameters: |
3631 * id: An ID to be used for getting the resource from the | 3631 * id: An ID to be used for getting the resource from the |
3632 * resource file. | 3632 * resource file. |
3633 */ | 3633 */ |
3634 HMENUI dw_menu_new(ULONG id) | 3634 HMENUI API dw_menu_new(ULONG id) |
3635 { | 3635 { |
3636 HMENUI tmp = malloc(sizeof(struct _hmenui)); | 3636 HMENUI tmp = malloc(sizeof(struct _hmenui)); |
3637 | 3637 |
3638 if(!tmp) | 3638 if(!tmp) |
3639 return NULL; | 3639 return NULL; |
3654 /* | 3654 /* |
3655 * Create a menubar on a window. | 3655 * Create a menubar on a window. |
3656 * Parameters: | 3656 * Parameters: |
3657 * location: Handle of a window frame to be attached to. | 3657 * location: Handle of a window frame to be attached to. |
3658 */ | 3658 */ |
3659 HMENUI dw_menubar_new(HWND location) | 3659 HMENUI API dw_menubar_new(HWND location) |
3660 { | 3660 { |
3661 HMENUI tmp = malloc(sizeof(struct _hmenui)); | 3661 HMENUI tmp = malloc(sizeof(struct _hmenui)); |
3662 | 3662 |
3663 if(!tmp) | 3663 if(!tmp) |
3664 return NULL; | 3664 return NULL; |
3679 /* | 3679 /* |
3680 * Destroys a menu created with dw_menubar_new or dw_menu_new. | 3680 * Destroys a menu created with dw_menubar_new or dw_menu_new. |
3681 * Parameters: | 3681 * Parameters: |
3682 * menu: Handle of a menu. | 3682 * menu: Handle of a menu. |
3683 */ | 3683 */ |
3684 void dw_menu_destroy(HMENUI *menu) | 3684 void API dw_menu_destroy(HMENUI *menu) |
3685 { | 3685 { |
3686 if(menu && *menu) | 3686 if(menu && *menu) |
3687 { | 3687 { |
3688 WinDestroyWindow((*menu)->menu); | 3688 WinDestroyWindow((*menu)->menu); |
3689 free(*menu); | 3689 free(*menu); |
3700 * flags: Extended attributes to set on the menu. | 3700 * flags: Extended attributes to set on the menu. |
3701 * end: If TRUE memu is positioned at the end of the menu. | 3701 * end: If TRUE memu is positioned at the end of the menu. |
3702 * check: If TRUE menu is "check"able. | 3702 * check: If TRUE menu is "check"able. |
3703 * submenu: Handle to an existing menu to be a submenu or NULL. | 3703 * submenu: Handle to an existing menu to be a submenu or NULL. |
3704 */ | 3704 */ |
3705 HWND dw_menu_append_item(HMENUI menux, char *title, ULONG id, ULONG flags, int end, int check, HMENUI submenu) | 3705 HWND API dw_menu_append_item(HMENUI menux, char *title, ULONG id, ULONG flags, int end, int check, HMENUI submenu) |
3706 { | 3706 { |
3707 MENUITEM miSubMenu; | 3707 MENUITEM miSubMenu; |
3708 HWND menu; | 3708 HWND menu; |
3709 | 3709 |
3710 if(!menux) | 3710 if(!menux) |
3738 * Parameters: | 3738 * Parameters: |
3739 * menu: The handle the the existing menu. | 3739 * menu: The handle the the existing menu. |
3740 * id: Menuitem id. | 3740 * id: Menuitem id. |
3741 * check: TRUE for checked FALSE for not checked. | 3741 * check: TRUE for checked FALSE for not checked. |
3742 */ | 3742 */ |
3743 void dw_menu_item_set_check(HMENUI menux, unsigned long id, int check) | 3743 void API dw_menu_item_set_check(HMENUI menux, unsigned long id, int check) |
3744 { | 3744 { |
3745 HWND menu; | 3745 HWND menu; |
3746 | 3746 |
3747 if(!menux) | 3747 if(!menux) |
3748 return; | 3748 return; |
3763 * menu: The handle the the existing menu. | 3763 * menu: The handle the the existing menu. |
3764 * parent: Handle to the window initiating the popup. | 3764 * parent: Handle to the window initiating the popup. |
3765 * x: X coordinate. | 3765 * x: X coordinate. |
3766 * y: Y coordinate. | 3766 * y: Y coordinate. |
3767 */ | 3767 */ |
3768 void dw_menu_popup(HMENUI *menu, HWND parent, int x, int y) | 3768 void API dw_menu_popup(HMENUI *menu, HWND parent, int x, int y) |
3769 { | 3769 { |
3770 if(menu && *menu) | 3770 if(menu && *menu) |
3771 { | 3771 { |
3772 popup = parent; | 3772 popup = parent; |
3773 WinPopupMenu(HWND_DESKTOP, parent, (*menu)->menu, x, dw_screen_height() - y, 0, PU_KEYBOARD | PU_MOUSEBUTTON1 | PU_VCONSTRAIN | PU_HCONSTRAIN); | 3773 WinPopupMenu(HWND_DESKTOP, parent, (*menu)->menu, x, dw_screen_height() - y, 0, PU_KEYBOARD | PU_MOUSEBUTTON1 | PU_VCONSTRAIN | PU_HCONSTRAIN); |
3780 * Returns the current X and Y coordinates of the mouse pointer. | 3780 * Returns the current X and Y coordinates of the mouse pointer. |
3781 * Parameters: | 3781 * Parameters: |
3782 * x: Pointer to variable to store X coordinate. | 3782 * x: Pointer to variable to store X coordinate. |
3783 * y: Pointer to variable to store Y coordinate. | 3783 * y: Pointer to variable to store Y coordinate. |
3784 */ | 3784 */ |
3785 void dw_pointer_query_pos(long *x, long *y) | 3785 void API dw_pointer_query_pos(long *x, long *y) |
3786 { | 3786 { |
3787 POINTL ptl; | 3787 POINTL ptl; |
3788 | 3788 |
3789 WinQueryPointerPos(HWND_DESKTOP, &ptl); | 3789 WinQueryPointerPos(HWND_DESKTOP, &ptl); |
3790 if(x && y) | 3790 if(x && y) |
3798 * Sets the X and Y coordinates of the mouse pointer. | 3798 * Sets the X and Y coordinates of the mouse pointer. |
3799 * Parameters: | 3799 * Parameters: |
3800 * x: X coordinate. | 3800 * x: X coordinate. |
3801 * y: Y coordinate. | 3801 * y: Y coordinate. |
3802 */ | 3802 */ |
3803 void dw_pointer_set_pos(long x, long y) | 3803 void API dw_pointer_set_pos(long x, long y) |
3804 { | 3804 { |
3805 WinSetPointerPos(HWND_DESKTOP, x, dw_screen_height() - y); | 3805 WinSetPointerPos(HWND_DESKTOP, x, dw_screen_height() - y); |
3806 } | 3806 } |
3807 | 3807 |
3808 /* | 3808 /* |
3809 * Create a container object to be packed. | 3809 * Create a container object to be packed. |
3810 * Parameters: | 3810 * Parameters: |
3811 * id: An ID to be used for getting the resource from the | 3811 * id: An ID to be used for getting the resource from the |
3812 * resource file. | 3812 * resource file. |
3813 */ | 3813 */ |
3814 HWND dw_container_new(ULONG id) | 3814 HWND API dw_container_new(ULONG id) |
3815 { | 3815 { |
3816 WindowData *blah = calloc(1, sizeof(WindowData)); | 3816 WindowData *blah = calloc(1, sizeof(WindowData)); |
3817 HWND tmp = WinCreateWindow(HWND_OBJECT, | 3817 HWND tmp = WinCreateWindow(HWND_OBJECT, |
3818 WC_CONTAINER, | 3818 WC_CONTAINER, |
3819 NULL, | 3819 NULL, |
3836 * Create a tree object to be packed. | 3836 * Create a tree object to be packed. |
3837 * Parameters: | 3837 * Parameters: |
3838 * id: An ID to be used for getting the resource from the | 3838 * id: An ID to be used for getting the resource from the |
3839 * resource file. | 3839 * resource file. |
3840 */ | 3840 */ |
3841 HWND dw_tree_new(ULONG id) | 3841 HWND API dw_tree_new(ULONG id) |
3842 { | 3842 { |
3843 CNRINFO cnrinfo; | 3843 CNRINFO cnrinfo; |
3844 WindowData *blah = calloc(1, sizeof(WindowData)); | 3844 WindowData *blah = calloc(1, sizeof(WindowData)); |
3845 HWND tmp = WinCreateWindow(HWND_OBJECT, | 3845 HWND tmp = WinCreateWindow(HWND_OBJECT, |
3846 WC_CONTAINER, | 3846 WC_CONTAINER, |
3873 * Create a new static text window (widget) to be packed. | 3873 * Create a new static text window (widget) to be packed. |
3874 * Parameters: | 3874 * Parameters: |
3875 * text: The text to be display by the static text widget. | 3875 * text: The text to be display by the static text widget. |
3876 * id: An ID to be used with WinWindowFromID() or 0L. | 3876 * id: An ID to be used with WinWindowFromID() or 0L. |
3877 */ | 3877 */ |
3878 HWND dw_text_new(char *text, ULONG id) | 3878 HWND API dw_text_new(char *text, ULONG id) |
3879 { | 3879 { |
3880 HWND tmp = WinCreateWindow(HWND_OBJECT, | 3880 HWND tmp = WinCreateWindow(HWND_OBJECT, |
3881 WC_STATIC, | 3881 WC_STATIC, |
3882 text, | 3882 text, |
3883 WS_VISIBLE | SS_TEXT, | 3883 WS_VISIBLE | SS_TEXT, |
3896 * Create a new status text window (widget) to be packed. | 3896 * Create a new status text window (widget) to be packed. |
3897 * Parameters: | 3897 * Parameters: |
3898 * text: The text to be display by the static text widget. | 3898 * text: The text to be display by the static text widget. |
3899 * id: An ID to be used with WinWindowFromID() or 0L. | 3899 * id: An ID to be used with WinWindowFromID() or 0L. |
3900 */ | 3900 */ |
3901 HWND dw_status_text_new(char *text, ULONG id) | 3901 HWND API dw_status_text_new(char *text, ULONG id) |
3902 { | 3902 { |
3903 WindowData *blah = calloc(sizeof(WindowData), 1); | 3903 WindowData *blah = calloc(sizeof(WindowData), 1); |
3904 HWND tmp = WinCreateWindow(HWND_OBJECT, | 3904 HWND tmp = WinCreateWindow(HWND_OBJECT, |
3905 WC_STATIC, | 3905 WC_STATIC, |
3906 text, | 3906 text, |
3926 /* | 3926 /* |
3927 * Create a new Multiline Editbox window (widget) to be packed. | 3927 * Create a new Multiline Editbox window (widget) to be packed. |
3928 * Parameters: | 3928 * Parameters: |
3929 * id: An ID to be used with WinWindowFromID() or 0L. | 3929 * id: An ID to be used with WinWindowFromID() or 0L. |
3930 */ | 3930 */ |
3931 HWND dw_mle_new(ULONG id) | 3931 HWND API dw_mle_new(ULONG id) |
3932 { | 3932 { |
3933 WindowData *blah = calloc(1, sizeof(WindowData)); | 3933 WindowData *blah = calloc(1, sizeof(WindowData)); |
3934 HWND tmp = WinCreateWindow(HWND_OBJECT, | 3934 HWND tmp = WinCreateWindow(HWND_OBJECT, |
3935 WC_MLE, | 3935 WC_MLE, |
3936 "", | 3936 "", |
3954 * Create a new Entryfield window (widget) to be packed. | 3954 * Create a new Entryfield window (widget) to be packed. |
3955 * Parameters: | 3955 * Parameters: |
3956 * text: The default text to be in the entryfield widget. | 3956 * text: The default text to be in the entryfield widget. |
3957 * id: An ID to be used with WinWindowFromID() or 0L. | 3957 * id: An ID to be used with WinWindowFromID() or 0L. |
3958 */ | 3958 */ |
3959 HWND dw_entryfield_new(char *text, ULONG id) | 3959 HWND API dw_entryfield_new(char *text, ULONG id) |
3960 { | 3960 { |
3961 | 3961 |
3962 WindowData *blah = calloc(1, sizeof(WindowData)); | 3962 WindowData *blah = calloc(1, sizeof(WindowData)); |
3963 HWND tmp = WinCreateWindow(HWND_OBJECT, | 3963 HWND tmp = WinCreateWindow(HWND_OBJECT, |
3964 WC_ENTRYFIELD, | 3964 WC_ENTRYFIELD, |
3982 * Create a new Entryfield (password) window (widget) to be packed. | 3982 * Create a new Entryfield (password) window (widget) to be packed. |
3983 * Parameters: | 3983 * Parameters: |
3984 * text: The default text to be in the entryfield widget. | 3984 * text: The default text to be in the entryfield widget. |
3985 * id: An ID to be used with WinWindowFromID() or 0L. | 3985 * id: An ID to be used with WinWindowFromID() or 0L. |
3986 */ | 3986 */ |
3987 HWND dw_entryfield_password_new(char *text, ULONG id) | 3987 HWND API dw_entryfield_password_new(char *text, ULONG id) |
3988 { | 3988 { |
3989 WindowData *blah = calloc(1, sizeof(WindowData)); | 3989 WindowData *blah = calloc(1, sizeof(WindowData)); |
3990 HWND tmp = WinCreateWindow(HWND_OBJECT, | 3990 HWND tmp = WinCreateWindow(HWND_OBJECT, |
3991 WC_ENTRYFIELD, | 3991 WC_ENTRYFIELD, |
3992 text, | 3992 text, |
4009 * Create a new Combobox window (widget) to be packed. | 4009 * Create a new Combobox window (widget) to be packed. |
4010 * Parameters: | 4010 * Parameters: |
4011 * text: The default text to be in the combpbox widget. | 4011 * text: The default text to be in the combpbox widget. |
4012 * id: An ID to be used with WinWindowFromID() or 0L. | 4012 * id: An ID to be used with WinWindowFromID() or 0L. |
4013 */ | 4013 */ |
4014 HWND dw_combobox_new(char *text, ULONG id) | 4014 HWND API dw_combobox_new(char *text, ULONG id) |
4015 { | 4015 { |
4016 WindowData *blah = calloc(1, sizeof(WindowData)); | 4016 WindowData *blah = calloc(1, sizeof(WindowData)); |
4017 HWND tmp = WinCreateWindow(HWND_OBJECT, | 4017 HWND tmp = WinCreateWindow(HWND_OBJECT, |
4018 WC_COMBOBOX, | 4018 WC_COMBOBOX, |
4019 text, | 4019 text, |
4046 * Create a new button window (widget) to be packed. | 4046 * Create a new button window (widget) to be packed. |
4047 * Parameters: | 4047 * Parameters: |
4048 * text: The text to be display by the static text widget. | 4048 * text: The text to be display by the static text widget. |
4049 * id: An ID to be used with WinWindowFromID() or 0L. | 4049 * id: An ID to be used with WinWindowFromID() or 0L. |
4050 */ | 4050 */ |
4051 HWND dw_button_new(char *text, ULONG id) | 4051 HWND API dw_button_new(char *text, ULONG id) |
4052 { | 4052 { |
4053 BubbleButton *bubble = calloc(sizeof(BubbleButton), 1); | 4053 BubbleButton *bubble = calloc(sizeof(BubbleButton), 1); |
4054 | 4054 |
4055 HWND tmp = WinCreateWindow(HWND_OBJECT, | 4055 HWND tmp = WinCreateWindow(HWND_OBJECT, |
4056 WC_BUTTON, | 4056 WC_BUTTON, |
4110 * Create a new bitmap button window (widget) to be packed. | 4110 * Create a new bitmap button window (widget) to be packed. |
4111 * Parameters: | 4111 * Parameters: |
4112 * text: Bubble help text to be displayed. | 4112 * text: Bubble help text to be displayed. |
4113 * id: An ID of a bitmap in the resource file. | 4113 * id: An ID of a bitmap in the resource file. |
4114 */ | 4114 */ |
4115 HWND dw_bitmapbutton_new(char *text, ULONG id) | 4115 HWND API dw_bitmapbutton_new(char *text, ULONG id) |
4116 { | 4116 { |
4117 char idbuf[256]; | 4117 char idbuf[256]; |
4118 HWND tmp; | 4118 HWND tmp; |
4119 BubbleButton *bubble = calloc(sizeof(BubbleButton), 1); | 4119 BubbleButton *bubble = calloc(sizeof(BubbleButton), 1); |
4120 | 4120 |
4146 * Create a new spinbutton window (widget) to be packed. | 4146 * Create a new spinbutton window (widget) to be packed. |
4147 * Parameters: | 4147 * Parameters: |
4148 * text: The text to be display by the static text widget. | 4148 * text: The text to be display by the static text widget. |
4149 * id: An ID to be used with WinWindowFromID() or 0L. | 4149 * id: An ID to be used with WinWindowFromID() or 0L. |
4150 */ | 4150 */ |
4151 HWND dw_spinbutton_new(char *text, ULONG id) | 4151 HWND API dw_spinbutton_new(char *text, ULONG id) |
4152 { | 4152 { |
4153 WindowData *blah = calloc(sizeof(WindowData), 1); | 4153 WindowData *blah = calloc(sizeof(WindowData), 1); |
4154 HWND tmp = WinCreateWindow(HWND_OBJECT, | 4154 HWND tmp = WinCreateWindow(HWND_OBJECT, |
4155 WC_SPINBUTTON, | 4155 WC_SPINBUTTON, |
4156 text, | 4156 text, |
4176 * Create a new radiobutton window (widget) to be packed. | 4176 * Create a new radiobutton window (widget) to be packed. |
4177 * Parameters: | 4177 * Parameters: |
4178 * text: The text to be display by the static text widget. | 4178 * text: The text to be display by the static text widget. |
4179 * id: An ID to be used with WinWindowFromID() or 0L. | 4179 * id: An ID to be used with WinWindowFromID() or 0L. |
4180 */ | 4180 */ |
4181 HWND dw_radiobutton_new(char *text, ULONG id) | 4181 HWND API dw_radiobutton_new(char *text, ULONG id) |
4182 { | 4182 { |
4183 WindowData *blah = calloc(sizeof(WindowData), 1); | 4183 WindowData *blah = calloc(sizeof(WindowData), 1); |
4184 HWND tmp = WinCreateWindow(HWND_OBJECT, | 4184 HWND tmp = WinCreateWindow(HWND_OBJECT, |
4185 WC_BUTTON, | 4185 WC_BUTTON, |
4186 text, | 4186 text, |
4205 * Parameters: | 4205 * Parameters: |
4206 * vertical: TRUE or FALSE if slider is vertical. | 4206 * vertical: TRUE or FALSE if slider is vertical. |
4207 * increments: Number of increments available. | 4207 * increments: Number of increments available. |
4208 * id: An ID to be used with WinWindowFromID() or 0L. | 4208 * id: An ID to be used with WinWindowFromID() or 0L. |
4209 */ | 4209 */ |
4210 HWND dw_slider_new(int vertical, int increments, ULONG id) | 4210 HWND API dw_slider_new(int vertical, int increments, ULONG id) |
4211 { | 4211 { |
4212 WindowData *blah = calloc(1, sizeof(WindowData)); | 4212 WindowData *blah = calloc(1, sizeof(WindowData)); |
4213 SLDCDATA sldcData = { 0, 0, 0, 0, 0 }; | 4213 SLDCDATA sldcData = { 0, 0, 0, 0, 0 }; |
4214 HWND tmp = WinCreateWindow(HWND_OBJECT, | 4214 HWND tmp = WinCreateWindow(HWND_OBJECT, |
4215 WC_SLIDER, | 4215 WC_SLIDER, |
4234 /* | 4234 /* |
4235 * Create a new percent bar window (widget) to be packed. | 4235 * Create a new percent bar window (widget) to be packed. |
4236 * Parameters: | 4236 * Parameters: |
4237 * id: An ID to be used with WinWindowFromID() or 0L. | 4237 * id: An ID to be used with WinWindowFromID() or 0L. |
4238 */ | 4238 */ |
4239 HWND dw_percent_new(ULONG id) | 4239 HWND API dw_percent_new(ULONG id) |
4240 { | 4240 { |
4241 WindowData *blah = calloc(1, sizeof(WindowData)); | 4241 WindowData *blah = calloc(1, sizeof(WindowData)); |
4242 HWND tmp = WinCreateWindow(HWND_OBJECT, | 4242 HWND tmp = WinCreateWindow(HWND_OBJECT, |
4243 WC_SLIDER, | 4243 WC_SLIDER, |
4244 "", | 4244 "", |
4260 * Create a new checkbox window (widget) to be packed. | 4260 * Create a new checkbox window (widget) to be packed. |
4261 * Parameters: | 4261 * Parameters: |
4262 * text: The text to be display by the static text widget. | 4262 * text: The text to be display by the static text widget. |
4263 * id: An ID to be used with WinWindowFromID() or 0L. | 4263 * id: An ID to be used with WinWindowFromID() or 0L. |
4264 */ | 4264 */ |
4265 HWND dw_checkbox_new(char *text, ULONG id) | 4265 HWND API dw_checkbox_new(char *text, ULONG id) |
4266 { | 4266 { |
4267 BubbleButton *bubble = calloc(sizeof(BubbleButton), 1); | 4267 BubbleButton *bubble = calloc(sizeof(BubbleButton), 1); |
4268 HWND tmp = WinCreateWindow(HWND_OBJECT, | 4268 HWND tmp = WinCreateWindow(HWND_OBJECT, |
4269 WC_BUTTON, | 4269 WC_BUTTON, |
4270 text, | 4270 text, |
4288 * Create a new listbox window (widget) to be packed. | 4288 * Create a new listbox window (widget) to be packed. |
4289 * Parameters: | 4289 * Parameters: |
4290 * id: An ID to be used with WinWindowFromID() or 0L. | 4290 * id: An ID to be used with WinWindowFromID() or 0L. |
4291 * multi: Multiple select TRUE or FALSE. | 4291 * multi: Multiple select TRUE or FALSE. |
4292 */ | 4292 */ |
4293 HWND dw_listbox_new(ULONG id, int multi) | 4293 HWND API dw_listbox_new(ULONG id, int multi) |
4294 { | 4294 { |
4295 WindowData *blah = calloc(sizeof(WindowData), 1); | 4295 WindowData *blah = calloc(sizeof(WindowData), 1); |
4296 HWND tmp = WinCreateWindow(HWND_OBJECT, | 4296 HWND tmp = WinCreateWindow(HWND_OBJECT, |
4297 WC_LISTBOX, | 4297 WC_LISTBOX, |
4298 NULL, | 4298 NULL, |
4315 * Sets the icon used for a given window. | 4315 * Sets the icon used for a given window. |
4316 * Parameters: | 4316 * Parameters: |
4317 * handle: Handle to the window. | 4317 * handle: Handle to the window. |
4318 * id: An ID to be used to specify the icon. | 4318 * id: An ID to be used to specify the icon. |
4319 */ | 4319 */ |
4320 void dw_window_set_icon(HWND handle, ULONG id) | 4320 void API dw_window_set_icon(HWND handle, ULONG id) |
4321 { | 4321 { |
4322 HPOINTER icon; | 4322 HPOINTER icon; |
4323 | 4323 |
4324 icon = WinLoadPointer(HWND_DESKTOP,NULLHANDLE,id); | 4324 icon = WinLoadPointer(HWND_DESKTOP,NULLHANDLE,id); |
4325 WinSendMsg(handle, WM_SETICON, (MPARAM)icon, 0); | 4325 WinSendMsg(handle, WM_SETICON, (MPARAM)icon, 0); |
4329 * Sets the bitmap used for a given static window. | 4329 * Sets the bitmap used for a given static window. |
4330 * Parameters: | 4330 * Parameters: |
4331 * handle: Handle to the window. | 4331 * handle: Handle to the window. |
4332 * id: An ID to be used to specify the icon. | 4332 * id: An ID to be used to specify the icon. |
4333 */ | 4333 */ |
4334 void dw_window_set_bitmap(HWND handle, ULONG id) | 4334 void API dw_window_set_bitmap(HWND handle, ULONG id) |
4335 { | 4335 { |
4336 HBITMAP hbm; | 4336 HBITMAP hbm; |
4337 HPS hps = WinGetPS(handle); | 4337 HPS hps = WinGetPS(handle); |
4338 | 4338 |
4339 hbm = GpiLoadBitmap(hps, NULLHANDLE, id, 0, 0); | 4339 hbm = GpiLoadBitmap(hps, NULLHANDLE, id, 0, 0); |
4347 * Sets the text used for a given window. | 4347 * Sets the text used for a given window. |
4348 * Parameters: | 4348 * Parameters: |
4349 * handle: Handle to the window. | 4349 * handle: Handle to the window. |
4350 * text: The text associsated with a given window. | 4350 * text: The text associsated with a given window. |
4351 */ | 4351 */ |
4352 void dw_window_set_text(HWND handle, char *text) | 4352 void API dw_window_set_text(HWND handle, char *text) |
4353 { | 4353 { |
4354 WinSetWindowText(handle, text); | 4354 WinSetWindowText(handle, text); |
4355 } | 4355 } |
4356 | 4356 |
4357 /* | 4357 /* |
4359 * Parameters: | 4359 * Parameters: |
4360 * handle: Handle to the window. | 4360 * handle: Handle to the window. |
4361 * Returns: | 4361 * Returns: |
4362 * text: The text associsated with a given window. | 4362 * text: The text associsated with a given window. |
4363 */ | 4363 */ |
4364 char *dw_window_get_text(HWND handle) | 4364 char * API dw_window_get_text(HWND handle) |
4365 { | 4365 { |
4366 int len = WinQueryWindowTextLength(handle); | 4366 int len = WinQueryWindowTextLength(handle); |
4367 char *tempbuf = calloc(1, len + 2); | 4367 char *tempbuf = calloc(1, len + 2); |
4368 | 4368 |
4369 WinQueryWindowText(handle, len + 1, tempbuf); | 4369 WinQueryWindowText(handle, len + 1, tempbuf); |
4374 /* | 4374 /* |
4375 * Disables given window (widget). | 4375 * Disables given window (widget). |
4376 * Parameters: | 4376 * Parameters: |
4377 * handle: Handle to the window. | 4377 * handle: Handle to the window. |
4378 */ | 4378 */ |
4379 void dw_window_disable(HWND handle) | 4379 void API dw_window_disable(HWND handle) |
4380 { | 4380 { |
4381 char tmpbuf[100]; | 4381 char tmpbuf[100]; |
4382 | 4382 |
4383 if(dw_window_get_data(handle, "_dw_disabled")) | 4383 if(dw_window_get_data(handle, "_dw_disabled")) |
4384 return; | 4384 return; |
4419 /* | 4419 /* |
4420 * Enables given window (widget). | 4420 * Enables given window (widget). |
4421 * Parameters: | 4421 * Parameters: |
4422 * handle: Handle to the window. | 4422 * handle: Handle to the window. |
4423 */ | 4423 */ |
4424 void dw_window_enable(HWND handle) | 4424 void API dw_window_enable(HWND handle) |
4425 { | 4425 { |
4426 ULONG fore = (ULONG)dw_window_get_data(handle, "_dw_fore"); | 4426 ULONG fore = (ULONG)dw_window_get_data(handle, "_dw_fore"); |
4427 ULONG back = (ULONG)dw_window_get_data(handle, "_dw_back"); | 4427 ULONG back = (ULONG)dw_window_get_data(handle, "_dw_back"); |
4428 HWND hwnd = _find_entryfield(handle); | 4428 HWND hwnd = _find_entryfield(handle); |
4429 | 4429 |
4440 * Gets the child window handle with specified ID. | 4440 * Gets the child window handle with specified ID. |
4441 * Parameters: | 4441 * Parameters: |
4442 * handle: Handle to the parent window. | 4442 * handle: Handle to the parent window. |
4443 * id: Integer ID of the child. | 4443 * id: Integer ID of the child. |
4444 */ | 4444 */ |
4445 HWND dw_window_from_id(HWND handle, int id) | 4445 HWND API dw_window_from_id(HWND handle, int id) |
4446 { | 4446 { |
4447 HENUM henum; | 4447 HENUM henum; |
4448 HWND child; | 4448 HWND child; |
4449 char tmpbuf[100]; | 4449 char tmpbuf[100]; |
4450 | 4450 |
4480 * height: Height in pixels of the item or -1 to be self determined. | 4480 * height: Height in pixels of the item or -1 to be self determined. |
4481 * hsize: TRUE if the window (widget) should expand horizontally to fill space given. | 4481 * hsize: TRUE if the window (widget) should expand horizontally to fill space given. |
4482 * vsize: TRUE if the window (widget) should expand vertically to fill space given. | 4482 * vsize: TRUE if the window (widget) should expand vertically to fill space given. |
4483 * pad: Number of pixels of padding around the item. | 4483 * pad: Number of pixels of padding around the item. |
4484 */ | 4484 */ |
4485 void dw_box_pack_end(HWND box, HWND item, int width, int height, int hsize, int vsize, int pad) | 4485 void API dw_box_pack_end(HWND box, HWND item, int width, int height, int hsize, int vsize, int pad) |
4486 { | 4486 { |
4487 Box *thisbox; | 4487 Box *thisbox; |
4488 | 4488 |
4489 if(WinWindowFromID(box, FID_CLIENT)) | 4489 if(WinWindowFromID(box, FID_CLIENT)) |
4490 { | 4490 { |
4579 * Parameters: | 4579 * Parameters: |
4580 * handle: Window (widget) handle. | 4580 * handle: Window (widget) handle. |
4581 * width: New width in pixels. | 4581 * width: New width in pixels. |
4582 * height: New height in pixels. | 4582 * height: New height in pixels. |
4583 */ | 4583 */ |
4584 void dw_window_set_usize(HWND handle, ULONG width, ULONG height) | 4584 void API dw_window_set_usize(HWND handle, ULONG width, ULONG height) |
4585 { | 4585 { |
4586 WinSetWindowPos(handle, NULLHANDLE, 0, 0, width, height, SWP_SHOW | SWP_SIZE); | 4586 WinSetWindowPos(handle, NULLHANDLE, 0, 0, width, height, SWP_SHOW | SWP_SIZE); |
4587 } | 4587 } |
4588 | 4588 |
4589 /* | 4589 /* |
4590 * Returns the width of the screen. | 4590 * Returns the width of the screen. |
4591 */ | 4591 */ |
4592 int dw_screen_width(void) | 4592 int API dw_screen_width(void) |
4593 { | 4593 { |
4594 return WinQuerySysValue(HWND_DESKTOP,SV_CXSCREEN); | 4594 return WinQuerySysValue(HWND_DESKTOP,SV_CXSCREEN); |
4595 } | 4595 } |
4596 | 4596 |
4597 /* | 4597 /* |
4598 * Returns the height of the screen. | 4598 * Returns the height of the screen. |
4599 */ | 4599 */ |
4600 int dw_screen_height(void) | 4600 int API dw_screen_height(void) |
4601 { | 4601 { |
4602 return WinQuerySysValue(HWND_DESKTOP,SV_CYSCREEN); | 4602 return WinQuerySysValue(HWND_DESKTOP,SV_CYSCREEN); |
4603 } | 4603 } |
4604 | 4604 |
4605 /* This should return the current color depth */ | 4605 /* This should return the current color depth */ |
4606 unsigned long dw_color_depth(void) | 4606 unsigned long API dw_color_depth(void) |
4607 { | 4607 { |
4608 HDC hdc = WinOpenWindowDC(HWND_DESKTOP); | 4608 HDC hdc = WinOpenWindowDC(HWND_DESKTOP); |
4609 long colors; | 4609 long colors; |
4610 | 4610 |
4611 DevQueryCaps(hdc, CAPS_COLOR_BITCOUNT, 1, &colors); | 4611 DevQueryCaps(hdc, CAPS_COLOR_BITCOUNT, 1, &colors); |
4619 * Parameters: | 4619 * Parameters: |
4620 * handle: Window (widget) handle. | 4620 * handle: Window (widget) handle. |
4621 * x: X location from the bottom left. | 4621 * x: X location from the bottom left. |
4622 * y: Y location from the bottom left. | 4622 * y: Y location from the bottom left. |
4623 */ | 4623 */ |
4624 void dw_window_set_pos(HWND handle, ULONG x, ULONG y) | 4624 void API dw_window_set_pos(HWND handle, ULONG x, ULONG y) |
4625 { | 4625 { |
4626 int myy = _get_frame_height(handle) - (y + _get_height(handle)); | 4626 int myy = _get_frame_height(handle) - (y + _get_height(handle)); |
4627 | 4627 |
4628 WinSetWindowPos(handle, NULLHANDLE, x, myy, 0, 0, SWP_MOVE); | 4628 WinSetWindowPos(handle, NULLHANDLE, x, myy, 0, 0, SWP_MOVE); |
4629 } | 4629 } |
4635 * x: X location from the bottom left. | 4635 * x: X location from the bottom left. |
4636 * y: Y location from the bottom left. | 4636 * y: Y location from the bottom left. |
4637 * width: Width of the widget. | 4637 * width: Width of the widget. |
4638 * height: Height of the widget. | 4638 * height: Height of the widget. |
4639 */ | 4639 */ |
4640 void dw_window_set_pos_size(HWND handle, ULONG x, ULONG y, ULONG width, ULONG height) | 4640 void API dw_window_set_pos_size(HWND handle, ULONG x, ULONG y, ULONG width, ULONG height) |
4641 { | 4641 { |
4642 int myy = _get_frame_height(handle) - (y + height); | 4642 int myy = _get_frame_height(handle) - (y + height); |
4643 | 4643 |
4644 WinSetWindowPos(handle, NULLHANDLE, x, myy, width, height, SWP_MOVE | SWP_SIZE | SWP_SHOW); | 4644 WinSetWindowPos(handle, NULLHANDLE, x, myy, width, height, SWP_MOVE | SWP_SIZE | SWP_SHOW); |
4645 } | 4645 } |
4651 * x: X location from the bottom left. | 4651 * x: X location from the bottom left. |
4652 * y: Y location from the bottom left. | 4652 * y: Y location from the bottom left. |
4653 * width: Width of the widget. | 4653 * width: Width of the widget. |
4654 * height: Height of the widget. | 4654 * height: Height of the widget. |
4655 */ | 4655 */ |
4656 void dw_window_get_pos_size(HWND handle, ULONG *x, ULONG *y, ULONG *width, ULONG *height) | 4656 void API dw_window_get_pos_size(HWND handle, ULONG *x, ULONG *y, ULONG *width, ULONG *height) |
4657 { | 4657 { |
4658 SWP swp; | 4658 SWP swp; |
4659 WinQueryWindowPos(handle, &swp); | 4659 WinQueryWindowPos(handle, &swp); |
4660 if(x) | 4660 if(x) |
4661 *x = swp.x; | 4661 *x = swp.x; |
4672 * Parameters: | 4672 * Parameters: |
4673 * handle: Window (widget) handle. | 4673 * handle: Window (widget) handle. |
4674 * width: New width in pixels. | 4674 * width: New width in pixels. |
4675 * height: New height in pixels. | 4675 * height: New height in pixels. |
4676 */ | 4676 */ |
4677 void dw_window_set_style(HWND handle, ULONG style, ULONG mask) | 4677 void API dw_window_set_style(HWND handle, ULONG style, ULONG mask) |
4678 { | 4678 { |
4679 WinSetWindowBits(handle, QWL_STYLE, style, mask); | 4679 WinSetWindowBits(handle, QWL_STYLE, style, mask); |
4680 } | 4680 } |
4681 | 4681 |
4682 /* | 4682 /* |
4684 * Parameters: | 4684 * Parameters: |
4685 * handle: Window (widget) handle. | 4685 * handle: Window (widget) handle. |
4686 * flags: Any additional page creation flags. | 4686 * flags: Any additional page creation flags. |
4687 * front: If TRUE page is added at the beginning. | 4687 * front: If TRUE page is added at the beginning. |
4688 */ | 4688 */ |
4689 ULONG dw_notebook_page_new(HWND handle, ULONG flags, int front) | 4689 unsigned long API dw_notebook_page_new(HWND handle, ULONG flags, int front) |
4690 { | 4690 { |
4691 if(front) | 4691 if(front) |
4692 return (ULONG)WinSendMsg(handle, BKM_INSERTPAGE, 0L, | 4692 return (ULONG)WinSendMsg(handle, BKM_INSERTPAGE, 0L, |
4693 MPFROM2SHORT((BKA_STATUSTEXTON | BKA_AUTOPAGESIZE | BKA_MAJOR | flags), BKA_FIRST)); | 4693 MPFROM2SHORT((BKA_STATUSTEXTON | BKA_AUTOPAGESIZE | BKA_MAJOR | flags), BKA_FIRST)); |
4694 return (ULONG)WinSendMsg(handle, BKM_INSERTPAGE, 0L, | 4694 return (ULONG)WinSendMsg(handle, BKM_INSERTPAGE, 0L, |
4699 * Remove a page from a notebook. | 4699 * Remove a page from a notebook. |
4700 * Parameters: | 4700 * Parameters: |
4701 * handle: Handle to the notebook widget. | 4701 * handle: Handle to the notebook widget. |
4702 * pageid: ID of the page to be destroyed. | 4702 * pageid: ID of the page to be destroyed. |
4703 */ | 4703 */ |
4704 void dw_notebook_page_destroy(HWND handle, unsigned int pageid) | 4704 void API dw_notebook_page_destroy(HWND handle, unsigned int pageid) |
4705 { | 4705 { |
4706 WinSendMsg(handle, BKM_DELETEPAGE, | 4706 WinSendMsg(handle, BKM_DELETEPAGE, |
4707 MPFROMLONG(pageid), (MPARAM)BKA_SINGLE); | 4707 MPFROMLONG(pageid), (MPARAM)BKA_SINGLE); |
4708 } | 4708 } |
4709 | 4709 |
4710 /* | 4710 /* |
4711 * Queries the currently visible page ID. | 4711 * Queries the currently visible page ID. |
4712 * Parameters: | 4712 * Parameters: |
4713 * handle: Handle to the notebook widget. | 4713 * handle: Handle to the notebook widget. |
4714 */ | 4714 */ |
4715 unsigned int dw_notebook_page_query(HWND handle) | 4715 unsigned int API dw_notebook_page_query(HWND handle) |
4716 { | 4716 { |
4717 return (int)WinSendMsg(handle, BKM_QUERYPAGEID,0L, MPFROM2SHORT(BKA_TOP, BKA_MAJOR)); | 4717 return (int)WinSendMsg(handle, BKM_QUERYPAGEID,0L, MPFROM2SHORT(BKA_TOP, BKA_MAJOR)); |
4718 } | 4718 } |
4719 | 4719 |
4720 /* | 4720 /* |
4721 * Sets the currently visibale page ID. | 4721 * Sets the currently visibale page ID. |
4722 * Parameters: | 4722 * Parameters: |
4723 * handle: Handle to the notebook widget. | 4723 * handle: Handle to the notebook widget. |
4724 * pageid: ID of the page to be made visible. | 4724 * pageid: ID of the page to be made visible. |
4725 */ | 4725 */ |
4726 void dw_notebook_page_set(HWND handle, unsigned int pageid) | 4726 void API dw_notebook_page_set(HWND handle, unsigned int pageid) |
4727 { | 4727 { |
4728 WinSendMsg(handle, BKM_TURNTOPAGE, MPFROMLONG(pageid), 0L); | 4728 WinSendMsg(handle, BKM_TURNTOPAGE, MPFROMLONG(pageid), 0L); |
4729 } | 4729 } |
4730 | 4730 |
4731 /* | 4731 /* |
4733 * Parameters: | 4733 * Parameters: |
4734 * handle: Notebook handle. | 4734 * handle: Notebook handle. |
4735 * pageid: Page ID of the tab to set. | 4735 * pageid: Page ID of the tab to set. |
4736 * text: Pointer to the text to set. | 4736 * text: Pointer to the text to set. |
4737 */ | 4737 */ |
4738 void dw_notebook_page_set_text(HWND handle, ULONG pageid, char *text) | 4738 void API dw_notebook_page_set_text(HWND handle, ULONG pageid, char *text) |
4739 { | 4739 { |
4740 WinSendMsg(handle, BKM_SETTABTEXT, | 4740 WinSendMsg(handle, BKM_SETTABTEXT, |
4741 MPFROMLONG(pageid), MPFROMP(text)); | 4741 MPFROMLONG(pageid), MPFROMP(text)); |
4742 } | 4742 } |
4743 | 4743 |
4746 * Parameters: | 4746 * Parameters: |
4747 * handle: Notebook handle. | 4747 * handle: Notebook handle. |
4748 * pageid: Page ID of the tab to set. | 4748 * pageid: Page ID of the tab to set. |
4749 * text: Pointer to the text to set. | 4749 * text: Pointer to the text to set. |
4750 */ | 4750 */ |
4751 void dw_notebook_page_set_status_text(HWND handle, ULONG pageid, char *text) | 4751 void API dw_notebook_page_set_status_text(HWND handle, ULONG pageid, char *text) |
4752 { | 4752 { |
4753 WinSendMsg(handle, BKM_SETSTATUSLINETEXT, | 4753 WinSendMsg(handle, BKM_SETSTATUSLINETEXT, |
4754 MPFROMLONG(pageid), MPFROMP(text)); | 4754 MPFROMLONG(pageid), MPFROMP(text)); |
4755 } | 4755 } |
4756 | 4756 |
4759 * Parameters: | 4759 * Parameters: |
4760 * handle: Handle to the notebook to be packed. | 4760 * handle: Handle to the notebook to be packed. |
4761 * pageid: Page ID in the notebook which is being packed. | 4761 * pageid: Page ID in the notebook which is being packed. |
4762 * page: Box handle to be packed. | 4762 * page: Box handle to be packed. |
4763 */ | 4763 */ |
4764 void dw_notebook_pack(HWND handle, ULONG pageid, HWND page) | 4764 void API dw_notebook_pack(HWND handle, ULONG pageid, HWND page) |
4765 { | 4765 { |
4766 HWND tmpbox = dw_box_new(BOXVERT, 0); | 4766 HWND tmpbox = dw_box_new(BOXVERT, 0); |
4767 | 4767 |
4768 dw_box_pack_start(tmpbox, page, 0, 0, TRUE, TRUE, 0); | 4768 dw_box_pack_start(tmpbox, page, 0, 0, TRUE, TRUE, 0); |
4769 WinSubclassWindow(tmpbox, _wndproc); | 4769 WinSubclassWindow(tmpbox, _wndproc); |
4775 * Appends the specified text to the listbox's (or combobox) entry list. | 4775 * Appends the specified text to the listbox's (or combobox) entry list. |
4776 * Parameters: | 4776 * Parameters: |
4777 * handle: Handle to the listbox to be appended to. | 4777 * handle: Handle to the listbox to be appended to. |
4778 * text: Text to append into listbox. | 4778 * text: Text to append into listbox. |
4779 */ | 4779 */ |
4780 void dw_listbox_append(HWND handle, char *text) | 4780 void API dw_listbox_append(HWND handle, char *text) |
4781 { | 4781 { |
4782 WinSendMsg(handle, | 4782 WinSendMsg(handle, |
4783 LM_INSERTITEM, | 4783 LM_INSERTITEM, |
4784 MPFROMSHORT(LIT_END), | 4784 MPFROMSHORT(LIT_END), |
4785 MPFROMP(text)); | 4785 MPFROMP(text)); |
4788 /* | 4788 /* |
4789 * Clears the listbox's (or combobox) list of all entries. | 4789 * Clears the listbox's (or combobox) list of all entries. |
4790 * Parameters: | 4790 * Parameters: |
4791 * handle: Handle to the listbox to be cleared. | 4791 * handle: Handle to the listbox to be cleared. |
4792 */ | 4792 */ |
4793 void dw_listbox_clear(HWND handle) | 4793 void API dw_listbox_clear(HWND handle) |
4794 { | 4794 { |
4795 WinSendMsg(handle, | 4795 WinSendMsg(handle, |
4796 LM_DELETEALL, 0L, 0L); | 4796 LM_DELETEALL, 0L, 0L); |
4797 } | 4797 } |
4798 | 4798 |
4799 /* | 4799 /* |
4800 * Returns the listbox's item count. | 4800 * Returns the listbox's item count. |
4801 * Parameters: | 4801 * Parameters: |
4802 * handle: Handle to the listbox to be cleared. | 4802 * handle: Handle to the listbox to be cleared. |
4803 */ | 4803 */ |
4804 int dw_listbox_count(HWND handle) | 4804 int API dw_listbox_count(HWND handle) |
4805 { | 4805 { |
4806 return (int)WinSendMsg(handle, | 4806 return (int)WinSendMsg(handle, |
4807 LM_QUERYITEMCOUNT,0L, 0L); | 4807 LM_QUERYITEMCOUNT,0L, 0L); |
4808 } | 4808 } |
4809 | 4809 |
4811 * Sets the topmost item in the viewport. | 4811 * Sets the topmost item in the viewport. |
4812 * Parameters: | 4812 * Parameters: |
4813 * handle: Handle to the listbox to be cleared. | 4813 * handle: Handle to the listbox to be cleared. |
4814 * top: Index to the top item. | 4814 * top: Index to the top item. |
4815 */ | 4815 */ |
4816 void dw_listbox_set_top(HWND handle, int top) | 4816 void API dw_listbox_set_top(HWND handle, int top) |
4817 { | 4817 { |
4818 WinSendMsg(handle, | 4818 WinSendMsg(handle, |
4819 LM_SETTOPINDEX, | 4819 LM_SETTOPINDEX, |
4820 MPFROMSHORT(top), | 4820 MPFROMSHORT(top), |
4821 0L); | 4821 0L); |
4827 * handle: Handle to the listbox to be queried. | 4827 * handle: Handle to the listbox to be queried. |
4828 * index: Index into the list to be queried. | 4828 * index: Index into the list to be queried. |
4829 * buffer: Buffer where text will be copied. | 4829 * buffer: Buffer where text will be copied. |
4830 * length: Length of the buffer (including NULL). | 4830 * length: Length of the buffer (including NULL). |
4831 */ | 4831 */ |
4832 void dw_listbox_query_text(HWND handle, unsigned int index, char *buffer, unsigned int length) | 4832 void API dw_listbox_query_text(HWND handle, unsigned int index, char *buffer, unsigned int length) |
4833 { | 4833 { |
4834 WinSendMsg(handle, LM_QUERYITEMTEXT, MPFROM2SHORT(index, length), (MPARAM)buffer); | 4834 WinSendMsg(handle, LM_QUERYITEMTEXT, MPFROM2SHORT(index, length), (MPARAM)buffer); |
4835 } | 4835 } |
4836 | 4836 |
4837 /* | 4837 /* |
4839 * Parameters: | 4839 * Parameters: |
4840 * handle: Handle to the listbox to be queried. | 4840 * handle: Handle to the listbox to be queried. |
4841 * index: Index into the list to be queried. | 4841 * index: Index into the list to be queried. |
4842 * buffer: Buffer where text will be copied. | 4842 * buffer: Buffer where text will be copied. |
4843 */ | 4843 */ |
4844 void dw_listbox_set_text(HWND handle, unsigned int index, char *buffer) | 4844 void API dw_listbox_set_text(HWND handle, unsigned int index, char *buffer) |
4845 { | 4845 { |
4846 WinSendMsg(handle, LM_SETITEMTEXT, MPFROMSHORT(index), (MPARAM)buffer); | 4846 WinSendMsg(handle, LM_SETITEMTEXT, MPFROMSHORT(index), (MPARAM)buffer); |
4847 } | 4847 } |
4848 | 4848 |
4849 /* | 4849 /* |
4850 * Returns the index to the item in the list currently selected. | 4850 * Returns the index to the item in the list currently selected. |
4851 * Parameters: | 4851 * Parameters: |
4852 * handle: Handle to the listbox to be queried. | 4852 * handle: Handle to the listbox to be queried. |
4853 */ | 4853 */ |
4854 unsigned int dw_listbox_selected(HWND handle) | 4854 unsigned int API dw_listbox_selected(HWND handle) |
4855 { | 4855 { |
4856 return (unsigned int)WinSendMsg(handle, | 4856 return (unsigned int)WinSendMsg(handle, |
4857 LM_QUERYSELECTION, | 4857 LM_QUERYSELECTION, |
4858 MPFROMSHORT(LIT_CURSOR), | 4858 MPFROMSHORT(LIT_CURSOR), |
4859 0); | 4859 0); |
4863 * Returns the index to the current selected item or -1 when done. | 4863 * Returns the index to the current selected item or -1 when done. |
4864 * Parameters: | 4864 * Parameters: |
4865 * handle: Handle to the listbox to be queried. | 4865 * handle: Handle to the listbox to be queried. |
4866 * where: Either the previous return or -1 to restart. | 4866 * where: Either the previous return or -1 to restart. |
4867 */ | 4867 */ |
4868 int dw_listbox_selected_multi(HWND handle, int where) | 4868 int API dw_listbox_selected_multi(HWND handle, int where) |
4869 { | 4869 { |
4870 int place = where; | 4870 int place = where; |
4871 | 4871 |
4872 if(where == -1) | 4872 if(where == -1) |
4873 place = LIT_FIRST; | 4873 place = LIT_FIRST; |
4885 * Parameters: | 4885 * Parameters: |
4886 * handle: Handle to the listbox to be set. | 4886 * handle: Handle to the listbox to be set. |
4887 * index: Item index. | 4887 * index: Item index. |
4888 * state: TRUE if selected FALSE if unselected. | 4888 * state: TRUE if selected FALSE if unselected. |
4889 */ | 4889 */ |
4890 void dw_listbox_select(HWND handle, int index, int state) | 4890 void API dw_listbox_select(HWND handle, int index, int state) |
4891 { | 4891 { |
4892 char tmpbuf[100]; | 4892 char tmpbuf[100]; |
4893 | 4893 |
4894 WinSendMsg(handle, LM_SELECTITEM, MPFROMSHORT(index), (MPARAM)state); | 4894 WinSendMsg(handle, LM_SELECTITEM, MPFROMSHORT(index), (MPARAM)state); |
4895 | 4895 |
4904 * Deletes the item with given index from the list. | 4904 * Deletes the item with given index from the list. |
4905 * Parameters: | 4905 * Parameters: |
4906 * handle: Handle to the listbox to be set. | 4906 * handle: Handle to the listbox to be set. |
4907 * index: Item index. | 4907 * index: Item index. |
4908 */ | 4908 */ |
4909 void dw_listbox_delete(HWND handle, int index) | 4909 void API dw_listbox_delete(HWND handle, int index) |
4910 { | 4910 { |
4911 WinSendMsg(handle, LM_DELETEITEM, MPFROMSHORT(index), 0); | 4911 WinSendMsg(handle, LM_DELETEITEM, MPFROMSHORT(index), 0); |
4912 } | 4912 } |
4913 | 4913 |
4914 /* | 4914 /* |
4916 * Parameters: | 4916 * Parameters: |
4917 * handle: Handle to the MLE to be queried. | 4917 * handle: Handle to the MLE to be queried. |
4918 * buffer: Text buffer to be imported. | 4918 * buffer: Text buffer to be imported. |
4919 * startpoint: Point to start entering text. | 4919 * startpoint: Point to start entering text. |
4920 */ | 4920 */ |
4921 unsigned int dw_mle_import(HWND handle, char *buffer, int startpoint) | 4921 unsigned int API dw_mle_import(HWND handle, char *buffer, int startpoint) |
4922 { | 4922 { |
4923 unsigned long point = startpoint; | 4923 unsigned long point = startpoint; |
4924 PBYTE mlebuf; | 4924 PBYTE mlebuf; |
4925 | 4925 |
4926 /* Work around 64K limit */ | 4926 /* Work around 64K limit */ |
4955 * handle: Handle to the MLE to be queried. | 4955 * handle: Handle to the MLE to be queried. |
4956 * buffer: Text buffer to be exported. | 4956 * buffer: Text buffer to be exported. |
4957 * startpoint: Point to start grabbing text. | 4957 * startpoint: Point to start grabbing text. |
4958 * length: Amount of text to be grabbed. | 4958 * length: Amount of text to be grabbed. |
4959 */ | 4959 */ |
4960 void dw_mle_export(HWND handle, char *buffer, int startpoint, int length) | 4960 void API dw_mle_export(HWND handle, char *buffer, int startpoint, int length) |
4961 { | 4961 { |
4962 PBYTE mlebuf; | 4962 PBYTE mlebuf; |
4963 | 4963 |
4964 /* Work around 64K limit */ | 4964 /* Work around 64K limit */ |
4965 if(!DosAllocMem((PPVOID) &mlebuf, 65535, PAG_COMMIT | PAG_READ | PAG_WRITE | OBJ_TILE)) | 4965 if(!DosAllocMem((PPVOID) &mlebuf, 65535, PAG_COMMIT | PAG_READ | PAG_WRITE | OBJ_TILE)) |
4994 * Parameters: | 4994 * Parameters: |
4995 * handle: Handle to the MLE to be queried. | 4995 * handle: Handle to the MLE to be queried. |
4996 * bytes: A pointer to a variable to return the total bytes. | 4996 * bytes: A pointer to a variable to return the total bytes. |
4997 * lines: A pointer to a variable to return the number of lines. | 4997 * lines: A pointer to a variable to return the number of lines. |
4998 */ | 4998 */ |
4999 void dw_mle_query(HWND handle, unsigned long *bytes, unsigned long *lines) | 4999 void API dw_mle_query(HWND handle, unsigned long *bytes, unsigned long *lines) |
5000 { | 5000 { |
5001 if(bytes) | 5001 if(bytes) |
5002 *bytes = (unsigned long)WinSendMsg(handle, MLM_QUERYTEXTLENGTH, 0, 0); | 5002 *bytes = (unsigned long)WinSendMsg(handle, MLM_QUERYTEXTLENGTH, 0, 0); |
5003 if(lines) | 5003 if(lines) |
5004 *lines = (unsigned long)WinSendMsg(handle, MLM_QUERYLINECOUNT, 0, 0); | 5004 *lines = (unsigned long)WinSendMsg(handle, MLM_QUERYLINECOUNT, 0, 0); |
5009 * Parameters: | 5009 * Parameters: |
5010 * handle: Handle to the MLE to be deleted from. | 5010 * handle: Handle to the MLE to be deleted from. |
5011 * startpoint: Point to start deleting text. | 5011 * startpoint: Point to start deleting text. |
5012 * length: Amount of text to be deleted. | 5012 * length: Amount of text to be deleted. |
5013 */ | 5013 */ |
5014 void dw_mle_delete(HWND handle, int startpoint, int length) | 5014 void API dw_mle_delete(HWND handle, int startpoint, int length) |
5015 { | 5015 { |
5016 char *buf = malloc(length+1); | 5016 char *buf = malloc(length+1); |
5017 int z, dellen = length; | 5017 int z, dellen = length; |
5018 | 5018 |
5019 dw_mle_export(handle, buf, startpoint, length); | 5019 dw_mle_export(handle, buf, startpoint, length); |
5030 /* | 5030 /* |
5031 * Clears all text from an MLE box. | 5031 * Clears all text from an MLE box. |
5032 * Parameters: | 5032 * Parameters: |
5033 * handle: Handle to the MLE to be cleared. | 5033 * handle: Handle to the MLE to be cleared. |
5034 */ | 5034 */ |
5035 void dw_mle_clear(HWND handle) | 5035 void API dw_mle_clear(HWND handle) |
5036 { | 5036 { |
5037 unsigned long bytes; | 5037 unsigned long bytes; |
5038 | 5038 |
5039 dw_mle_query(handle, &bytes, NULL); | 5039 dw_mle_query(handle, &bytes, NULL); |
5040 | 5040 |
5045 * Sets the visible line of an MLE box. | 5045 * Sets the visible line of an MLE box. |
5046 * Parameters: | 5046 * Parameters: |
5047 * handle: Handle to the MLE to be positioned. | 5047 * handle: Handle to the MLE to be positioned. |
5048 * line: Line to be visible. | 5048 * line: Line to be visible. |
5049 */ | 5049 */ |
5050 void dw_mle_set_visible(HWND handle, int line) | 5050 void API dw_mle_set_visible(HWND handle, int line) |
5051 { | 5051 { |
5052 int tmppnt = (int)WinSendMsg(handle, MLM_CHARFROMLINE, MPFROMLONG(line), 0); | 5052 int tmppnt = (int)WinSendMsg(handle, MLM_CHARFROMLINE, MPFROMLONG(line), 0); |
5053 WinSendMsg(handle, MLM_SETSEL, MPFROMLONG(tmppnt), MPFROMLONG(tmppnt)); | 5053 WinSendMsg(handle, MLM_SETSEL, MPFROMLONG(tmppnt), MPFROMLONG(tmppnt)); |
5054 } | 5054 } |
5055 | 5055 |
5057 * Sets the editablity of an MLE box. | 5057 * Sets the editablity of an MLE box. |
5058 * Parameters: | 5058 * Parameters: |
5059 * handle: Handle to the MLE. | 5059 * handle: Handle to the MLE. |
5060 * state: TRUE if it can be edited, FALSE for readonly. | 5060 * state: TRUE if it can be edited, FALSE for readonly. |
5061 */ | 5061 */ |
5062 void dw_mle_set_editable(HWND handle, int state) | 5062 void API dw_mle_set_editable(HWND handle, int state) |
5063 { | 5063 { |
5064 WinSendMsg(handle, MLM_SETREADONLY, MPFROMLONG(state ? FALSE : TRUE), 0); | 5064 WinSendMsg(handle, MLM_SETREADONLY, MPFROMLONG(state ? FALSE : TRUE), 0); |
5065 } | 5065 } |
5066 | 5066 |
5067 /* | 5067 /* |
5068 * Sets the word wrap state of an MLE box. | 5068 * Sets the word wrap state of an MLE box. |
5069 * Parameters: | 5069 * Parameters: |
5070 * handle: Handle to the MLE. | 5070 * handle: Handle to the MLE. |
5071 * state: TRUE if it wraps, FALSE if it doesn't. | 5071 * state: TRUE if it wraps, FALSE if it doesn't. |
5072 */ | 5072 */ |
5073 void dw_mle_set_word_wrap(HWND handle, int state) | 5073 void API dw_mle_set_word_wrap(HWND handle, int state) |
5074 { | 5074 { |
5075 WinSendMsg(handle, MLM_SETWRAP, MPFROMLONG(state), 0); | 5075 WinSendMsg(handle, MLM_SETWRAP, MPFROMLONG(state), 0); |
5076 } | 5076 } |
5077 | 5077 |
5078 /* | 5078 /* |
5079 * Sets the current cursor position of an MLE box. | 5079 * Sets the current cursor position of an MLE box. |
5080 * Parameters: | 5080 * Parameters: |
5081 * handle: Handle to the MLE to be positioned. | 5081 * handle: Handle to the MLE to be positioned. |
5082 * point: Point to position cursor. | 5082 * point: Point to position cursor. |
5083 */ | 5083 */ |
5084 void dw_mle_set(HWND handle, int point) | 5084 void API dw_mle_set(HWND handle, int point) |
5085 { | 5085 { |
5086 WinSendMsg(handle, MLM_SETSEL, MPFROMLONG(point), MPFROMLONG(point)); | 5086 WinSendMsg(handle, MLM_SETSEL, MPFROMLONG(point), MPFROMLONG(point)); |
5087 } | 5087 } |
5088 | 5088 |
5089 /* | 5089 /* |
5092 * handle: Handle to the MLE to be cleared. | 5092 * handle: Handle to the MLE to be cleared. |
5093 * text: Text to search for. | 5093 * text: Text to search for. |
5094 * point: Start point of search. | 5094 * point: Start point of search. |
5095 * flags: Search specific flags. | 5095 * flags: Search specific flags. |
5096 */ | 5096 */ |
5097 int dw_mle_search(HWND handle, char *text, int point, unsigned long flags) | 5097 int API dw_mle_search(HWND handle, char *text, int point, unsigned long flags) |
5098 { | 5098 { |
5099 MLE_SEARCHDATA msd; | 5099 MLE_SEARCHDATA msd; |
5100 | 5100 |
5101 /* This code breaks with structure packing set to 1 (/Sp1 in VAC) | 5101 /* This code breaks with structure packing set to 1 (/Sp1 in VAC) |
5102 * if this is needed we need to add a pragma here. | 5102 * if this is needed we need to add a pragma here. |
5117 /* | 5117 /* |
5118 * Stops redrawing of an MLE box. | 5118 * Stops redrawing of an MLE box. |
5119 * Parameters: | 5119 * Parameters: |
5120 * handle: Handle to the MLE to freeze. | 5120 * handle: Handle to the MLE to freeze. |
5121 */ | 5121 */ |
5122 void dw_mle_freeze(HWND handle) | 5122 void API dw_mle_freeze(HWND handle) |
5123 { | 5123 { |
5124 WinSendMsg(handle, MLM_DISABLEREFRESH, 0, 0); | 5124 WinSendMsg(handle, MLM_DISABLEREFRESH, 0, 0); |
5125 } | 5125 } |
5126 | 5126 |
5127 /* | 5127 /* |
5128 * Resumes redrawing of an MLE box. | 5128 * Resumes redrawing of an MLE box. |
5129 * Parameters: | 5129 * Parameters: |
5130 * handle: Handle to the MLE to thaw. | 5130 * handle: Handle to the MLE to thaw. |
5131 */ | 5131 */ |
5132 void dw_mle_thaw(HWND handle) | 5132 void API dw_mle_thaw(HWND handle) |
5133 { | 5133 { |
5134 WinSendMsg(handle, MLM_ENABLEREFRESH, 0, 0); | 5134 WinSendMsg(handle, MLM_ENABLEREFRESH, 0, 0); |
5135 } | 5135 } |
5136 | 5136 |
5137 /* | 5137 /* |
5138 * Returns the range of the percent bar. | 5138 * Returns the range of the percent bar. |
5139 * Parameters: | 5139 * Parameters: |
5140 * handle: Handle to the percent bar to be queried. | 5140 * handle: Handle to the percent bar to be queried. |
5141 */ | 5141 */ |
5142 unsigned int dw_percent_query_range(HWND handle) | 5142 unsigned int API dw_percent_query_range(HWND handle) |
5143 { | 5143 { |
5144 return SHORT2FROMMP(WinSendMsg(handle, SLM_QUERYSLIDERINFO, MPFROM2SHORT(SMA_SLIDERARMPOSITION,SMA_RANGEVALUE), 0)); | 5144 return SHORT2FROMMP(WinSendMsg(handle, SLM_QUERYSLIDERINFO, MPFROM2SHORT(SMA_SLIDERARMPOSITION,SMA_RANGEVALUE), 0)); |
5145 } | 5145 } |
5146 | 5146 |
5147 /* | 5147 /* |
5148 * Sets the percent bar position. | 5148 * Sets the percent bar position. |
5149 * Parameters: | 5149 * Parameters: |
5150 * handle: Handle to the percent bar to be set. | 5150 * handle: Handle to the percent bar to be set. |
5151 * position: Position of the percent bar withing the range. | 5151 * position: Position of the percent bar withing the range. |
5152 */ | 5152 */ |
5153 void dw_percent_set_pos(HWND handle, unsigned int position) | 5153 void API dw_percent_set_pos(HWND handle, unsigned int position) |
5154 { | 5154 { |
5155 _dw_int_set(handle, position); | 5155 _dw_int_set(handle, position); |
5156 WinSendMsg(handle, SLM_SETSLIDERINFO, MPFROM2SHORT(SMA_SLIDERARMPOSITION,SMA_RANGEVALUE), (MPARAM)position); | 5156 WinSendMsg(handle, SLM_SETSLIDERINFO, MPFROM2SHORT(SMA_SLIDERARMPOSITION,SMA_RANGEVALUE), (MPARAM)position); |
5157 } | 5157 } |
5158 | 5158 |
5159 /* | 5159 /* |
5160 * Returns the position of the slider. | 5160 * Returns the position of the slider. |
5161 * Parameters: | 5161 * Parameters: |
5162 * handle: Handle to the slider to be queried. | 5162 * handle: Handle to the slider to be queried. |
5163 */ | 5163 */ |
5164 unsigned int dw_slider_query_pos(HWND handle) | 5164 unsigned int API dw_slider_query_pos(HWND handle) |
5165 { | 5165 { |
5166 return (unsigned int)WinSendMsg(handle, SLM_QUERYSLIDERINFO, MPFROM2SHORT(SMA_SLIDERARMPOSITION, SMA_INCREMENTVALUE), 0); | 5166 return (unsigned int)WinSendMsg(handle, SLM_QUERYSLIDERINFO, MPFROM2SHORT(SMA_SLIDERARMPOSITION, SMA_INCREMENTVALUE), 0); |
5167 } | 5167 } |
5168 | 5168 |
5169 /* | 5169 /* |
5170 * Sets the slider position. | 5170 * Sets the slider position. |
5171 * Parameters: | 5171 * Parameters: |
5172 * handle: Handle to the slider to be set. | 5172 * handle: Handle to the slider to be set. |
5173 * position: Position of the slider withing the range. | 5173 * position: Position of the slider withing the range. |
5174 */ | 5174 */ |
5175 void dw_slider_set_pos(HWND handle, unsigned int position) | 5175 void API dw_slider_set_pos(HWND handle, unsigned int position) |
5176 { | 5176 { |
5177 dw_window_set_data(handle, "_dw_slider_value", (void *)position); | 5177 dw_window_set_data(handle, "_dw_slider_value", (void *)position); |
5178 WinSendMsg(handle, SLM_SETSLIDERINFO, MPFROM2SHORT(SMA_SLIDERARMPOSITION, SMA_INCREMENTVALUE), (MPARAM)position); | 5178 WinSendMsg(handle, SLM_SETSLIDERINFO, MPFROM2SHORT(SMA_SLIDERARMPOSITION, SMA_INCREMENTVALUE), (MPARAM)position); |
5179 } | 5179 } |
5180 | 5180 |
5182 * Sets the spinbutton value. | 5182 * Sets the spinbutton value. |
5183 * Parameters: | 5183 * Parameters: |
5184 * handle: Handle to the spinbutton to be set. | 5184 * handle: Handle to the spinbutton to be set. |
5185 * position: Current value of the spinbutton. | 5185 * position: Current value of the spinbutton. |
5186 */ | 5186 */ |
5187 void dw_spinbutton_set_pos(HWND handle, long position) | 5187 void API dw_spinbutton_set_pos(HWND handle, long position) |
5188 { | 5188 { |
5189 WinSendMsg(handle, SPBM_SETCURRENTVALUE, MPFROMLONG((long)position), 0L); | 5189 WinSendMsg(handle, SPBM_SETCURRENTVALUE, MPFROMLONG((long)position), 0L); |
5190 } | 5190 } |
5191 | 5191 |
5192 /* | 5192 /* |
5194 * Parameters: | 5194 * Parameters: |
5195 * handle: Handle to the spinbutton to be set. | 5195 * handle: Handle to the spinbutton to be set. |
5196 * upper: Upper limit. | 5196 * upper: Upper limit. |
5197 * lower: Lower limit. | 5197 * lower: Lower limit. |
5198 */ | 5198 */ |
5199 void dw_spinbutton_set_limits(HWND handle, long upper, long lower) | 5199 void API dw_spinbutton_set_limits(HWND handle, long upper, long lower) |
5200 { | 5200 { |
5201 WinSendMsg(handle, SPBM_SETLIMITS, MPFROMLONG(upper), MPFROMLONG(lower)); | 5201 WinSendMsg(handle, SPBM_SETLIMITS, MPFROMLONG(upper), MPFROMLONG(lower)); |
5202 } | 5202 } |
5203 | 5203 |
5204 /* | 5204 /* |
5205 * Sets the entryfield character limit. | 5205 * Sets the entryfield character limit. |
5206 * Parameters: | 5206 * Parameters: |
5207 * handle: Handle to the spinbutton to be set. | 5207 * handle: Handle to the spinbutton to be set. |
5208 * limit: Number of characters the entryfield will take. | 5208 * limit: Number of characters the entryfield will take. |
5209 */ | 5209 */ |
5210 void dw_entryfield_set_limit(HWND handle, ULONG limit) | 5210 void API dw_entryfield_set_limit(HWND handle, ULONG limit) |
5211 { | 5211 { |
5212 WinSendMsg(handle, EM_SETTEXTLIMIT, (MPARAM)limit, (MPARAM)0); | 5212 WinSendMsg(handle, EM_SETTEXTLIMIT, (MPARAM)limit, (MPARAM)0); |
5213 } | 5213 } |
5214 | 5214 |
5215 | 5215 |
5216 /* | 5216 /* |
5217 * Returns the current value of the spinbutton. | 5217 * Returns the current value of the spinbutton. |
5218 * Parameters: | 5218 * Parameters: |
5219 * handle: Handle to the spinbutton to be queried. | 5219 * handle: Handle to the spinbutton to be queried. |
5220 */ | 5220 */ |
5221 long dw_spinbutton_query(HWND handle) | 5221 long API dw_spinbutton_query(HWND handle) |
5222 { | 5222 { |
5223 long tmpval = 0L; | 5223 long tmpval = 0L; |
5224 | 5224 |
5225 WinSendMsg(handle, SPBM_QUERYVALUE, (MPARAM)&tmpval,0L); | 5225 WinSendMsg(handle, SPBM_QUERYVALUE, (MPARAM)&tmpval,0L); |
5226 return tmpval; | 5226 return tmpval; |
5229 /* | 5229 /* |
5230 * Returns the state of the checkbox. | 5230 * Returns the state of the checkbox. |
5231 * Parameters: | 5231 * Parameters: |
5232 * handle: Handle to the checkbox to be queried. | 5232 * handle: Handle to the checkbox to be queried. |
5233 */ | 5233 */ |
5234 int dw_checkbox_query(HWND handle) | 5234 int API dw_checkbox_query(HWND handle) |
5235 { | 5235 { |
5236 return (int)WinSendMsg(handle,BM_QUERYCHECK,0,0); | 5236 return (int)WinSendMsg(handle,BM_QUERYCHECK,0,0); |
5237 } | 5237 } |
5238 | 5238 |
5239 /* | 5239 /* |
5240 * Sets the state of the checkbox. | 5240 * Sets the state of the checkbox. |
5241 * Parameters: | 5241 * Parameters: |
5242 * handle: Handle to the checkbox to be queried. | 5242 * handle: Handle to the checkbox to be queried. |
5243 * value: TRUE for checked, FALSE for unchecked. | 5243 * value: TRUE for checked, FALSE for unchecked. |
5244 */ | 5244 */ |
5245 void dw_checkbox_set(HWND handle, int value) | 5245 void API dw_checkbox_set(HWND handle, int value) |
5246 { | 5246 { |
5247 WinSendMsg(handle,BM_SETCHECK,MPFROMSHORT(value),0); | 5247 WinSendMsg(handle,BM_SETCHECK,MPFROMSHORT(value),0); |
5248 } | 5248 } |
5249 | 5249 |
5250 /* | 5250 /* |
5255 * title: The text title of the entry. | 5255 * title: The text title of the entry. |
5256 * icon: Handle to coresponding icon. | 5256 * icon: Handle to coresponding icon. |
5257 * parent: Parent handle or 0 if root. | 5257 * parent: Parent handle or 0 if root. |
5258 * itemdata: Item specific data. | 5258 * itemdata: Item specific data. |
5259 */ | 5259 */ |
5260 HWND dw_tree_insert_after(HWND handle, HWND item, char *title, unsigned long icon, HWND parent, void *itemdata) | 5260 HWND API dw_tree_insert_after(HWND handle, HWND item, char *title, unsigned long icon, HWND parent, void *itemdata) |
5261 { | 5261 { |
5262 ULONG cbExtra; | 5262 ULONG cbExtra; |
5263 PCNRITEM pci; | 5263 PCNRITEM pci; |
5264 RECORDINSERT ri; | 5264 RECORDINSERT ri; |
5265 | 5265 |
5312 * title: The text title of the entry. | 5312 * title: The text title of the entry. |
5313 * icon: Handle to coresponding icon. | 5313 * icon: Handle to coresponding icon. |
5314 * parent: Parent handle or 0 if root. | 5314 * parent: Parent handle or 0 if root. |
5315 * itemdata: Item specific data. | 5315 * itemdata: Item specific data. |
5316 */ | 5316 */ |
5317 HWND dw_tree_insert(HWND handle, char *title, unsigned long icon, HWND parent, void *itemdata) | 5317 HWND API dw_tree_insert(HWND handle, char *title, unsigned long icon, HWND parent, void *itemdata) |
5318 { | 5318 { |
5319 return dw_tree_insert_after(handle, (HWND)CMA_END, title, icon, parent, itemdata); | 5319 return dw_tree_insert_after(handle, (HWND)CMA_END, title, icon, parent, itemdata); |
5320 } | 5320 } |
5321 | 5321 |
5322 /* | 5322 /* |
5325 * handle: Handle to the tree containing the item. | 5325 * handle: Handle to the tree containing the item. |
5326 * item: Handle of the item to be modified. | 5326 * item: Handle of the item to be modified. |
5327 * title: The text title of the entry. | 5327 * title: The text title of the entry. |
5328 * icon: Handle to coresponding icon. | 5328 * icon: Handle to coresponding icon. |
5329 */ | 5329 */ |
5330 void dw_tree_set(HWND handle, HWND item, char *title, unsigned long icon) | 5330 void API dw_tree_set(HWND handle, HWND item, char *title, unsigned long icon) |
5331 { | 5331 { |
5332 PCNRITEM pci = (PCNRITEM)item; | 5332 PCNRITEM pci = (PCNRITEM)item; |
5333 | 5333 |
5334 if(!pci) | 5334 if(!pci) |
5335 return; | 5335 return; |
5350 * Parameters: | 5350 * Parameters: |
5351 * handle: Handle to the tree containing the item. | 5351 * handle: Handle to the tree containing the item. |
5352 * item: Handle of the item to be modified. | 5352 * item: Handle of the item to be modified. |
5353 * itemdata: User defined data to be associated with item. | 5353 * itemdata: User defined data to be associated with item. |
5354 */ | 5354 */ |
5355 void dw_tree_set_data(HWND handle, HWND item, void *itemdata) | 5355 void API dw_tree_set_data(HWND handle, HWND item, void *itemdata) |
5356 { | 5356 { |
5357 PCNRITEM pci = (PCNRITEM)item; | 5357 PCNRITEM pci = (PCNRITEM)item; |
5358 | 5358 |
5359 if(!pci) | 5359 if(!pci) |
5360 return; | 5360 return; |
5366 * Sets this item as the active selection. | 5366 * Sets this item as the active selection. |
5367 * Parameters: | 5367 * Parameters: |
5368 * handle: Handle to the tree window (widget) to be selected. | 5368 * handle: Handle to the tree window (widget) to be selected. |
5369 * item: Handle to the item to be selected. | 5369 * item: Handle to the item to be selected. |
5370 */ | 5370 */ |
5371 void dw_tree_item_select(HWND handle, HWND item) | 5371 void API dw_tree_item_select(HWND handle, HWND item) |
5372 { | 5372 { |
5373 PRECORDCORE pCore = WinSendMsg(handle, CM_QUERYRECORD, (MPARAM)0L, MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER)); | 5373 PRECORDCORE pCore = WinSendMsg(handle, CM_QUERYRECORD, (MPARAM)0L, MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER)); |
5374 | 5374 |
5375 while(pCore) | 5375 while(pCore) |
5376 { | 5376 { |
5386 /* | 5386 /* |
5387 * Removes all nodes from a tree. | 5387 * Removes all nodes from a tree. |
5388 * Parameters: | 5388 * Parameters: |
5389 * handle: Handle to the window (widget) to be cleared. | 5389 * handle: Handle to the window (widget) to be cleared. |
5390 */ | 5390 */ |
5391 void dw_tree_clear(HWND handle) | 5391 void API dw_tree_clear(HWND handle) |
5392 { | 5392 { |
5393 WinSendMsg(handle, CM_REMOVERECORD, (MPARAM)0L, MPFROM2SHORT(0, CMA_INVALIDATE | CMA_FREE)); | 5393 WinSendMsg(handle, CM_REMOVERECORD, (MPARAM)0L, MPFROM2SHORT(0, CMA_INVALIDATE | CMA_FREE)); |
5394 } | 5394 } |
5395 | 5395 |
5396 /* | 5396 /* |
5397 * Expands a node on a tree. | 5397 * Expands a node on a tree. |
5398 * Parameters: | 5398 * Parameters: |
5399 * handle: Handle to the tree window (widget). | 5399 * handle: Handle to the tree window (widget). |
5400 * item: Handle to node to be expanded. | 5400 * item: Handle to node to be expanded. |
5401 */ | 5401 */ |
5402 void dw_tree_expand(HWND handle, HWND item) | 5402 void API dw_tree_expand(HWND handle, HWND item) |
5403 { | 5403 { |
5404 WinSendMsg(handle, CM_EXPANDTREE, MPFROMP(item), 0); | 5404 WinSendMsg(handle, CM_EXPANDTREE, MPFROMP(item), 0); |
5405 } | 5405 } |
5406 | 5406 |
5407 /* | 5407 /* |
5408 * Collapses a node on a tree. | 5408 * Collapses a node on a tree. |
5409 * Parameters: | 5409 * Parameters: |
5410 * handle: Handle to the tree window (widget). | 5410 * handle: Handle to the tree window (widget). |
5411 * item: Handle to node to be collapsed. | 5411 * item: Handle to node to be collapsed. |
5412 */ | 5412 */ |
5413 void dw_tree_collapse(HWND handle, HWND item) | 5413 void API dw_tree_collapse(HWND handle, HWND item) |
5414 { | 5414 { |
5415 WinSendMsg(handle, CM_COLLAPSETREE, MPFROMP(item), 0); | 5415 WinSendMsg(handle, CM_COLLAPSETREE, MPFROMP(item), 0); |
5416 } | 5416 } |
5417 | 5417 |
5418 /* | 5418 /* |
5419 * Removes a node from a tree. | 5419 * Removes a node from a tree. |
5420 * Parameters: | 5420 * Parameters: |
5421 * handle: Handle to the window (widget) to be cleared. | 5421 * handle: Handle to the window (widget) to be cleared. |
5422 * item: Handle to node to be deleted. | 5422 * item: Handle to node to be deleted. |
5423 */ | 5423 */ |
5424 void dw_tree_delete(HWND handle, HWND item) | 5424 void API dw_tree_delete(HWND handle, HWND item) |
5425 { | 5425 { |
5426 PCNRITEM pci = (PCNRITEM)item; | 5426 PCNRITEM pci = (PCNRITEM)item; |
5427 | 5427 |
5428 if(!item) | 5428 if(!item) |
5429 return; | 5429 return; |
5452 * titles: An array of strings with column text titles. | 5452 * titles: An array of strings with column text titles. |
5453 * count: The number of columns (this should match the arrays). | 5453 * count: The number of columns (this should match the arrays). |
5454 * separator: The column number that contains the main separator. | 5454 * separator: The column number that contains the main separator. |
5455 * (this item may only be used in OS/2) | 5455 * (this item may only be used in OS/2) |
5456 */ | 5456 */ |
5457 int dw_container_setup(HWND handle, unsigned long *flags, char **titles, int count, int separator) | 5457 int API dw_container_setup(HWND handle, unsigned long *flags, char **titles, int count, int separator) |
5458 { | 5458 { |
5459 PFIELDINFO details, first, left = NULL; | 5459 PFIELDINFO details, first, left = NULL; |
5460 FIELDINFOINSERT detin; | 5460 FIELDINFOINSERT detin; |
5461 CNRINFO cnri; | 5461 CNRINFO cnri; |
5462 int z; | 5462 int z; |
5545 * handle: Handle to the container to be configured. | 5545 * handle: Handle to the container to be configured. |
5546 * flags: An array of unsigned longs with column flags. | 5546 * flags: An array of unsigned longs with column flags. |
5547 * titles: An array of strings with column text titles. | 5547 * titles: An array of strings with column text titles. |
5548 * count: The number of columns (this should match the arrays). | 5548 * count: The number of columns (this should match the arrays). |
5549 */ | 5549 */ |
5550 int dw_filesystem_setup(HWND handle, unsigned long *flags, char **titles, int count) | 5550 int API dw_filesystem_setup(HWND handle, unsigned long *flags, char **titles, int count) |
5551 { | 5551 { |
5552 char **newtitles = malloc(sizeof(char *) * (count + 2)); | 5552 char **newtitles = malloc(sizeof(char *) * (count + 2)); |
5553 unsigned long *newflags = malloc(sizeof(unsigned long) * (count + 2)); | 5553 unsigned long *newflags = malloc(sizeof(unsigned long) * (count + 2)); |
5554 | 5554 |
5555 newtitles[0] = "Icon"; | 5555 newtitles[0] = "Icon"; |
5574 * module: Handle to module (DLL) in OS/2 and Windows. | 5574 * module: Handle to module (DLL) in OS/2 and Windows. |
5575 * id: A unsigned long id int the resources on OS/2 and | 5575 * id: A unsigned long id int the resources on OS/2 and |
5576 * Windows, on GTK this is converted to a pointer | 5576 * Windows, on GTK this is converted to a pointer |
5577 * to an embedded XPM. | 5577 * to an embedded XPM. |
5578 */ | 5578 */ |
5579 unsigned long dw_icon_load(unsigned long module, unsigned long id) | 5579 unsigned long API dw_icon_load(unsigned long module, unsigned long id) |
5580 { | 5580 { |
5581 return WinLoadPointer(HWND_DESKTOP,module,id); | 5581 return WinLoadPointer(HWND_DESKTOP,module,id); |
5582 } | 5582 } |
5583 | 5583 |
5584 /* | 5584 /* |
5585 * Frees a loaded resource in OS/2 and Windows. | 5585 * Frees a loaded resource in OS/2 and Windows. |
5586 * Parameters: | 5586 * Parameters: |
5587 * handle: Handle to icon returned by dw_icon_load(). | 5587 * handle: Handle to icon returned by dw_icon_load(). |
5588 */ | 5588 */ |
5589 void dw_icon_free(unsigned long handle) | 5589 void API dw_icon_free(unsigned long handle) |
5590 { | 5590 { |
5591 WinDestroyPointer(handle); | 5591 WinDestroyPointer(handle); |
5592 } | 5592 } |
5593 | 5593 |
5594 /* | 5594 /* |
5595 * Allocates memory used to populate a container. | 5595 * Allocates memory used to populate a container. |
5596 * Parameters: | 5596 * Parameters: |
5597 * handle: Handle to the container window (widget). | 5597 * handle: Handle to the container window (widget). |
5598 * rowcount: The number of items to be populated. | 5598 * rowcount: The number of items to be populated. |
5599 */ | 5599 */ |
5600 void *dw_container_alloc(HWND handle, int rowcount) | 5600 void * API dw_container_alloc(HWND handle, int rowcount) |
5601 { | 5601 { |
5602 WindowData *wd = (WindowData *)WinQueryWindowPtr(handle, QWP_USER); | 5602 WindowData *wd = (WindowData *)WinQueryWindowPtr(handle, QWP_USER); |
5603 ULONG *flags = wd ? wd->data : 0; | 5603 ULONG *flags = wd ? wd->data : 0; |
5604 int z, size = 0, totalsize, count = 0; | 5604 int z, size = 0, totalsize, count = 0; |
5605 PRECORDCORE temp; | 5605 PRECORDCORE temp; |
5723 * pointer: Pointer to the allocated memory in dw_container_alloc(). | 5723 * pointer: Pointer to the allocated memory in dw_container_alloc(). |
5724 * column: Zero based column of data being set. | 5724 * column: Zero based column of data being set. |
5725 * row: Zero based row of data being set. | 5725 * row: Zero based row of data being set. |
5726 * data: Pointer to the data to be added. | 5726 * data: Pointer to the data to be added. |
5727 */ | 5727 */ |
5728 void dw_container_set_item(HWND handle, void *pointer, int column, int row, void *data) | 5728 void API dw_container_set_item(HWND handle, void *pointer, int column, int row, void *data) |
5729 { | 5729 { |
5730 ContainerInfo *ci = (ContainerInfo *)pointer; | 5730 ContainerInfo *ci = (ContainerInfo *)pointer; |
5731 | 5731 |
5732 if(!ci) | 5732 if(!ci) |
5733 return; | 5733 return; |
5741 * handle: Handle to the container window (widget). | 5741 * handle: Handle to the container window (widget). |
5742 * column: Zero based column of data being set. | 5742 * column: Zero based column of data being set. |
5743 * row: Zero based row of data being set. | 5743 * row: Zero based row of data being set. |
5744 * data: Pointer to the data to be added. | 5744 * data: Pointer to the data to be added. |
5745 */ | 5745 */ |
5746 void dw_container_change_item(HWND handle, int column, int row, void *data) | 5746 void API dw_container_change_item(HWND handle, int column, int row, void *data) |
5747 { | 5747 { |
5748 PRECORDCORE pCore = WinSendMsg(handle, CM_QUERYRECORD, (MPARAM)0L, MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER)); | 5748 PRECORDCORE pCore = WinSendMsg(handle, CM_QUERYRECORD, (MPARAM)0L, MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER)); |
5749 int count = 0; | 5749 int count = 0; |
5750 | 5750 |
5751 while(pCore) | 5751 while(pCore) |
5768 * pointer: Pointer to the allocated memory in dw_container_alloc(). | 5768 * pointer: Pointer to the allocated memory in dw_container_alloc(). |
5769 * column: Zero based column of data being set. | 5769 * column: Zero based column of data being set. |
5770 * row: Zero based row of data being set. | 5770 * row: Zero based row of data being set. |
5771 * data: Pointer to the data to be added. | 5771 * data: Pointer to the data to be added. |
5772 */ | 5772 */ |
5773 void dw_filesystem_set_file(HWND handle, void *pointer, int row, char *filename, unsigned long icon) | 5773 void API dw_filesystem_set_file(HWND handle, void *pointer, int row, char *filename, unsigned long icon) |
5774 { | 5774 { |
5775 dw_container_set_item(handle, pointer, 0, row, (void *)&icon); | 5775 dw_container_set_item(handle, pointer, 0, row, (void *)&icon); |
5776 dw_container_set_item(handle, pointer, 1, row, (void *)&filename); | 5776 dw_container_set_item(handle, pointer, 1, row, (void *)&filename); |
5777 } | 5777 } |
5778 | 5778 |
5783 * pointer: Pointer to the allocated memory in dw_container_alloc(). | 5783 * pointer: Pointer to the allocated memory in dw_container_alloc(). |
5784 * column: Zero based column of data being set. | 5784 * column: Zero based column of data being set. |
5785 * row: Zero based row of data being set. | 5785 * row: Zero based row of data being set. |
5786 * data: Pointer to the data to be added. | 5786 * data: Pointer to the data to be added. |
5787 */ | 5787 */ |
5788 void dw_filesystem_set_item(HWND handle, void *pointer, int column, int row, void *data) | 5788 void API dw_filesystem_set_item(HWND handle, void *pointer, int column, int row, void *data) |
5789 { | 5789 { |
5790 dw_container_set_item(handle, pointer, column + 2, row, data); | 5790 dw_container_set_item(handle, pointer, column + 2, row, data); |
5791 } | 5791 } |
5792 | 5792 |
5793 /* | 5793 /* |
5795 * Parameters: | 5795 * Parameters: |
5796 * handle: Handle to window (widget) of container. | 5796 * handle: Handle to window (widget) of container. |
5797 * column: Zero based column of width being set. | 5797 * column: Zero based column of width being set. |
5798 * width: Width of column in pixels. | 5798 * width: Width of column in pixels. |
5799 */ | 5799 */ |
5800 void dw_container_set_column_width(HWND handle, int column, int width) | 5800 void API dw_container_set_column_width(HWND handle, int column, int width) |
5801 { | 5801 { |
5802 } | 5802 } |
5803 | 5803 |
5804 /* | 5804 /* |
5805 * Sets the title of a row in the container. | 5805 * Sets the title of a row in the container. |
5806 * Parameters: | 5806 * Parameters: |
5807 * pointer: Pointer to the allocated memory in dw_container_alloc(). | 5807 * pointer: Pointer to the allocated memory in dw_container_alloc(). |
5808 * row: Zero based row of data being set. | 5808 * row: Zero based row of data being set. |
5809 * title: String title of the item. | 5809 * title: String title of the item. |
5810 */ | 5810 */ |
5811 void dw_container_set_row_title(void *pointer, int row, char *title) | 5811 void API dw_container_set_row_title(void *pointer, int row, char *title) |
5812 { | 5812 { |
5813 ContainerInfo *ci = (ContainerInfo *)pointer; | 5813 ContainerInfo *ci = (ContainerInfo *)pointer; |
5814 PRECORDCORE temp; | 5814 PRECORDCORE temp; |
5815 int z, currentcount; | 5815 int z, currentcount; |
5816 CNRINFO cnr; | 5816 CNRINFO cnr; |
5844 * Parameters: | 5844 * Parameters: |
5845 * handle: Handle to the container window (widget). | 5845 * handle: Handle to the container window (widget). |
5846 * pointer: Pointer to the allocated memory in dw_container_alloc(). | 5846 * pointer: Pointer to the allocated memory in dw_container_alloc(). |
5847 * rowcount: The number of rows to be inserted. | 5847 * rowcount: The number of rows to be inserted. |
5848 */ | 5848 */ |
5849 void dw_container_insert(HWND handle, void *pointer, int rowcount) | 5849 void API dw_container_insert(HWND handle, void *pointer, int rowcount) |
5850 { | 5850 { |
5851 RECORDINSERT recin; | 5851 RECORDINSERT recin; |
5852 ContainerInfo *ci = (ContainerInfo *)pointer; | 5852 ContainerInfo *ci = (ContainerInfo *)pointer; |
5853 int z; | 5853 int z; |
5854 | 5854 |
5879 * Removes all rows from a container. | 5879 * Removes all rows from a container. |
5880 * Parameters: | 5880 * Parameters: |
5881 * handle: Handle to the window (widget) to be cleared. | 5881 * handle: Handle to the window (widget) to be cleared. |
5882 * redraw: TRUE to cause the container to redraw immediately. | 5882 * redraw: TRUE to cause the container to redraw immediately. |
5883 */ | 5883 */ |
5884 void dw_container_clear(HWND handle, int redraw) | 5884 void API dw_container_clear(HWND handle, int redraw) |
5885 { | 5885 { |
5886 int z = 0; | 5886 int z = 0; |
5887 | 5887 |
5888 while((int)WinSendMsg(handle, CM_REMOVERECORD, (MPARAM)0L, MPFROM2SHORT(0, (redraw ? CMA_INVALIDATE : 0) | CMA_FREE)) == -1) | 5888 while((int)WinSendMsg(handle, CM_REMOVERECORD, (MPARAM)0L, MPFROM2SHORT(0, (redraw ? CMA_INVALIDATE : 0) | CMA_FREE)) == -1) |
5889 { | 5889 { |
5898 * Removes the first x rows from a container. | 5898 * Removes the first x rows from a container. |
5899 * Parameters: | 5899 * Parameters: |
5900 * handle: Handle to the window (widget) to be deleted from. | 5900 * handle: Handle to the window (widget) to be deleted from. |
5901 * rowcount: The number of rows to be deleted. | 5901 * rowcount: The number of rows to be deleted. |
5902 */ | 5902 */ |
5903 void dw_container_delete(HWND handle, int rowcount) | 5903 void API dw_container_delete(HWND handle, int rowcount) |
5904 { | 5904 { |
5905 RECORDCORE *last, **prc = malloc(sizeof(RECORDCORE *) * rowcount); | 5905 RECORDCORE *last, **prc = malloc(sizeof(RECORDCORE *) * rowcount); |
5906 int current = 1, z; | 5906 int current = 1, z; |
5907 | 5907 |
5908 prc[0] = last = (RECORDCORE *)WinSendMsg(handle, CM_QUERYRECORD, (MPARAM)0L, MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER)); | 5908 prc[0] = last = (RECORDCORE *)WinSendMsg(handle, CM_QUERYRECORD, (MPARAM)0L, MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER)); |
5932 * handle: Handle to the window (widget) to be scrolled. | 5932 * handle: Handle to the window (widget) to be scrolled. |
5933 * direction: DW_SCROLL_UP, DW_SCROLL_DOWN, DW_SCROLL_TOP or | 5933 * direction: DW_SCROLL_UP, DW_SCROLL_DOWN, DW_SCROLL_TOP or |
5934 * DW_SCROLL_BOTTOM. (rows is ignored for last two) | 5934 * DW_SCROLL_BOTTOM. (rows is ignored for last two) |
5935 * rows: The number of rows to be scrolled. | 5935 * rows: The number of rows to be scrolled. |
5936 */ | 5936 */ |
5937 void dw_container_scroll(HWND handle, int direction, long rows) | 5937 void API dw_container_scroll(HWND handle, int direction, long rows) |
5938 { | 5938 { |
5939 switch(direction) | 5939 switch(direction) |
5940 { | 5940 { |
5941 case DW_SCROLL_TOP: | 5941 case DW_SCROLL_TOP: |
5942 WinSendMsg(handle, CM_SCROLLWINDOW, MPFROMSHORT(CMA_VERTICAL), MPFROMLONG(-10000000)); | 5942 WinSendMsg(handle, CM_SCROLLWINDOW, MPFROMSHORT(CMA_VERTICAL), MPFROMLONG(-10000000)); |
5950 /* | 5950 /* |
5951 * Removes all rows from a container. | 5951 * Removes all rows from a container. |
5952 * Parameters: | 5952 * Parameters: |
5953 * handle: Handle to the window (widget) to be cleared. | 5953 * handle: Handle to the window (widget) to be cleared. |
5954 */ | 5954 */ |
5955 void dw_container_set_view(HWND handle, unsigned long flags, int iconwidth, int iconheight) | 5955 void API dw_container_set_view(HWND handle, unsigned long flags, int iconwidth, int iconheight) |
5956 { | 5956 { |
5957 CNRINFO cnrinfo; | 5957 CNRINFO cnrinfo; |
5958 | 5958 |
5959 cnrinfo.flWindowAttr = flags; | 5959 cnrinfo.flWindowAttr = flags; |
5960 cnrinfo.slBitmapOrIcon.cx = iconwidth; | 5960 cnrinfo.slBitmapOrIcon.cx = iconwidth; |
5969 * handle: Handle to the window (widget) to be queried. | 5969 * handle: Handle to the window (widget) to be queried. |
5970 * flags: If this parameter is DW_CRA_SELECTED it will only | 5970 * flags: If this parameter is DW_CRA_SELECTED it will only |
5971 * return items that are currently selected. Otherwise | 5971 * return items that are currently selected. Otherwise |
5972 * it will return all records in the container. | 5972 * it will return all records in the container. |
5973 */ | 5973 */ |
5974 char *dw_container_query_start(HWND handle, unsigned long flags) | 5974 char * API dw_container_query_start(HWND handle, unsigned long flags) |
5975 { | 5975 { |
5976 pCore = WinSendMsg(handle, CM_QUERYRECORD, (MPARAM)0L, MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER)); | 5976 pCore = WinSendMsg(handle, CM_QUERYRECORD, (MPARAM)0L, MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER)); |
5977 if(pCore) | 5977 if(pCore) |
5978 { | 5978 { |
5979 if(flags) | 5979 if(flags) |
5997 * handle: Handle to the window (widget) to be queried. | 5997 * handle: Handle to the window (widget) to be queried. |
5998 * flags: If this parameter is DW_CRA_SELECTED it will only | 5998 * flags: If this parameter is DW_CRA_SELECTED it will only |
5999 * return items that are currently selected. Otherwise | 5999 * return items that are currently selected. Otherwise |
6000 * it will return all records in the container. | 6000 * it will return all records in the container. |
6001 */ | 6001 */ |
6002 char *dw_container_query_next(HWND handle, unsigned long flags) | 6002 char * API dw_container_query_next(HWND handle, unsigned long flags) |
6003 { | 6003 { |
6004 pCore = WinSendMsg(handle, CM_QUERYRECORD, (MPARAM)pCore, MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER)); | 6004 pCore = WinSendMsg(handle, CM_QUERYRECORD, (MPARAM)pCore, MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER)); |
6005 if(pCore) | 6005 if(pCore) |
6006 { | 6006 { |
6007 if(flags) | 6007 if(flags) |
6024 * Cursors the item with the text speficied, and scrolls to that item. | 6024 * Cursors the item with the text speficied, and scrolls to that item. |
6025 * Parameters: | 6025 * Parameters: |
6026 * handle: Handle to the window (widget) to be queried. | 6026 * handle: Handle to the window (widget) to be queried. |
6027 * text: Text usually returned by dw_container_query(). | 6027 * text: Text usually returned by dw_container_query(). |
6028 */ | 6028 */ |
6029 void dw_container_cursor(HWND handle, char *text) | 6029 void API dw_container_cursor(HWND handle, char *text) |
6030 { | 6030 { |
6031 RECTL viewport, item; | 6031 RECTL viewport, item; |
6032 | 6032 |
6033 pCore = WinSendMsg(handle, CM_QUERYRECORD, (MPARAM)0L, MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER)); | 6033 pCore = WinSendMsg(handle, CM_QUERYRECORD, (MPARAM)0L, MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER)); |
6034 while(pCore) | 6034 while(pCore) |
6062 * Deletes the item with the text speficied. | 6062 * Deletes the item with the text speficied. |
6063 * Parameters: | 6063 * Parameters: |
6064 * handle: Handle to the window (widget). | 6064 * handle: Handle to the window (widget). |
6065 * text: Text usually returned by dw_container_query(). | 6065 * text: Text usually returned by dw_container_query(). |
6066 */ | 6066 */ |
6067 void dw_container_delete_row(HWND handle, char *text) | 6067 void API dw_container_delete_row(HWND handle, char *text) |
6068 { | 6068 { |
6069 PRECORDCORE pCore = WinSendMsg(handle, CM_QUERYRECORD, (MPARAM)0L, MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER)); | 6069 PRECORDCORE pCore = WinSendMsg(handle, CM_QUERYRECORD, (MPARAM)0L, MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER)); |
6070 | 6070 |
6071 while(pCore) | 6071 while(pCore) |
6072 { | 6072 { |
6082 /* | 6082 /* |
6083 * Optimizes the column widths so that all data is visible. | 6083 * Optimizes the column widths so that all data is visible. |
6084 * Parameters: | 6084 * Parameters: |
6085 * handle: Handle to the window (widget) to be optimized. | 6085 * handle: Handle to the window (widget) to be optimized. |
6086 */ | 6086 */ |
6087 void dw_container_optimize(HWND handle) | 6087 void API dw_container_optimize(HWND handle) |
6088 { | 6088 { |
6089 WindowData *blah = (WindowData *)WinQueryWindowPtr(handle, QWP_USER); | 6089 WindowData *blah = (WindowData *)WinQueryWindowPtr(handle, QWP_USER); |
6090 RECTL item; | 6090 RECTL item; |
6091 PRECORDCORE pCore = NULL; | 6091 PRECORDCORE pCore = NULL; |
6092 int max = 0; | 6092 int max = 0; |
6131 * Parameters: | 6131 * Parameters: |
6132 * id: An id to be used with dw_window_from_id. | 6132 * id: An id to be used with dw_window_from_id. |
6133 * Returns: | 6133 * Returns: |
6134 * A handle to the widget or NULL on failure. | 6134 * A handle to the widget or NULL on failure. |
6135 */ | 6135 */ |
6136 HWND dw_render_new(unsigned long id) | 6136 HWND API dw_render_new(unsigned long id) |
6137 { | 6137 { |
6138 HWND hwndframe = WinCreateWindow(HWND_OBJECT, | 6138 HWND hwndframe = WinCreateWindow(HWND_OBJECT, |
6139 WC_FRAME, | 6139 WC_FRAME, |
6140 NULL, | 6140 NULL, |
6141 WS_VISIBLE | | 6141 WS_VISIBLE | |
6154 * Parameters: | 6154 * Parameters: |
6155 * red: red value. | 6155 * red: red value. |
6156 * green: green value. | 6156 * green: green value. |
6157 * blue: blue value. | 6157 * blue: blue value. |
6158 */ | 6158 */ |
6159 void dw_color_foreground_set(unsigned long value) | 6159 void API dw_color_foreground_set(unsigned long value) |
6160 { | 6160 { |
6161 _foreground = DW_RED_VALUE(value) << 16 | DW_GREEN_VALUE(value) << 8 | DW_BLUE_VALUE(value); | 6161 _foreground = DW_RED_VALUE(value) << 16 | DW_GREEN_VALUE(value) << 8 | DW_BLUE_VALUE(value); |
6162 } | 6162 } |
6163 | 6163 |
6164 /* Sets the current background drawing color. | 6164 /* Sets the current background drawing color. |
6165 * Parameters: | 6165 * Parameters: |
6166 * red: red value. | 6166 * red: red value. |
6167 * green: green value. | 6167 * green: green value. |
6168 * blue: blue value. | 6168 * blue: blue value. |
6169 */ | 6169 */ |
6170 void dw_color_background_set(unsigned long value) | 6170 void API dw_color_background_set(unsigned long value) |
6171 { | 6171 { |
6172 _background = DW_RED_VALUE(value) << 16 | DW_GREEN_VALUE(value) << 8 | DW_BLUE_VALUE(value); | 6172 _background = DW_RED_VALUE(value) << 16 | DW_GREEN_VALUE(value) << 8 | DW_BLUE_VALUE(value); |
6173 } | 6173 } |
6174 | 6174 |
6175 HPS _set_hps(HPS hps) | 6175 HPS _set_hps(HPS hps) |
6205 * handle: Handle to the window. | 6205 * handle: Handle to the window. |
6206 * pixmap: Handle to the pixmap. (choose only one of these) | 6206 * pixmap: Handle to the pixmap. (choose only one of these) |
6207 * x: X coordinate. | 6207 * x: X coordinate. |
6208 * y: Y coordinate. | 6208 * y: Y coordinate. |
6209 */ | 6209 */ |
6210 void dw_draw_point(HWND handle, HPIXMAP pixmap, int x, int y) | 6210 void API dw_draw_point(HWND handle, HPIXMAP pixmap, int x, int y) |
6211 { | 6211 { |
6212 HPS hps; | 6212 HPS hps; |
6213 int height; | 6213 int height; |
6214 POINTL ptl; | 6214 POINTL ptl; |
6215 | 6215 |
6241 * x1: First X coordinate. | 6241 * x1: First X coordinate. |
6242 * y1: First Y coordinate. | 6242 * y1: First Y coordinate. |
6243 * x2: Second X coordinate. | 6243 * x2: Second X coordinate. |
6244 * y2: Second Y coordinate. | 6244 * y2: Second Y coordinate. |
6245 */ | 6245 */ |
6246 void dw_draw_line(HWND handle, HPIXMAP pixmap, int x1, int y1, int x2, int y2) | 6246 void API dw_draw_line(HWND handle, HPIXMAP pixmap, int x1, int y1, int x2, int y2) |
6247 { | 6247 { |
6248 HPS hps; | 6248 HPS hps; |
6249 int height; | 6249 int height; |
6250 POINTL ptl[2]; | 6250 POINTL ptl[2]; |
6251 | 6251 |
6303 * pixmap: Handle to the pixmap. (choose only one of these) | 6303 * pixmap: Handle to the pixmap. (choose only one of these) |
6304 * x: X coordinate. | 6304 * x: X coordinate. |
6305 * y: Y coordinate. | 6305 * y: Y coordinate. |
6306 * text: Text to be displayed. | 6306 * text: Text to be displayed. |
6307 */ | 6307 */ |
6308 void dw_draw_text(HWND handle, HPIXMAP pixmap, int x, int y, char *text) | 6308 void API dw_draw_text(HWND handle, HPIXMAP pixmap, int x, int y, char *text) |
6309 { | 6309 { |
6310 HPS hps; | 6310 HPS hps; |
6311 int size = 9, z, height; | 6311 int size = 9, z, height; |
6312 RECTL rcl; | 6312 RECTL rcl; |
6313 char fontname[128]; | 6313 char fontname[128]; |
6355 * pixmap: Handle to the pixmap. (choose only one of these) | 6355 * pixmap: Handle to the pixmap. (choose only one of these) |
6356 * text: Text to be queried. | 6356 * text: Text to be queried. |
6357 * width: Pointer to a variable to be filled in with the width. | 6357 * width: Pointer to a variable to be filled in with the width. |
6358 * height Pointer to a variable to be filled in with the height. | 6358 * height Pointer to a variable to be filled in with the height. |
6359 */ | 6359 */ |
6360 void dw_font_text_extents(HWND handle, HPIXMAP pixmap, char *text, int *width, int *height) | 6360 void API dw_font_text_extents(HWND handle, HPIXMAP pixmap, char *text, int *width, int *height) |
6361 { | 6361 { |
6362 HPS hps; | 6362 HPS hps; |
6363 POINTL aptl[TXTBOX_COUNT]; | 6363 POINTL aptl[TXTBOX_COUNT]; |
6364 | 6364 |
6365 if(handle) | 6365 if(handle) |
6397 * x: X coordinate. | 6397 * x: X coordinate. |
6398 * y: Y coordinate. | 6398 * y: Y coordinate. |
6399 * width: Width of rectangle. | 6399 * width: Width of rectangle. |
6400 * height: Height of rectangle. | 6400 * height: Height of rectangle. |
6401 */ | 6401 */ |
6402 void dw_draw_rect(HWND handle, HPIXMAP pixmap, int fill, int x, int y, int width, int height) | 6402 void API dw_draw_rect(HWND handle, HPIXMAP pixmap, int fill, int x, int y, int width, int height) |
6403 { | 6403 { |
6404 HPS hps; | 6404 HPS hps; |
6405 int thisheight; | 6405 int thisheight; |
6406 POINTL ptl[2]; | 6406 POINTL ptl[2]; |
6407 | 6407 |
6431 } | 6431 } |
6432 | 6432 |
6433 /* Call this after drawing to the screen to make sure | 6433 /* Call this after drawing to the screen to make sure |
6434 * anything you have drawn is visible. | 6434 * anything you have drawn is visible. |
6435 */ | 6435 */ |
6436 void dw_flush(void) | 6436 void API dw_flush(void) |
6437 { | 6437 { |
6438 } | 6438 } |
6439 | 6439 |
6440 /* | 6440 /* |
6441 * Creates a pixmap with given parameters. | 6441 * Creates a pixmap with given parameters. |
6445 * height: Height of the pixmap in pixels. | 6445 * height: Height of the pixmap in pixels. |
6446 * depth: Color depth of the pixmap. | 6446 * depth: Color depth of the pixmap. |
6447 * Returns: | 6447 * Returns: |
6448 * A handle to a pixmap or NULL on failure. | 6448 * A handle to a pixmap or NULL on failure. |
6449 */ | 6449 */ |
6450 HPIXMAP dw_pixmap_new(HWND handle, unsigned long width, unsigned long height, int depth) | 6450 HPIXMAP API dw_pixmap_new(HWND handle, unsigned long width, unsigned long height, int depth) |
6451 { | 6451 { |
6452 BITMAPINFOHEADER bmih; | 6452 BITMAPINFOHEADER bmih; |
6453 SIZEL sizl = { 0, 0 }; | 6453 SIZEL sizl = { 0, 0 }; |
6454 HPIXMAP pixmap; | 6454 HPIXMAP pixmap; |
6455 HDC hdc; | 6455 HDC hdc; |
6503 * handle: Window handle the pixmap is associated with. | 6503 * handle: Window handle the pixmap is associated with. |
6504 * id: Resource ID associated with requested pixmap. | 6504 * id: Resource ID associated with requested pixmap. |
6505 * Returns: | 6505 * Returns: |
6506 * A handle to a pixmap or NULL on failure. | 6506 * A handle to a pixmap or NULL on failure. |
6507 */ | 6507 */ |
6508 HPIXMAP dw_pixmap_grab(HWND handle, ULONG id) | 6508 HPIXMAP API dw_pixmap_grab(HWND handle, ULONG id) |
6509 { | 6509 { |
6510 BITMAPINFOHEADER bmih; | 6510 BITMAPINFOHEADER bmih; |
6511 SIZEL sizl = { 0, 0 }; | 6511 SIZEL sizl = { 0, 0 }; |
6512 HPIXMAP pixmap; | 6512 HPIXMAP pixmap; |
6513 HDC hdc; | 6513 HDC hdc; |
6542 * Destroys an allocated pixmap. | 6542 * Destroys an allocated pixmap. |
6543 * Parameters: | 6543 * Parameters: |
6544 * pixmap: Handle to a pixmap returned by | 6544 * pixmap: Handle to a pixmap returned by |
6545 * dw_pixmap_new.. | 6545 * dw_pixmap_new.. |
6546 */ | 6546 */ |
6547 void dw_pixmap_destroy(HPIXMAP pixmap) | 6547 void API dw_pixmap_destroy(HPIXMAP pixmap) |
6548 { | 6548 { |
6549 GpiSetBitmap(pixmap->hps, NULLHANDLE); | 6549 GpiSetBitmap(pixmap->hps, NULLHANDLE); |
6550 GpiDeleteBitmap(pixmap->hbm); | 6550 GpiDeleteBitmap(pixmap->hbm); |
6551 GpiAssociate(pixmap->hps, NULLHANDLE); | 6551 GpiAssociate(pixmap->hps, NULLHANDLE); |
6552 GpiDestroyPS(pixmap->hps); | 6552 GpiDestroyPS(pixmap->hps); |
6566 * src: Source window handle. | 6566 * src: Source window handle. |
6567 * srcp: Source pixmap. (choose only one). | 6567 * srcp: Source pixmap. (choose only one). |
6568 * xsrc: X coordinate of source. | 6568 * xsrc: X coordinate of source. |
6569 * ysrc: Y coordinate of source. | 6569 * ysrc: Y coordinate of source. |
6570 */ | 6570 */ |
6571 void dw_pixmap_bitblt(HWND dest, HPIXMAP destp, int xdest, int ydest, int width, int height, HWND src, HPIXMAP srcp, int xsrc, int ysrc) | 6571 void API dw_pixmap_bitblt(HWND dest, HPIXMAP destp, int xdest, int ydest, int width, int height, HWND src, HPIXMAP srcp, int xsrc, int ysrc) |
6572 { | 6572 { |
6573 HPS hpsdest; | 6573 HPS hpsdest; |
6574 HPS hpssrc; | 6574 HPS hpssrc; |
6575 POINTL ptl[4]; | 6575 POINTL ptl[4]; |
6576 int destheight, srcheight; | 6576 int destheight, srcheight; |
6626 * Emits a beep. | 6626 * Emits a beep. |
6627 * Parameters: | 6627 * Parameters: |
6628 * freq: Frequency. | 6628 * freq: Frequency. |
6629 * dur: Duration. | 6629 * dur: Duration. |
6630 */ | 6630 */ |
6631 void dw_beep(int freq, int dur) | 6631 void API dw_beep(int freq, int dur) |
6632 { | 6632 { |
6633 DosBeep(freq, dur); | 6633 DosBeep(freq, dur); |
6634 } | 6634 } |
6635 | 6635 |
6636 /* Open a shared library and return a handle. | 6636 /* Open a shared library and return a handle. |
6637 * Parameters: | 6637 * Parameters: |
6638 * name: Base name of the shared library. | 6638 * name: Base name of the shared library. |
6639 * handle: Pointer to a module handle, | 6639 * handle: Pointer to a module handle, |
6640 * will be filled in with the handle. | 6640 * will be filled in with the handle. |
6641 */ | 6641 */ |
6642 int dw_module_load(char *name, HMOD *handle) | 6642 int API dw_module_load(char *name, HMOD *handle) |
6643 { | 6643 { |
6644 char objnamebuf[300] = ""; | 6644 char objnamebuf[300] = ""; |
6645 | 6645 |
6646 return DosLoadModule(objnamebuf, sizeof(objnamebuf), name, handle); | 6646 return DosLoadModule(objnamebuf, sizeof(objnamebuf), name, handle); |
6647 } | 6647 } |
6651 * handle: Module handle returned by dw_module_load() | 6651 * handle: Module handle returned by dw_module_load() |
6652 * name: Name of the symbol you want the address of. | 6652 * name: Name of the symbol you want the address of. |
6653 * func: A pointer to a function pointer, to obtain | 6653 * func: A pointer to a function pointer, to obtain |
6654 * the address. | 6654 * the address. |
6655 */ | 6655 */ |
6656 int dw_module_symbol(HMOD handle, char *name, void**func) | 6656 int API dw_module_symbol(HMOD handle, char *name, void**func) |
6657 { | 6657 { |
6658 return DosQueryProcAddr(handle, 0, name, (PFN*)func); | 6658 return DosQueryProcAddr(handle, 0, name, (PFN*)func); |
6659 } | 6659 } |
6660 | 6660 |
6661 /* Frees the shared library previously opened. | 6661 /* Frees the shared library previously opened. |
6662 * Parameters: | 6662 * Parameters: |
6663 * handle: Module handle returned by dw_module_load() | 6663 * handle: Module handle returned by dw_module_load() |
6664 */ | 6664 */ |
6665 int dw_module_close(HMOD handle) | 6665 int API dw_module_close(HMOD handle) |
6666 { | 6666 { |
6667 DosFreeModule(handle); | 6667 DosFreeModule(handle); |
6668 return 0; | 6668 return 0; |
6669 } | 6669 } |
6670 | 6670 |
6671 /* | 6671 /* |
6672 * Returns the handle to an unnamed mutex semaphore. | 6672 * Returns the handle to an unnamed mutex semaphore. |
6673 */ | 6673 */ |
6674 HMTX dw_mutex_new(void) | 6674 HMTX API dw_mutex_new(void) |
6675 { | 6675 { |
6676 HMTX mutex; | 6676 HMTX mutex; |
6677 | 6677 |
6678 DosCreateMutexSem(NULL, &mutex, 0, FALSE); | 6678 DosCreateMutexSem(NULL, &mutex, 0, FALSE); |
6679 return mutex; | 6679 return mutex; |
6682 /* | 6682 /* |
6683 * Closes a semaphore created by dw_mutex_new(). | 6683 * Closes a semaphore created by dw_mutex_new(). |
6684 * Parameters: | 6684 * Parameters: |
6685 * mutex: The handle to the mutex returned by dw_mutex_new(). | 6685 * mutex: The handle to the mutex returned by dw_mutex_new(). |
6686 */ | 6686 */ |
6687 void dw_mutex_close(HMTX mutex) | 6687 void API dw_mutex_close(HMTX mutex) |
6688 { | 6688 { |
6689 DosCloseMutexSem(mutex); | 6689 DosCloseMutexSem(mutex); |
6690 } | 6690 } |
6691 | 6691 |
6692 /* | 6692 /* |
6694 * If we are in a callback we must keep the message loop running | 6694 * If we are in a callback we must keep the message loop running |
6695 * while blocking. | 6695 * while blocking. |
6696 * Parameters: | 6696 * Parameters: |
6697 * mutex: The handle to the mutex returned by dw_mutex_new(). | 6697 * mutex: The handle to the mutex returned by dw_mutex_new(). |
6698 */ | 6698 */ |
6699 void dw_mutex_lock(HMTX mutex) | 6699 void API dw_mutex_lock(HMTX mutex) |
6700 { | 6700 { |
6701 if(_dwtid == dw_thread_id()) | 6701 if(_dwtid == dw_thread_id()) |
6702 { | 6702 { |
6703 int rc = DosRequestMutexSem(mutex, SEM_IMMEDIATE_RETURN); | 6703 int rc = DosRequestMutexSem(mutex, SEM_IMMEDIATE_RETURN); |
6704 | 6704 |
6715 /* | 6715 /* |
6716 * Reliquishes the access to the semaphore. | 6716 * Reliquishes the access to the semaphore. |
6717 * Parameters: | 6717 * Parameters: |
6718 * mutex: The handle to the mutex returned by dw_mutex_new(). | 6718 * mutex: The handle to the mutex returned by dw_mutex_new(). |
6719 */ | 6719 */ |
6720 void dw_mutex_unlock(HMTX mutex) | 6720 void API dw_mutex_unlock(HMTX mutex) |
6721 { | 6721 { |
6722 DosReleaseMutexSem(mutex); | 6722 DosReleaseMutexSem(mutex); |
6723 } | 6723 } |
6724 | 6724 |
6725 /* | 6725 /* |
6726 * Returns the handle to an unnamed event semaphore. | 6726 * Returns the handle to an unnamed event semaphore. |
6727 */ | 6727 */ |
6728 HEV dw_event_new(void) | 6728 HEV API dw_event_new(void) |
6729 { | 6729 { |
6730 HEV blah; | 6730 HEV blah; |
6731 | 6731 |
6732 if(DosCreateEventSem (NULL, &blah, 0L, FALSE)) | 6732 if(DosCreateEventSem (NULL, &blah, 0L, FALSE)) |
6733 return 0; | 6733 return 0; |
6738 /* | 6738 /* |
6739 * Resets a semaphore created by dw_event_new(). | 6739 * Resets a semaphore created by dw_event_new(). |
6740 * Parameters: | 6740 * Parameters: |
6741 * eve: The handle to the event returned by dw_event_new(). | 6741 * eve: The handle to the event returned by dw_event_new(). |
6742 */ | 6742 */ |
6743 int dw_event_reset(HEV eve) | 6743 int API dw_event_reset(HEV eve) |
6744 { | 6744 { |
6745 ULONG count; | 6745 ULONG count; |
6746 | 6746 |
6747 if(DosResetEventSem(eve, &count)) | 6747 if(DosResetEventSem(eve, &count)) |
6748 return FALSE; | 6748 return FALSE; |
6753 * Posts a semaphore created by dw_event_new(). Causing all threads | 6753 * Posts a semaphore created by dw_event_new(). Causing all threads |
6754 * waiting on this event in dw_event_wait to continue. | 6754 * waiting on this event in dw_event_wait to continue. |
6755 * Parameters: | 6755 * Parameters: |
6756 * eve: The handle to the event returned by dw_event_new(). | 6756 * eve: The handle to the event returned by dw_event_new(). |
6757 */ | 6757 */ |
6758 int dw_event_post(HEV eve) | 6758 int API dw_event_post(HEV eve) |
6759 { | 6759 { |
6760 if(DosPostEventSem(eve)) | 6760 if(DosPostEventSem(eve)) |
6761 return FALSE; | 6761 return FALSE; |
6762 return TRUE; | 6762 return TRUE; |
6763 } | 6763 } |
6767 * Waits on a semaphore created by dw_event_new(), until the | 6767 * Waits on a semaphore created by dw_event_new(), until the |
6768 * event gets posted or until the timeout expires. | 6768 * event gets posted or until the timeout expires. |
6769 * Parameters: | 6769 * Parameters: |
6770 * eve: The handle to the event returned by dw_event_new(). | 6770 * eve: The handle to the event returned by dw_event_new(). |
6771 */ | 6771 */ |
6772 int dw_event_wait(HEV eve, unsigned long timeout) | 6772 int API dw_event_wait(HEV eve, unsigned long timeout) |
6773 { | 6773 { |
6774 int rc = DosWaitEventSem(eve, timeout); | 6774 int rc = DosWaitEventSem(eve, timeout); |
6775 if(!rc) | 6775 if(!rc) |
6776 return 1; | 6776 return 1; |
6777 if(rc == ERROR_TIMEOUT) | 6777 if(rc == ERROR_TIMEOUT) |
6782 /* | 6782 /* |
6783 * Closes a semaphore created by dw_event_new(). | 6783 * Closes a semaphore created by dw_event_new(). |
6784 * Parameters: | 6784 * Parameters: |
6785 * eve: The handle to the event returned by dw_event_new(). | 6785 * eve: The handle to the event returned by dw_event_new(). |
6786 */ | 6786 */ |
6787 int dw_event_close(HEV *eve) | 6787 int API dw_event_close(HEV *eve) |
6788 { | 6788 { |
6789 if(!eve || ~DosCloseEventSem(*eve)) | 6789 if(!eve || ~DosCloseEventSem(*eve)) |
6790 return FALSE; | 6790 return FALSE; |
6791 return TRUE; | 6791 return TRUE; |
6792 } | 6792 } |
6815 * Parameters: | 6815 * Parameters: |
6816 * func: Function which will be run in the new thread. | 6816 * func: Function which will be run in the new thread. |
6817 * data: Parameter(s) passed to the function. | 6817 * data: Parameter(s) passed to the function. |
6818 * stack: Stack size of new thread (OS/2 and Windows only). | 6818 * stack: Stack size of new thread (OS/2 and Windows only). |
6819 */ | 6819 */ |
6820 DWTID dw_thread_new(void *func, void *data, int stack) | 6820 DWTID API dw_thread_new(void *func, void *data, int stack) |
6821 { | 6821 { |
6822 void **tmp = malloc(sizeof(void *) * 2); | 6822 void **tmp = malloc(sizeof(void *) * 2); |
6823 | 6823 |
6824 tmp[0] = func; | 6824 tmp[0] = func; |
6825 tmp[1] = data; | 6825 tmp[1] = data; |
6828 } | 6828 } |
6829 | 6829 |
6830 /* | 6830 /* |
6831 * Ends execution of current thread immediately. | 6831 * Ends execution of current thread immediately. |
6832 */ | 6832 */ |
6833 void dw_thread_end(void) | 6833 void API dw_thread_end(void) |
6834 { | 6834 { |
6835 _endthread(); | 6835 _endthread(); |
6836 } | 6836 } |
6837 | 6837 |
6838 /* | 6838 /* |
6839 * Returns the current thread's ID. | 6839 * Returns the current thread's ID. |
6840 */ | 6840 */ |
6841 DWTID dw_thread_id(void) | 6841 DWTID API dw_thread_id(void) |
6842 { | 6842 { |
6843 return (DWTID)_threadid; | 6843 return (DWTID)_threadid; |
6844 } | 6844 } |
6845 | 6845 |
6846 /* | 6846 /* |
6847 * Cleanly terminates a DW session, should be signal handler safe. | 6847 * Cleanly terminates a DW session, should be signal handler safe. |
6848 * Parameters: | 6848 * Parameters: |
6849 * exitcode: Exit code reported to the operating system. | 6849 * exitcode: Exit code reported to the operating system. |
6850 */ | 6850 */ |
6851 void dw_exit(int exitcode) | 6851 void API dw_exit(int exitcode) |
6852 { | 6852 { |
6853 /* In case we are in a signal handler, don't | 6853 /* In case we are in a signal handler, don't |
6854 * try to free memory that could possibly be | 6854 * try to free memory that could possibly be |
6855 * free()'d by the runtime already. | 6855 * free()'d by the runtime already. |
6856 */ | 6856 */ |
6866 * topleft: Handle to the window to be top or left. | 6866 * topleft: Handle to the window to be top or left. |
6867 * bottomright: Handle to the window to be bottom or right. | 6867 * bottomright: Handle to the window to be bottom or right. |
6868 * Returns: | 6868 * Returns: |
6869 * A handle to a splitbar window or NULL on failure. | 6869 * A handle to a splitbar window or NULL on failure. |
6870 */ | 6870 */ |
6871 HWND dw_splitbar_new(int type, HWND topleft, HWND bottomright, unsigned long id) | 6871 HWND API dw_splitbar_new(int type, HWND topleft, HWND bottomright, unsigned long id) |
6872 { | 6872 { |
6873 HWND tmp = WinCreateWindow(HWND_OBJECT, | 6873 HWND tmp = WinCreateWindow(HWND_OBJECT, |
6874 SplitbarClassName, | 6874 SplitbarClassName, |
6875 NULL, | 6875 NULL, |
6876 WS_VISIBLE | WS_CLIPCHILDREN, | 6876 WS_VISIBLE | WS_CLIPCHILDREN, |
6903 /* | 6903 /* |
6904 * Sets the position of a splitbar (pecentage). | 6904 * Sets the position of a splitbar (pecentage). |
6905 * Parameters: | 6905 * Parameters: |
6906 * handle: The handle to the splitbar returned by dw_splitbar_new(). | 6906 * handle: The handle to the splitbar returned by dw_splitbar_new(). |
6907 */ | 6907 */ |
6908 void dw_splitbar_set(HWND handle, float percent) | 6908 void API dw_splitbar_set(HWND handle, float percent) |
6909 { | 6909 { |
6910 float *mypercent = (float *)dw_window_get_data(handle, "_dw_percent"); | 6910 float *mypercent = (float *)dw_window_get_data(handle, "_dw_percent"); |
6911 int type = (int)dw_window_get_data(handle, "_dw_type"); | 6911 int type = (int)dw_window_get_data(handle, "_dw_type"); |
6912 unsigned long width, height; | 6912 unsigned long width, height; |
6913 | 6913 |
6922 /* | 6922 /* |
6923 * Gets the position of a splitbar (pecentage). | 6923 * Gets the position of a splitbar (pecentage). |
6924 * Parameters: | 6924 * Parameters: |
6925 * handle: The handle to the splitbar returned by dw_splitbar_new(). | 6925 * handle: The handle to the splitbar returned by dw_splitbar_new(). |
6926 */ | 6926 */ |
6927 float dw_splitbar_get(HWND handle) | 6927 float API dw_splitbar_get(HWND handle) |
6928 { | 6928 { |
6929 float *percent = (float *)dw_window_get_data(handle, "_dw_percent"); | 6929 float *percent = (float *)dw_window_get_data(handle, "_dw_percent"); |
6930 | 6930 |
6931 if(percent) | 6931 if(percent) |
6932 return *percent; | 6932 return *percent; |
6942 * height: Height in pixels of the item or -1 to be self determined. | 6942 * height: Height in pixels of the item or -1 to be self determined. |
6943 * hsize: TRUE if the window (widget) should expand horizontally to fill space given. | 6943 * hsize: TRUE if the window (widget) should expand horizontally to fill space given. |
6944 * vsize: TRUE if the window (widget) should expand vertically to fill space given. | 6944 * vsize: TRUE if the window (widget) should expand vertically to fill space given. |
6945 * pad: Number of pixels of padding around the item. | 6945 * pad: Number of pixels of padding around the item. |
6946 */ | 6946 */ |
6947 void dw_box_pack_start(HWND box, HWND item, int width, int height, int hsize, int vsize, int pad) | 6947 void API dw_box_pack_start(HWND box, HWND item, int width, int height, int hsize, int vsize, int pad) |
6948 { | 6948 { |
6949 Box *thisbox; | 6949 Box *thisbox; |
6950 | 6950 |
6951 if(WinWindowFromID(box, FID_CLIENT)) | 6951 if(WinWindowFromID(box, FID_CLIENT)) |
6952 { | 6952 { |
7116 * Sets the default focus item for a window/dialog. | 7116 * Sets the default focus item for a window/dialog. |
7117 * Parameters: | 7117 * Parameters: |
7118 * window: Toplevel window or dialog. | 7118 * window: Toplevel window or dialog. |
7119 * defaultitem: Handle to the dialog item to be default. | 7119 * defaultitem: Handle to the dialog item to be default. |
7120 */ | 7120 */ |
7121 void dw_window_default(HWND window, HWND defaultitem) | 7121 void API dw_window_default(HWND window, HWND defaultitem) |
7122 { | 7122 { |
7123 Box *thisbox = NULL; | 7123 Box *thisbox = NULL; |
7124 HWND box; | 7124 HWND box; |
7125 | 7125 |
7126 box = WinWindowFromID(window, FID_CLIENT); | 7126 box = WinWindowFromID(window, FID_CLIENT); |
7135 * Sets window to click the default dialog item when an ENTER is pressed. | 7135 * Sets window to click the default dialog item when an ENTER is pressed. |
7136 * Parameters: | 7136 * Parameters: |
7137 * window: Window (widget) to look for the ENTER press. | 7137 * window: Window (widget) to look for the ENTER press. |
7138 * next: Window (widget) to move to next (or click) | 7138 * next: Window (widget) to move to next (or click) |
7139 */ | 7139 */ |
7140 void dw_window_click_default(HWND window, HWND next) | 7140 void API dw_window_click_default(HWND window, HWND next) |
7141 { | 7141 { |
7142 WindowData *blah = (WindowData *)WinQueryWindowPtr(window, QWP_USER); | 7142 WindowData *blah = (WindowData *)WinQueryWindowPtr(window, QWP_USER); |
7143 | 7143 |
7144 if(blah) | 7144 if(blah) |
7145 blah->clickdefault = next; | 7145 blah->clickdefault = next; |
7148 /* | 7148 /* |
7149 * Returns some information about the current operating environment. | 7149 * Returns some information about the current operating environment. |
7150 * Parameters: | 7150 * Parameters: |
7151 * env: Pointer to a DWEnv struct. | 7151 * env: Pointer to a DWEnv struct. |
7152 */ | 7152 */ |
7153 void dw_environment_query(DWEnv *env) | 7153 void API dw_environment_query(DWEnv *env) |
7154 { | 7154 { |
7155 ULONG Build; | 7155 ULONG Build; |
7156 | 7156 |
7157 if(!env) | 7157 if(!env) |
7158 return; | 7158 return; |
7195 * Returns: | 7195 * Returns: |
7196 * NULL on error. A malloced buffer containing | 7196 * NULL on error. A malloced buffer containing |
7197 * the file path on success. | 7197 * the file path on success. |
7198 * | 7198 * |
7199 */ | 7199 */ |
7200 char *dw_file_browse(char *title, char *defpath, char *ext, int flags) | 7200 char * API dw_file_browse(char *title, char *defpath, char *ext, int flags) |
7201 { | 7201 { |
7202 FILEDLG fild; | 7202 FILEDLG fild; |
7203 HWND hwndFile; | 7203 HWND hwndFile; |
7204 int len; | 7204 int len; |
7205 | 7205 |
7279 * type: Either DW_EXEC_CON or DW_EXEC_GUI. | 7279 * type: Either DW_EXEC_CON or DW_EXEC_GUI. |
7280 * params: An array of pointers to string arguements. | 7280 * params: An array of pointers to string arguements. |
7281 * Returns: | 7281 * Returns: |
7282 * -1 on error. | 7282 * -1 on error. |
7283 */ | 7283 */ |
7284 int dw_exec(char *program, int type, char **params) | 7284 int API dw_exec(char *program, int type, char **params) |
7285 { | 7285 { |
7286 return spawnvp(P_NOWAIT, program, (const char **)params); | 7286 return spawnvp(P_NOWAIT, program, (const char **)params); |
7287 } | 7287 } |
7288 | 7288 |
7289 /* | 7289 /* |
7290 * Loads a web browser pointed at the given URL. | 7290 * Loads a web browser pointed at the given URL. |
7291 * Parameters: | 7291 * Parameters: |
7292 * url: Uniform resource locator. | 7292 * url: Uniform resource locator. |
7293 */ | 7293 */ |
7294 int dw_browse(char *url) | 7294 int API dw_browse(char *url) |
7295 { | 7295 { |
7296 /* Is there a way to find the webbrowser in Unix? */ | 7296 /* Is there a way to find the webbrowser in Unix? */ |
7297 char *execargs[3], browser[1024], *olddir, *newurl = NULL; | 7297 char *execargs[3], browser[1024], *olddir, *newurl = NULL; |
7298 int len, ret; | 7298 int len, ret; |
7299 | 7299 |
7351 /* | 7351 /* |
7352 * Returns a pointer to a static buffer which containes the | 7352 * Returns a pointer to a static buffer which containes the |
7353 * current user directory. Or the root directory (C:\ on | 7353 * current user directory. Or the root directory (C:\ on |
7354 * OS/2 and Windows). | 7354 * OS/2 and Windows). |
7355 */ | 7355 */ |
7356 char *dw_user_dir(void) | 7356 char * API dw_user_dir(void) |
7357 { | 7357 { |
7358 static char _user_dir[1024] = ""; | 7358 static char _user_dir[1024] = ""; |
7359 | 7359 |
7360 if(!_user_dir[0]) | 7360 if(!_user_dir[0]) |
7361 { | 7361 { |
7374 * Parameters: | 7374 * Parameters: |
7375 * handle: Window handle of the widget. | 7375 * handle: Window handle of the widget. |
7376 * function: Function pointer to be called. | 7376 * function: Function pointer to be called. |
7377 * data: Pointer to the data to be passed to the function. | 7377 * data: Pointer to the data to be passed to the function. |
7378 */ | 7378 */ |
7379 void dw_window_function(HWND handle, void *function, void *data) | 7379 void API dw_window_function(HWND handle, void *function, void *data) |
7380 { | 7380 { |
7381 WinSendMsg(handle, WM_USER, (MPARAM)function, (MPARAM)data); | 7381 WinSendMsg(handle, WM_USER, (MPARAM)function, (MPARAM)data); |
7382 } | 7382 } |
7383 | 7383 |
7384 /* Functions for managing the user data lists that are associated with | 7384 /* Functions for managing the user data lists that are associated with |
7472 * Parameters: | 7472 * Parameters: |
7473 * window: Window handle of signal to be called back. | 7473 * window: Window handle of signal to be called back. |
7474 * dataname: A string pointer identifying which signal to be hooked. | 7474 * dataname: A string pointer identifying which signal to be hooked. |
7475 * data: User data to be passed to the handler function. | 7475 * data: User data to be passed to the handler function. |
7476 */ | 7476 */ |
7477 void dw_window_set_data(HWND window, char *dataname, void *data) | 7477 void API dw_window_set_data(HWND window, char *dataname, void *data) |
7478 { | 7478 { |
7479 WindowData *blah = (WindowData *)WinQueryWindowPtr(window, QWP_USER); | 7479 WindowData *blah = (WindowData *)WinQueryWindowPtr(window, QWP_USER); |
7480 | 7480 |
7481 if(!blah) | 7481 if(!blah) |
7482 { | 7482 { |
7521 * window: Window handle of signal to be called back. | 7521 * window: Window handle of signal to be called back. |
7522 * signame: A string pointer identifying which signal to be hooked. | 7522 * signame: A string pointer identifying which signal to be hooked. |
7523 * sigfunc: The pointer to the function to be used as the callback. | 7523 * sigfunc: The pointer to the function to be used as the callback. |
7524 * data: User data to be passed to the handler function. | 7524 * data: User data to be passed to the handler function. |
7525 */ | 7525 */ |
7526 void dw_signal_connect(HWND window, char *signame, void *sigfunc, void *data) | 7526 void API dw_signal_connect(HWND window, char *signame, void *sigfunc, void *data) |
7527 { | 7527 { |
7528 ULONG message = 0L; | 7528 ULONG message = 0L; |
7529 | 7529 |
7530 if(strcmp(signame, "lose-focus") == 0) | 7530 if(strcmp(signame, "lose-focus") == 0) |
7531 { | 7531 { |
7552 /* | 7552 /* |
7553 * Removes callbacks for a given window with given name. | 7553 * Removes callbacks for a given window with given name. |
7554 * Parameters: | 7554 * Parameters: |
7555 * window: Window handle of callback to be removed. | 7555 * window: Window handle of callback to be removed. |
7556 */ | 7556 */ |
7557 void dw_signal_disconnect_by_name(HWND window, char *signame) | 7557 void API dw_signal_disconnect_by_name(HWND window, char *signame) |
7558 { | 7558 { |
7559 SignalHandler *prev = NULL, *tmp = Root; | 7559 SignalHandler *prev = NULL, *tmp = Root; |
7560 ULONG message; | 7560 ULONG message; |
7561 | 7561 |
7562 if(!window || !signame || (message = _findsigmessage(signame)) == 0) | 7562 if(!window || !signame || (message = _findsigmessage(signame)) == 0) |
7590 /* | 7590 /* |
7591 * Removes all callbacks for a given window. | 7591 * Removes all callbacks for a given window. |
7592 * Parameters: | 7592 * Parameters: |
7593 * window: Window handle of callback to be removed. | 7593 * window: Window handle of callback to be removed. |
7594 */ | 7594 */ |
7595 void dw_signal_disconnect_by_window(HWND window) | 7595 void API dw_signal_disconnect_by_window(HWND window) |
7596 { | 7596 { |
7597 SignalHandler *prev = NULL, *tmp = Root; | 7597 SignalHandler *prev = NULL, *tmp = Root; |
7598 | 7598 |
7599 while(tmp) | 7599 while(tmp) |
7600 { | 7600 { |
7625 * Removes all callbacks for a given window with specified data. | 7625 * Removes all callbacks for a given window with specified data. |
7626 * Parameters: | 7626 * Parameters: |
7627 * window: Window handle of callback to be removed. | 7627 * window: Window handle of callback to be removed. |
7628 * data: Pointer to the data to be compared against. | 7628 * data: Pointer to the data to be compared against. |
7629 */ | 7629 */ |
7630 void dw_signal_disconnect_by_data(HWND window, void *data) | 7630 void API dw_signal_disconnect_by_data(HWND window, void *data) |
7631 { | 7631 { |
7632 SignalHandler *prev = NULL, *tmp = Root; | 7632 SignalHandler *prev = NULL, *tmp = Root; |
7633 | 7633 |
7634 while(tmp) | 7634 while(tmp) |
7635 { | 7635 { |