comparison win/dw.c @ 177:e3dd5c765775

Fixes for Windows.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Sun, 01 Dec 2002 14:33:43 +0000
parents c2b5d0019ec3
children 4207e64d4689
comparison
equal deleted inserted replaced
176:4e3407df0e38 177:e3dd5c765775
2804 * Initializes the Dynamic Windows engine. 2804 * Initializes the Dynamic Windows engine.
2805 * Parameters: 2805 * Parameters:
2806 * newthread: True if this is the only thread. 2806 * newthread: True if this is the only thread.
2807 * False if there is already a message loop running. 2807 * False if there is already a message loop running.
2808 */ 2808 */
2809 int dw_init(int newthread, int argc, char *argv[]) 2809 int API dw_init(int newthread, int argc, char *argv[])
2810 { 2810 {
2811 WNDCLASS wc; 2811 WNDCLASS wc;
2812 int z; 2812 int z;
2813 INITCOMMONCONTROLSEX icc; 2813 INITCOMMONCONTROLSEX icc;
2814 2814
2908 } 2908 }
2909 2909
2910 /* 2910 /*
2911 * Runs a message loop for Dynamic Windows. 2911 * Runs a message loop for Dynamic Windows.
2912 */ 2912 */
2913 void dw_main(void) 2913 void API dw_main(void)
2914 { 2914 {
2915 MSG msg; 2915 MSG msg;
2916 2916
2917 _dwtid = dw_thread_id(); 2917 _dwtid = dw_thread_id();
2918 2918
2926 /* 2926 /*
2927 * Runs a message loop for Dynamic Windows, for a period of milliseconds. 2927 * Runs a message loop for Dynamic Windows, for a period of milliseconds.
2928 * Parameters: 2928 * Parameters:
2929 * milliseconds: Number of milliseconds to run the loop for. 2929 * milliseconds: Number of milliseconds to run the loop for.
2930 */ 2930 */
2931 void dw_main_sleep(int milliseconds) 2931 void API dw_main_sleep(int milliseconds)
2932 { 2932 {
2933 MSG msg; 2933 MSG msg;
2934 double start = (double)clock(); 2934 double start = (double)clock();
2935 2935
2936 while(((clock() - start) / (CLOCKS_PER_SEC/1000)) <= milliseconds) 2936 while(((clock() - start) / (CLOCKS_PER_SEC/1000)) <= milliseconds)
2950 * Free's memory allocated by dynamic windows. 2950 * Free's memory allocated by dynamic windows.
2951 * Parameters: 2951 * Parameters:
2952 * ptr: Pointer to dynamic windows allocated 2952 * ptr: Pointer to dynamic windows allocated
2953 * memory to be free()'d. 2953 * memory to be free()'d.
2954 */ 2954 */
2955 void dw_free(void *ptr) 2955 void API dw_free(void *ptr)
2956 { 2956 {
2957 free(ptr); 2957 free(ptr);
2958 } 2958 }
2959 2959
2960 /* 2960 /*
2961 * Allocates and initializes a dialog struct. 2961 * Allocates and initializes a dialog struct.
2962 * Parameters: 2962 * Parameters:
2963 * data: User defined data to be passed to functions. 2963 * data: User defined data to be passed to functions.
2964 */ 2964 */
2965 DWDialog *dw_dialog_new(void *data) 2965 DWDialog * API dw_dialog_new(void *data)
2966 { 2966 {
2967 DWDialog *tmp = malloc(sizeof(DWDialog)); 2967 DWDialog *tmp = malloc(sizeof(DWDialog));
2968 2968
2969 tmp->eve = dw_event_new(); 2969 tmp->eve = dw_event_new();
2970 dw_event_reset(tmp->eve); 2970 dw_event_reset(tmp->eve);
2980 * initial called of dw_dialog_wait(). 2980 * initial called of dw_dialog_wait().
2981 * Parameters: 2981 * Parameters:
2982 * dialog: Pointer to a dialog struct aquired by dw_dialog_new). 2982 * dialog: Pointer to a dialog struct aquired by dw_dialog_new).
2983 * result: Data to be returned by dw_dialog_wait(). 2983 * result: Data to be returned by dw_dialog_wait().
2984 */ 2984 */
2985 int dw_dialog_dismiss(DWDialog *dialog, void *result) 2985 int API dw_dialog_dismiss(DWDialog *dialog, void *result)
2986 { 2986 {
2987 dialog->result = result; 2987 dialog->result = result;
2988 dw_event_post(dialog->eve); 2988 dw_event_post(dialog->eve);
2989 dialog->done = TRUE; 2989 dialog->done = TRUE;
2990 return 0; 2990 return 0;
2994 * Accepts a dialog struct waits for dw_dialog_dismiss() to be 2994 * Accepts a dialog struct waits for dw_dialog_dismiss() to be
2995 * called by a signal handler with the given dialog struct. 2995 * called by a signal handler with the given dialog struct.
2996 * Parameters: 2996 * Parameters:
2997 * dialog: Pointer to a dialog struct aquired by dw_dialog_new). 2997 * dialog: Pointer to a dialog struct aquired by dw_dialog_new).
2998 */ 2998 */
2999 void *dw_dialog_wait(DWDialog *dialog) 2999 void * API dw_dialog_wait(DWDialog *dialog)
3000 { 3000 {
3001 MSG msg; 3001 MSG msg;
3002 void *tmp; 3002 void *tmp;
3003 3003
3004 while (GetMessage(&msg,NULL,0,0)) 3004 while (GetMessage(&msg,NULL,0,0))
3019 * Parameters: 3019 * Parameters:
3020 * title: The title of the message box. 3020 * title: The title of the message box.
3021 * format: printf style format string. 3021 * format: printf style format string.
3022 * ...: Additional variables for use in the format. 3022 * ...: Additional variables for use in the format.
3023 */ 3023 */
3024 int dw_messagebox(char *title, char *format, ...) 3024 int API dw_messagebox(char *title, char *format, ...)
3025 { 3025 {
3026 va_list args; 3026 va_list args;
3027 char outbuf[256]; 3027 char outbuf[256];
3028 3028
3029 va_start(args, format); 3029 va_start(args, format);
3041 * title: The title of the message box. 3041 * title: The title of the message box.
3042 * text: The text to display in the box. 3042 * text: The text to display in the box.
3043 * Returns: 3043 * Returns:
3044 * True if YES False of NO. 3044 * True if YES False of NO.
3045 */ 3045 */
3046 int dw_yesno(char *title, char *text) 3046 int API dw_yesno(char *title, char *text)
3047 { 3047 {
3048 if(MessageBox(HWND_DESKTOP, text, title, MB_YESNO) == IDYES) 3048 if(MessageBox(HWND_DESKTOP, text, title, MB_YESNO) == IDYES)
3049 return TRUE; 3049 return TRUE;
3050 return FALSE; 3050 return FALSE;
3051 } 3051 }
3053 /* 3053 /*
3054 * Minimizes or Iconifies a top-level window. 3054 * Minimizes or Iconifies a top-level window.
3055 * Parameters: 3055 * Parameters:
3056 * handle: The window handle to minimize. 3056 * handle: The window handle to minimize.
3057 */ 3057 */
3058 int dw_window_minimize(HWND handle) 3058 int API dw_window_minimize(HWND handle)
3059 { 3059 {
3060 return ShowWindow(handle, SW_MINIMIZE); 3060 return ShowWindow(handle, SW_MINIMIZE);
3061 } 3061 }
3062 3062
3063 /* 3063 /*
3064 * Makes the window topmost. 3064 * Makes the window topmost.
3065 * Parameters: 3065 * Parameters:
3066 * handle: The window handle to make topmost. 3066 * handle: The window handle to make topmost.
3067 */ 3067 */
3068 int dw_window_raise(HWND handle) 3068 int API dw_window_raise(HWND handle)
3069 { 3069 {
3070 return SetWindowPos(handle, HWND_TOP, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE); 3070 return SetWindowPos(handle, HWND_TOP, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
3071 } 3071 }
3072 3072
3073 /* 3073 /*
3074 * Makes the window bottommost. 3074 * Makes the window bottommost.
3075 * Parameters: 3075 * Parameters:
3076 * handle: The window handle to make bottommost. 3076 * handle: The window handle to make bottommost.
3077 */ 3077 */
3078 int dw_window_lower(HWND handle) 3078 int API dw_window_lower(HWND handle)
3079 { 3079 {
3080 return SetWindowPos(handle, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE); 3080 return SetWindowPos(handle, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
3081 } 3081 }
3082 3082
3083 /* 3083 /*
3084 * Makes the window visible. 3084 * Makes the window visible.
3085 * Parameters: 3085 * Parameters:
3086 * handle: The window handle to make visible. 3086 * handle: The window handle to make visible.
3087 */ 3087 */
3088 int dw_window_show(HWND handle) 3088 int API dw_window_show(HWND handle)
3089 { 3089 {
3090 int rc = ShowWindow(handle, SW_SHOW); 3090 int rc = ShowWindow(handle, SW_SHOW);
3091 SetFocus(handle); 3091 SetFocus(handle);
3092 _initial_focus(handle); 3092 _initial_focus(handle);
3093 return rc; 3093 return rc;
3096 /* 3096 /*
3097 * Makes the window invisible. 3097 * Makes the window invisible.
3098 * Parameters: 3098 * Parameters:
3099 * handle: The window handle to make visible. 3099 * handle: The window handle to make visible.
3100 */ 3100 */
3101 int dw_window_hide(HWND handle) 3101 int API dw_window_hide(HWND handle)
3102 { 3102 {
3103 return ShowWindow(handle, SW_HIDE); 3103 return ShowWindow(handle, SW_HIDE);
3104 } 3104 }
3105 3105
3106 /* 3106 /*
3107 * Destroys a window and all of it's children. 3107 * Destroys a window and all of it's children.
3108 * Parameters: 3108 * Parameters:
3109 * handle: The window handle to destroy. 3109 * handle: The window handle to destroy.
3110 */ 3110 */
3111 int dw_window_destroy(HWND handle) 3111 int API dw_window_destroy(HWND handle)
3112 { 3112 {
3113 HWND parent = GetParent(handle); 3113 HWND parent = GetParent(handle);
3114 Box *thisbox = (Box *)GetWindowLong(parent, GWL_USERDATA); 3114 Box *thisbox = (Box *)GetWindowLong(parent, GWL_USERDATA);
3115 3115
3116 if(parent != HWND_DESKTOP && thisbox && thisbox->count) 3116 if(parent != HWND_DESKTOP && thisbox && thisbox->count)
3150 3150
3151 /* Causes entire window to be invalidated and redrawn. 3151 /* Causes entire window to be invalidated and redrawn.
3152 * Parameters: 3152 * Parameters:
3153 * handle: Toplevel window handle to be redrawn. 3153 * handle: Toplevel window handle to be redrawn.
3154 */ 3154 */
3155 void dw_window_redraw(HWND handle) 3155 void API dw_window_redraw(HWND handle)
3156 { 3156 {
3157 Box *mybox = (Box *)GetWindowLong(handle, GWL_USERDATA); 3157 Box *mybox = (Box *)GetWindowLong(handle, GWL_USERDATA);
3158 3158
3159 if(mybox) 3159 if(mybox)
3160 { 3160 {
3173 * Changes a window's parent to newparent. 3173 * Changes a window's parent to newparent.
3174 * Parameters: 3174 * Parameters:
3175 * handle: The window handle to destroy. 3175 * handle: The window handle to destroy.
3176 * newparent: The window's new parent window. 3176 * newparent: The window's new parent window.
3177 */ 3177 */
3178 void dw_window_reparent(HWND handle, HWND newparent) 3178 void API dw_window_reparent(HWND handle, HWND newparent)
3179 { 3179 {
3180 SetParent(handle, newparent); 3180 SetParent(handle, newparent);
3181 } 3181 }
3182 3182
3183 HFONT _acquire_font(HWND handle, char *fontname) 3183 HFONT _acquire_font(HWND handle, char *fontname)
3230 * Sets the font used by a specified window (widget) handle. 3230 * Sets the font used by a specified window (widget) handle.
3231 * Parameters: 3231 * Parameters:
3232 * handle: The window (widget) handle. 3232 * handle: The window (widget) handle.
3233 * fontname: Name and size of the font in the form "size.fontname" 3233 * fontname: Name and size of the font in the form "size.fontname"
3234 */ 3234 */
3235 int dw_window_set_font(HWND handle, char *fontname) 3235 int API dw_window_set_font(HWND handle, char *fontname)
3236 { 3236 {
3237 HFONT oldfont = (HFONT)SendMessage(handle, WM_GETFONT, 0, 0); 3237 HFONT oldfont = (HFONT)SendMessage(handle, WM_GETFONT, 0, 0);
3238 HFONT hfont = _acquire_font(handle, fontname); 3238 HFONT hfont = _acquire_font(handle, fontname);
3239 ColorInfo *cinfo; 3239 ColorInfo *cinfo;
3240 3240
3269 * Parameters: 3269 * Parameters:
3270 * handle: The window (widget) handle. 3270 * handle: The window (widget) handle.
3271 * fore: Foreground color in RGB format. 3271 * fore: Foreground color in RGB format.
3272 * back: Background color in RGB format. 3272 * back: Background color in RGB format.
3273 */ 3273 */
3274 int dw_window_set_color(HWND handle, ULONG fore, ULONG back) 3274 int API dw_window_set_color(HWND handle, ULONG fore, ULONG back)
3275 { 3275 {
3276 ColorInfo *cinfo; 3276 ColorInfo *cinfo;
3277 char tmpbuf[100]; 3277 char tmpbuf[100];
3278 3278
3279 cinfo = (ColorInfo *)GetWindowLong(handle, GWL_USERDATA); 3279 cinfo = (ColorInfo *)GetWindowLong(handle, GWL_USERDATA);
3319 * Sets the font used by a specified window (widget) handle. 3319 * Sets the font used by a specified window (widget) handle.
3320 * Parameters: 3320 * Parameters:
3321 * handle: The window (widget) handle. 3321 * handle: The window (widget) handle.
3322 * border: Size of the window border in pixels. 3322 * border: Size of the window border in pixels.
3323 */ 3323 */
3324 int dw_window_set_border(HWND handle, int border) 3324 int API dw_window_set_border(HWND handle, int border)
3325 { 3325 {
3326 return 0; 3326 return 0;
3327 } 3327 }
3328 3328
3329 /* 3329 /*
3330 * Captures the mouse input to this window. 3330 * Captures the mouse input to this window.
3331 * Parameters: 3331 * Parameters:
3332 * handle: Handle to receive mouse input. 3332 * handle: Handle to receive mouse input.
3333 */ 3333 */
3334 void dw_window_capture(HWND handle) 3334 void API dw_window_capture(HWND handle)
3335 { 3335 {
3336 SetCapture(handle); 3336 SetCapture(handle);
3337 } 3337 }
3338 3338
3339 /* 3339 /*
3340 * Releases previous mouse capture. 3340 * Releases previous mouse capture.
3341 */ 3341 */
3342 void dw_window_release(void) 3342 void API dw_window_release(void)
3343 { 3343 {
3344 ReleaseCapture(); 3344 ReleaseCapture();
3345 } 3345 }
3346 3346
3347 /* 3347 /*
3348 * Changes the appearance of the mouse pointer. 3348 * Changes the appearance of the mouse pointer.
3349 * Parameters: 3349 * Parameters:
3350 * handle: Handle to widget for which to change. 3350 * handle: Handle to widget for which to change.
3351 * cursortype: ID of the pointer you want. 3351 * cursortype: ID of the pointer you want.
3352 */ 3352 */
3353 void dw_window_pointer(HWND handle, int pointertype) 3353 void API dw_window_pointer(HWND handle, int pointertype)
3354 { 3354 {
3355 SetCursor(LoadCursor(NULL, MAKEINTRESOURCE(pointertype))); 3355 SetCursor(LoadCursor(NULL, MAKEINTRESOURCE(pointertype)));
3356 } 3356 }
3357 3357
3358 /* 3358 /*
3360 * Parameters: 3360 * Parameters:
3361 * owner: The Owner's window handle or HWND_DESKTOP. 3361 * owner: The Owner's window handle or HWND_DESKTOP.
3362 * title: The Window title. 3362 * title: The Window title.
3363 * flStyle: Style flags, see the DW reference. 3363 * flStyle: Style flags, see the DW reference.
3364 */ 3364 */
3365 HWND dw_window_new(HWND hwndOwner, char *title, ULONG flStyle) 3365 HWND API dw_window_new(HWND hwndOwner, char *title, ULONG flStyle)
3366 { 3366 {
3367 HWND hwndframe; 3367 HWND hwndframe;
3368 Box *newbox = calloc(sizeof(Box), 1); 3368 Box *newbox = calloc(sizeof(Box), 1);
3369 ULONG flStyleEx = 0; 3369 ULONG flStyleEx = 0;
3370 3370
3407 * Create a new Box to be packed. 3407 * Create a new Box to be packed.
3408 * Parameters: 3408 * Parameters:
3409 * type: Either BOXVERT (vertical) or BOXHORZ (horizontal). 3409 * type: Either BOXVERT (vertical) or BOXHORZ (horizontal).
3410 * pad: Number of pixels to pad around the box. 3410 * pad: Number of pixels to pad around the box.
3411 */ 3411 */
3412 HWND dw_box_new(int type, int pad) 3412 HWND API dw_box_new(int type, int pad)
3413 { 3413 {
3414 Box *newbox = calloc(sizeof(Box), 1); 3414 Box *newbox = calloc(sizeof(Box), 1);
3415 HWND hwndframe; 3415 HWND hwndframe;
3416 3416
3417 newbox->pad = pad; 3417 newbox->pad = pad;
3441 * Parameters: 3441 * Parameters:
3442 * type: Either BOXVERT (vertical) or BOXHORZ (horizontal). 3442 * type: Either BOXVERT (vertical) or BOXHORZ (horizontal).
3443 * pad: Number of pixels to pad around the box. 3443 * pad: Number of pixels to pad around the box.
3444 * title: Text to be displayined in the group outline. 3444 * title: Text to be displayined in the group outline.
3445 */ 3445 */
3446 HWND dw_groupbox_new(int type, int pad, char *title) 3446 HWND API dw_groupbox_new(int type, int pad, char *title)
3447 { 3447 {
3448 Box *newbox = calloc(sizeof(Box), 1); 3448 Box *newbox = calloc(sizeof(Box), 1);
3449 HWND hwndframe; 3449 HWND hwndframe;
3450 3450
3451 newbox->pad = pad; 3451 newbox->pad = pad;
3480 /* 3480 /*
3481 * Create a new MDI Frame to be packed. 3481 * Create a new MDI Frame to be packed.
3482 * Parameters: 3482 * Parameters:
3483 * id: An ID to be used with dw_window_from_id or 0L. 3483 * id: An ID to be used with dw_window_from_id or 0L.
3484 */ 3484 */
3485 HWND dw_mdi_new(unsigned long id) 3485 HWND API dw_mdi_new(unsigned long id)
3486 { 3486 {
3487 CLIENTCREATESTRUCT ccs; 3487 CLIENTCREATESTRUCT ccs;
3488 HWND hwndframe; 3488 HWND hwndframe;
3489 3489
3490 ccs.hWindowMenu = NULL; 3490 ccs.hWindowMenu = NULL;
3504 /* 3504 /*
3505 * Create a bitmap object to be packed. 3505 * Create a bitmap object to be packed.
3506 * Parameters: 3506 * Parameters:
3507 * id: An ID to be used with dw_window_from_id or 0L. 3507 * id: An ID to be used with dw_window_from_id or 0L.
3508 */ 3508 */
3509 HWND dw_bitmap_new(ULONG id) 3509 HWND API dw_bitmap_new(ULONG id)
3510 { 3510 {
3511 return CreateWindow(STATICCLASSNAME, 3511 return CreateWindow(STATICCLASSNAME,
3512 "", 3512 "",
3513 SS_BITMAP | WS_VISIBLE | 3513 SS_BITMAP | WS_VISIBLE |
3514 WS_CHILD | WS_CLIPCHILDREN, 3514 WS_CHILD | WS_CLIPCHILDREN,
3523 * Create a notebook object to be packed. 3523 * Create a notebook object to be packed.
3524 * Parameters: 3524 * Parameters:
3525 * id: An ID to be used for getting the resource from the 3525 * id: An ID to be used for getting the resource from the
3526 * resource file. 3526 * resource file.
3527 */ 3527 */
3528 HWND dw_notebook_new(ULONG id, int top) 3528 HWND API dw_notebook_new(ULONG id, int top)
3529 { 3529 {
3530 ULONG flags = 0; 3530 ULONG flags = 0;
3531 HWND tmp; 3531 HWND tmp;
3532 NotebookPage **array = calloc(256, sizeof(NotebookPage *)); 3532 NotebookPage **array = calloc(256, sizeof(NotebookPage *));
3533 3533
3551 * Create a menu object to be popped up. 3551 * Create a menu object to be popped up.
3552 * Parameters: 3552 * Parameters:
3553 * id: An ID to be used for getting the resource from the 3553 * id: An ID to be used for getting the resource from the
3554 * resource file. 3554 * resource file.
3555 */ 3555 */
3556 HMENUI dw_menu_new(ULONG id) 3556 HMENUI API dw_menu_new(ULONG id)
3557 { 3557 {
3558 HMENUI tmp = malloc(sizeof(struct _hmenui)); 3558 HMENUI tmp = malloc(sizeof(struct _hmenui));
3559 3559
3560 if(!tmp) 3560 if(!tmp)
3561 return NULL; 3561 return NULL;
3568 /* 3568 /*
3569 * Create a menubar on a window. 3569 * Create a menubar on a window.
3570 * Parameters: 3570 * Parameters:
3571 * location: Handle of a window frame to be attached to. 3571 * location: Handle of a window frame to be attached to.
3572 */ 3572 */
3573 HMENUI dw_menubar_new(HWND location) 3573 HMENUI API dw_menubar_new(HWND location)
3574 { 3574 {
3575 HMENUI tmp = malloc(sizeof(struct _hmenui)); 3575 HMENUI tmp = malloc(sizeof(struct _hmenui));
3576 3576
3577 if(!tmp) 3577 if(!tmp)
3578 return NULL; 3578 return NULL;
3587 /* 3587 /*
3588 * Destroys a menu created with dw_menubar_new or dw_menu_new. 3588 * Destroys a menu created with dw_menubar_new or dw_menu_new.
3589 * Parameters: 3589 * Parameters:
3590 * menu: Handle of a menu. 3590 * menu: Handle of a menu.
3591 */ 3591 */
3592 void dw_menu_destroy(HMENUI *menu) 3592 void API dw_menu_destroy(HMENUI *menu)
3593 { 3593 {
3594 if(menu && *menu) 3594 if(menu && *menu)
3595 { 3595 {
3596 DestroyMenu((*menu)->menu); 3596 DestroyMenu((*menu)->menu);
3597 free(*menu); 3597 free(*menu);
3608 * end: If TRUE memu is positioned at the end of the menu. 3608 * end: If TRUE memu is positioned at the end of the menu.
3609 * check: If TRUE menu is "check"able. 3609 * check: If TRUE menu is "check"able.
3610 * flags: Extended attributes to set on the menu. 3610 * flags: Extended attributes to set on the menu.
3611 * submenu: Handle to an existing menu to be a submenu or NULL. 3611 * submenu: Handle to an existing menu to be a submenu or NULL.
3612 */ 3612 */
3613 HWND dw_menu_append_item(HMENUI menux, char *title, ULONG id, ULONG flags, int end, int check, HMENUI submenu) 3613 HWND API dw_menu_append_item(HMENUI menux, char *title, ULONG id, ULONG flags, int end, int check, HMENUI submenu)
3614 { 3614 {
3615 MENUITEMINFO mii; 3615 MENUITEMINFO mii;
3616 HMENU menu; 3616 HMENU menu;
3617 3617
3618 if(!menux) 3618 if(!menux)
3657 * Parameters: 3657 * Parameters:
3658 * menu: The handle the the existing menu. 3658 * menu: The handle the the existing menu.
3659 * id: Menuitem id. 3659 * id: Menuitem id.
3660 * check: TRUE for checked FALSE for not checked. 3660 * check: TRUE for checked FALSE for not checked.
3661 */ 3661 */
3662 void dw_menu_item_set_check(HMENUI menux, unsigned long id, int check) 3662 void API dw_menu_item_set_check(HMENUI menux, unsigned long id, int check)
3663 { 3663 {
3664 MENUITEMINFO mii; 3664 MENUITEMINFO mii;
3665 HMENU menu; 3665 HMENU menu;
3666 3666
3667 if(!menux) 3667 if(!menux)
3684 * menu: The handle the the existing menu. 3684 * menu: The handle the the existing menu.
3685 * parent: Handle to the window initiating the popup. 3685 * parent: Handle to the window initiating the popup.
3686 * x: X coordinate. 3686 * x: X coordinate.
3687 * y: Y coordinate. 3687 * y: Y coordinate.
3688 */ 3688 */
3689 void dw_menu_popup(HMENUI *menu, HWND parent, int x, int y) 3689 void API dw_menu_popup(HMENUI *menu, HWND parent, int x, int y)
3690 { 3690 {
3691 if(menu && *menu) 3691 if(menu && *menu)
3692 { 3692 {
3693 popup = parent; 3693 popup = parent;
3694 TrackPopupMenu((*menu)->menu, 0, x, y, 0, parent, NULL); 3694 TrackPopupMenu((*menu)->menu, 0, x, y, 0, parent, NULL);
3702 * Create a container object to be packed. 3702 * Create a container object to be packed.
3703 * Parameters: 3703 * Parameters:
3704 * id: An ID to be used for getting the resource from the 3704 * id: An ID to be used for getting the resource from the
3705 * resource file. 3705 * resource file.
3706 */ 3706 */
3707 HWND dw_container_new(ULONG id) 3707 HWND API dw_container_new(ULONG id)
3708 { 3708 {
3709 HWND tmp = CreateWindow(WC_LISTVIEW, 3709 HWND tmp = CreateWindow(WC_LISTVIEW,
3710 "", 3710 "",
3711 WS_VISIBLE | WS_CHILD | 3711 WS_VISIBLE | WS_CHILD |
3712 LVS_REPORT | LVS_SHOWSELALWAYS | 3712 LVS_REPORT | LVS_SHOWSELALWAYS |
3737 * Create a tree object to be packed. 3737 * Create a tree object to be packed.
3738 * Parameters: 3738 * Parameters:
3739 * id: An ID to be used for getting the resource from the 3739 * id: An ID to be used for getting the resource from the
3740 * resource file. 3740 * resource file.
3741 */ 3741 */
3742 HWND dw_tree_new(ULONG id) 3742 HWND API dw_tree_new(ULONG id)
3743 { 3743 {
3744 HWND tmp = CreateWindow(WC_TREEVIEW, 3744 HWND tmp = CreateWindow(WC_TREEVIEW,
3745 "", 3745 "",
3746 WS_VISIBLE | WS_CHILD | 3746 WS_VISIBLE | WS_CHILD |
3747 TVS_HASLINES | TVS_SHOWSELALWAYS | 3747 TVS_HASLINES | TVS_SHOWSELALWAYS |
3773 * Returns the current X and Y coordinates of the mouse pointer. 3773 * Returns the current X and Y coordinates of the mouse pointer.
3774 * Parameters: 3774 * Parameters:
3775 * x: Pointer to variable to store X coordinate. 3775 * x: Pointer to variable to store X coordinate.
3776 * y: Pointer to variable to store Y coordinate. 3776 * y: Pointer to variable to store Y coordinate.
3777 */ 3777 */
3778 void dw_pointer_query_pos(long *x, long *y) 3778 void API dw_pointer_query_pos(long *x, long *y)
3779 { 3779 {
3780 POINT ptl; 3780 POINT ptl;
3781 3781
3782 GetCursorPos(&ptl); 3782 GetCursorPos(&ptl);
3783 if(x && y) 3783 if(x && y)
3791 * Sets the X and Y coordinates of the mouse pointer. 3791 * Sets the X and Y coordinates of the mouse pointer.
3792 * Parameters: 3792 * Parameters:
3793 * x: X coordinate. 3793 * x: X coordinate.
3794 * y: Y coordinate. 3794 * y: Y coordinate.
3795 */ 3795 */
3796 void dw_pointer_set_pos(long x, long y) 3796 void API dw_pointer_set_pos(long x, long y)
3797 { 3797 {
3798 SetCursorPos(x, y); 3798 SetCursorPos(x, y);
3799 } 3799 }
3800 3800
3801 /* 3801 /*
3802 * Create a new static text window (widget) to be packed. 3802 * Create a new static text window (widget) to be packed.
3803 * Parameters: 3803 * Parameters:
3804 * text: The text to be display by the static text widget. 3804 * text: The text to be display by the static text widget.
3805 * id: An ID to be used with WinWindowFromID() or 0L. 3805 * id: An ID to be used with WinWindowFromID() or 0L.
3806 */ 3806 */
3807 HWND dw_text_new(char *text, ULONG id) 3807 HWND API dw_text_new(char *text, ULONG id)
3808 { 3808 {
3809 HWND tmp = CreateWindow(STATICCLASSNAME, 3809 HWND tmp = CreateWindow(STATICCLASSNAME,
3810 text, 3810 text,
3811 BS_TEXT | WS_VISIBLE | 3811 BS_TEXT | WS_VISIBLE |
3812 WS_CHILD | WS_CLIPCHILDREN, 3812 WS_CHILD | WS_CLIPCHILDREN,
3823 * Create a new status text window (widget) to be packed. 3823 * Create a new status text window (widget) to be packed.
3824 * Parameters: 3824 * Parameters:
3825 * text: The text to be display by the static text widget. 3825 * text: The text to be display by the static text widget.
3826 * id: An ID to be used with WinWindowFromID() or 0L. 3826 * id: An ID to be used with WinWindowFromID() or 0L.
3827 */ 3827 */
3828 HWND dw_status_text_new(char *text, ULONG id) 3828 HWND API dw_status_text_new(char *text, ULONG id)
3829 { 3829 {
3830 HWND tmp = CreateWindow(STATICCLASSNAME, 3830 HWND tmp = CreateWindow(STATICCLASSNAME,
3831 text, 3831 text,
3832 BS_TEXT | WS_VISIBLE | 3832 BS_TEXT | WS_VISIBLE |
3833 WS_CHILD | WS_CLIPCHILDREN, 3833 WS_CHILD | WS_CLIPCHILDREN,
3844 /* 3844 /*
3845 * Create a new Multiline Editbox window (widget) to be packed. 3845 * Create a new Multiline Editbox window (widget) to be packed.
3846 * Parameters: 3846 * Parameters:
3847 * id: An ID to be used with WinWindowFromID() or 0L. 3847 * id: An ID to be used with WinWindowFromID() or 0L.
3848 */ 3848 */
3849 HWND dw_mle_new(ULONG id) 3849 HWND API dw_mle_new(ULONG id)
3850 { 3850 {
3851 3851
3852 HWND tmp = CreateWindowEx(WS_EX_CLIENTEDGE, 3852 HWND tmp = CreateWindowEx(WS_EX_CLIENTEDGE,
3853 EDITCLASSNAME, 3853 EDITCLASSNAME,
3854 "", 3854 "",
3881 * Create a new Entryfield window (widget) to be packed. 3881 * Create a new Entryfield window (widget) to be packed.
3882 * Parameters: 3882 * Parameters:
3883 * text: The default text to be in the entryfield widget. 3883 * text: The default text to be in the entryfield widget.
3884 * id: An ID to be used with WinWindowFromID() or 0L. 3884 * id: An ID to be used with WinWindowFromID() or 0L.
3885 */ 3885 */
3886 HWND dw_entryfield_new(char *text, ULONG id) 3886 HWND API dw_entryfield_new(char *text, ULONG id)
3887 { 3887 {
3888 HWND tmp = CreateWindowEx(WS_EX_CLIENTEDGE, 3888 HWND tmp = CreateWindowEx(WS_EX_CLIENTEDGE,
3889 EDITCLASSNAME, 3889 EDITCLASSNAME,
3890 text, 3890 text,
3891 ES_WANTRETURN | WS_CHILD | 3891 ES_WANTRETURN | WS_CHILD |
3911 * Create a new Entryfield passwird window (widget) to be packed. 3911 * Create a new Entryfield passwird window (widget) to be packed.
3912 * Parameters: 3912 * Parameters:
3913 * text: The default text to be in the entryfield widget. 3913 * text: The default text to be in the entryfield widget.
3914 * id: An ID to be used with WinWindowFromID() or 0L. 3914 * id: An ID to be used with WinWindowFromID() or 0L.
3915 */ 3915 */
3916 HWND dw_entryfield_password_new(char *text, ULONG id) 3916 HWND API dw_entryfield_password_new(char *text, ULONG id)
3917 { 3917 {
3918 HWND tmp = CreateWindowEx(WS_EX_CLIENTEDGE, 3918 HWND tmp = CreateWindowEx(WS_EX_CLIENTEDGE,
3919 EDITCLASSNAME, 3919 EDITCLASSNAME,
3920 text, 3920 text,
3921 ES_WANTRETURN | WS_CHILD | 3921 ES_WANTRETURN | WS_CHILD |
3954 * Create a new Combobox window (widget) to be packed. 3954 * Create a new Combobox window (widget) to be packed.
3955 * Parameters: 3955 * Parameters:
3956 * text: The default text to be in the combpbox widget. 3956 * text: The default text to be in the combpbox 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_combobox_new(char *text, ULONG id) 3959 HWND API dw_combobox_new(char *text, ULONG id)
3960 { 3960 {
3961 HWND tmp = CreateWindow(COMBOBOXCLASSNAME, 3961 HWND tmp = CreateWindow(COMBOBOXCLASSNAME,
3962 text, 3962 text,
3963 WS_CHILD | CBS_DROPDOWN | WS_VSCROLL | 3963 WS_CHILD | CBS_DROPDOWN | WS_VSCROLL |
3964 WS_CLIPCHILDREN | WS_VISIBLE, 3964 WS_CLIPCHILDREN | WS_VISIBLE,
3994 * Create a new button window (widget) to be packed. 3994 * Create a new button window (widget) to be packed.
3995 * Parameters: 3995 * Parameters:
3996 * text: The text to be display by the static text widget. 3996 * text: The text to be display by the static text widget.
3997 * id: An ID to be used with WinWindowFromID() or 0L. 3997 * id: An ID to be used with WinWindowFromID() or 0L.
3998 */ 3998 */
3999 HWND dw_button_new(char *text, ULONG id) 3999 HWND API dw_button_new(char *text, ULONG id)
4000 { 4000 {
4001 BubbleButton *bubble = calloc(1, sizeof(BubbleButton)); 4001 BubbleButton *bubble = calloc(1, sizeof(BubbleButton));
4002 4002
4003 HWND tmp = CreateWindow(BUTTONCLASSNAME, 4003 HWND tmp = CreateWindow(BUTTONCLASSNAME,
4004 text, 4004 text,
4023 * Create a new bitmap button window (widget) to be packed. 4023 * Create a new bitmap button window (widget) to be packed.
4024 * Parameters: 4024 * Parameters:
4025 * text: Bubble help text to be displayed. 4025 * text: Bubble help text to be displayed.
4026 * id: An ID of a bitmap in the resource file. 4026 * id: An ID of a bitmap in the resource file.
4027 */ 4027 */
4028 HWND dw_bitmapbutton_new(char *text, ULONG id) 4028 HWND API dw_bitmapbutton_new(char *text, ULONG id)
4029 { 4029 {
4030 HWND tmp; 4030 HWND tmp;
4031 BubbleButton *bubble = calloc(1, sizeof(BubbleButton)); 4031 BubbleButton *bubble = calloc(1, sizeof(BubbleButton));
4032 HBITMAP hbitmap = LoadBitmap(DWInstance, MAKEINTRESOURCE(id)); 4032 HBITMAP hbitmap = LoadBitmap(DWInstance, MAKEINTRESOURCE(id));
4033 4033
4059 * Create a new spinbutton window (widget) to be packed. 4059 * Create a new spinbutton window (widget) to be packed.
4060 * Parameters: 4060 * Parameters:
4061 * text: The text to be display by the static text widget. 4061 * text: The text to be display by the static text widget.
4062 * id: An ID to be used with WinWindowFromID() or 0L. 4062 * id: An ID to be used with WinWindowFromID() or 0L.
4063 */ 4063 */
4064 HWND dw_spinbutton_new(char *text, ULONG id) 4064 HWND API dw_spinbutton_new(char *text, ULONG id)
4065 { 4065 {
4066 ULONG *data = malloc(sizeof(ULONG)); 4066 ULONG *data = malloc(sizeof(ULONG));
4067 HWND buddy = CreateWindowEx(WS_EX_CLIENTEDGE, 4067 HWND buddy = CreateWindowEx(WS_EX_CLIENTEDGE,
4068 EDITCLASSNAME, 4068 EDITCLASSNAME,
4069 text, 4069 text,
4107 * Create a new radiobutton window (widget) to be packed. 4107 * Create a new radiobutton window (widget) to be packed.
4108 * Parameters: 4108 * Parameters:
4109 * text: The text to be display by the static text widget. 4109 * text: The text to be display by the static text widget.
4110 * id: An ID to be used with WinWindowFromID() or 0L. 4110 * id: An ID to be used with WinWindowFromID() or 0L.
4111 */ 4111 */
4112 HWND dw_radiobutton_new(char *text, ULONG id) 4112 HWND API dw_radiobutton_new(char *text, ULONG id)
4113 { 4113 {
4114 HWND tmp = CreateWindow(BUTTONCLASSNAME, 4114 HWND tmp = CreateWindow(BUTTONCLASSNAME,
4115 text, 4115 text,
4116 WS_CHILD | BS_AUTORADIOBUTTON | 4116 WS_CHILD | BS_AUTORADIOBUTTON |
4117 WS_CLIPCHILDREN | WS_VISIBLE, 4117 WS_CLIPCHILDREN | WS_VISIBLE,
4136 * Parameters: 4136 * Parameters:
4137 * vertical: TRUE or FALSE if slider is vertical. 4137 * vertical: TRUE or FALSE if slider is vertical.
4138 * increments: Number of increments available. 4138 * increments: Number of increments available.
4139 * id: An ID to be used with WinWindowFromID() or 0L. 4139 * id: An ID to be used with WinWindowFromID() or 0L.
4140 */ 4140 */
4141 HWND dw_slider_new(int vertical, int increments, ULONG id) 4141 HWND API dw_slider_new(int vertical, int increments, ULONG id)
4142 { 4142 {
4143 HWND tmp = CreateWindow(TRACKBAR_CLASS, 4143 HWND tmp = CreateWindow(TRACKBAR_CLASS,
4144 "", 4144 "",
4145 WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE | 4145 WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE |
4146 (vertical ? TBS_VERT : TBS_HORZ), 4146 (vertical ? TBS_VERT : TBS_HORZ),
4164 /* 4164 /*
4165 * Create a new percent bar window (widget) to be packed. 4165 * Create a new percent bar window (widget) to be packed.
4166 * Parameters: 4166 * Parameters:
4167 * id: An ID to be used with WinWindowFromID() or 0L. 4167 * id: An ID to be used with WinWindowFromID() or 0L.
4168 */ 4168 */
4169 HWND dw_percent_new(ULONG id) 4169 HWND API dw_percent_new(ULONG id)
4170 { 4170 {
4171 return CreateWindow(PROGRESS_CLASS, 4171 return CreateWindow(PROGRESS_CLASS,
4172 "", 4172 "",
4173 WS_VISIBLE | WS_CHILD | WS_CLIPCHILDREN, 4173 WS_VISIBLE | WS_CHILD | WS_CLIPCHILDREN,
4174 0,0,2000,1000, 4174 0,0,2000,1000,
4182 * Create a new checkbox window (widget) to be packed. 4182 * Create a new checkbox window (widget) to be packed.
4183 * Parameters: 4183 * Parameters:
4184 * text: The text to be display by the static text widget. 4184 * text: The text to be display by the static text widget.
4185 * id: An ID to be used with WinWindowFromID() or 0L. 4185 * id: An ID to be used with WinWindowFromID() or 0L.
4186 */ 4186 */
4187 HWND dw_checkbox_new(char *text, ULONG id) 4187 HWND API dw_checkbox_new(char *text, ULONG id)
4188 { 4188 {
4189 BubbleButton *bubble = calloc(1, sizeof(BubbleButton)); 4189 BubbleButton *bubble = calloc(1, sizeof(BubbleButton));
4190 HWND tmp = CreateWindow(BUTTONCLASSNAME, 4190 HWND tmp = CreateWindow(BUTTONCLASSNAME,
4191 text, 4191 text,
4192 WS_CHILD | BS_AUTOCHECKBOX | 4192 WS_CHILD | BS_AUTOCHECKBOX |
4210 * Create a new listbox window (widget) to be packed. 4210 * Create a new listbox window (widget) to be packed.
4211 * Parameters: 4211 * Parameters:
4212 * id: An ID to be used with WinWindowFromID() or 0L. 4212 * id: An ID to be used with WinWindowFromID() or 0L.
4213 * multi: Multiple select TRUE or FALSE. 4213 * multi: Multiple select TRUE or FALSE.
4214 */ 4214 */
4215 HWND dw_listbox_new(ULONG id, int multi) 4215 HWND API dw_listbox_new(ULONG id, int multi)
4216 { 4216 {
4217 HWND tmp = CreateWindowEx(WS_EX_CLIENTEDGE, 4217 HWND tmp = CreateWindowEx(WS_EX_CLIENTEDGE,
4218 LISTBOXCLASSNAME, 4218 LISTBOXCLASSNAME,
4219 "", 4219 "",
4220 WS_VISIBLE | LBS_NOINTEGRALHEIGHT | 4220 WS_VISIBLE | LBS_NOINTEGRALHEIGHT |
4247 * Sets the icon used for a given window. 4247 * Sets the icon used for a given window.
4248 * Parameters: 4248 * Parameters:
4249 * handle: Handle to the window. 4249 * handle: Handle to the window.
4250 * id: An ID to be used to specify the icon. 4250 * id: An ID to be used to specify the icon.
4251 */ 4251 */
4252 void dw_window_set_icon(HWND handle, ULONG id) 4252 void API dw_window_set_icon(HWND handle, ULONG id)
4253 { 4253 {
4254 HICON hicon = LoadIcon(DWInstance, MAKEINTRESOURCE(id)); 4254 HICON hicon = LoadIcon(DWInstance, MAKEINTRESOURCE(id));
4255 4255
4256 SendMessage(handle, WM_SETICON, 4256 SendMessage(handle, WM_SETICON,
4257 (WPARAM) IMAGE_ICON, 4257 (WPARAM) IMAGE_ICON,
4262 * Sets the bitmap used for a given static window. 4262 * Sets the bitmap used for a given static window.
4263 * Parameters: 4263 * Parameters:
4264 * handle: Handle to the window. 4264 * handle: Handle to the window.
4265 * id: An ID to be used to specify the icon. 4265 * id: An ID to be used to specify the icon.
4266 */ 4266 */
4267 void dw_window_set_bitmap(HWND handle, ULONG id) 4267 void API dw_window_set_bitmap(HWND handle, ULONG id)
4268 { 4268 {
4269 HBITMAP hbitmap = LoadBitmap(DWInstance, MAKEINTRESOURCE(id)); 4269 HBITMAP hbitmap = LoadBitmap(DWInstance, MAKEINTRESOURCE(id));
4270 HBITMAP oldbitmap = (HBITMAP)SendMessage(handle, STM_GETIMAGE, IMAGE_BITMAP, 0); 4270 HBITMAP oldbitmap = (HBITMAP)SendMessage(handle, STM_GETIMAGE, IMAGE_BITMAP, 0);
4271 4271
4272 SendMessage(handle, STM_SETIMAGE, 4272 SendMessage(handle, STM_SETIMAGE,
4281 * Sets the text used for a given window. 4281 * Sets the text used for a given window.
4282 * Parameters: 4282 * Parameters:
4283 * handle: Handle to the window. 4283 * handle: Handle to the window.
4284 * text: The text associsated with a given window. 4284 * text: The text associsated with a given window.
4285 */ 4285 */
4286 void dw_window_set_text(HWND handle, char *text) 4286 void API dw_window_set_text(HWND handle, char *text)
4287 { 4287 {
4288 char tmpbuf[100]; 4288 char tmpbuf[100];
4289 4289
4290 GetClassName(handle, tmpbuf, 99); 4290 GetClassName(handle, tmpbuf, 99);
4291 4291
4301 * Parameters: 4301 * Parameters:
4302 * handle: Handle to the window. 4302 * handle: Handle to the window.
4303 * Returns: 4303 * Returns:
4304 * text: The text associsated with a given window. 4304 * text: The text associsated with a given window.
4305 */ 4305 */
4306 char *dw_window_get_text(HWND handle) 4306 char * API dw_window_get_text(HWND handle)
4307 { 4307 {
4308 int len = GetWindowTextLength(handle); 4308 int len = GetWindowTextLength(handle);
4309 char *tempbuf = calloc(1, len + 2); 4309 char *tempbuf = calloc(1, len + 2);
4310 4310
4311 GetWindowText(handle, tempbuf, len + 1); 4311 GetWindowText(handle, tempbuf, len + 1);
4316 /* 4316 /*
4317 * Disables given window (widget). 4317 * Disables given window (widget).
4318 * Parameters: 4318 * Parameters:
4319 * handle: Handle to the window. 4319 * handle: Handle to the window.
4320 */ 4320 */
4321 void dw_window_disable(HWND handle) 4321 void API dw_window_disable(HWND handle)
4322 { 4322 {
4323 EnableWindow(handle, FALSE); 4323 EnableWindow(handle, FALSE);
4324 } 4324 }
4325 4325
4326 /* 4326 /*
4327 * Enables given window (widget). 4327 * Enables given window (widget).
4328 * Parameters: 4328 * Parameters:
4329 * handle: Handle to the window. 4329 * handle: Handle to the window.
4330 */ 4330 */
4331 void dw_window_enable(HWND handle) 4331 void API dw_window_enable(HWND handle)
4332 { 4332 {
4333 EnableWindow(handle, TRUE); 4333 EnableWindow(handle, TRUE);
4334 } 4334 }
4335 4335
4336 /* 4336 /*
4337 * Gets the child window handle with specified ID. 4337 * Gets the child window handle with specified ID.
4338 * Parameters: 4338 * Parameters:
4339 * handle: Handle to the parent window. 4339 * handle: Handle to the parent window.
4340 * id: Integer ID of the child. 4340 * id: Integer ID of the child.
4341 */ 4341 */
4342 HWND dw_window_from_id(HWND handle, int id) 4342 HWND API dw_window_from_id(HWND handle, int id)
4343 { 4343 {
4344 return 0L; 4344 return 0L;
4345 } 4345 }
4346 /* 4346 /*
4347 * Pack windows (widgets) into a box from the start (or top). 4347 * Pack windows (widgets) into a box from the start (or top).
4352 * height: Height in pixels of the item or -1 to be self determined. 4352 * height: Height in pixels of the item or -1 to be self determined.
4353 * hsize: TRUE if the window (widget) should expand horizontally to fill space given. 4353 * hsize: TRUE if the window (widget) should expand horizontally to fill space given.
4354 * vsize: TRUE if the window (widget) should expand vertically to fill space given. 4354 * vsize: TRUE if the window (widget) should expand vertically to fill space given.
4355 * pad: Number of pixels of padding around the item. 4355 * pad: Number of pixels of padding around the item.
4356 */ 4356 */
4357 void dw_box_pack_start(HWND box, HWND item, int width, int height, int hsize, int vsize, int pad) 4357 void API dw_box_pack_start(HWND box, HWND item, int width, int height, int hsize, int vsize, int pad)
4358 { 4358 {
4359 Box *thisbox; 4359 Box *thisbox;
4360 4360
4361 thisbox = (Box *)GetWindowLong(box, GWL_USERDATA); 4361 thisbox = (Box *)GetWindowLong(box, GWL_USERDATA);
4362 if(thisbox) 4362 if(thisbox)
4420 * Parameters: 4420 * Parameters:
4421 * handle: Window (widget) handle. 4421 * handle: Window (widget) handle.
4422 * width: New width in pixels. 4422 * width: New width in pixels.
4423 * height: New height in pixels. 4423 * height: New height in pixels.
4424 */ 4424 */
4425 void dw_window_set_usize(HWND handle, ULONG width, ULONG height) 4425 void API dw_window_set_usize(HWND handle, ULONG width, ULONG height)
4426 { 4426 {
4427 SetWindowPos(handle, (HWND)NULL, 0, 0, width, height, SWP_SHOWWINDOW | SWP_NOZORDER | SWP_NOMOVE); 4427 SetWindowPos(handle, (HWND)NULL, 0, 0, width, height, SWP_SHOWWINDOW | SWP_NOZORDER | SWP_NOMOVE);
4428 } 4428 }
4429 4429
4430 /* 4430 /*
4431 * Returns the width of the screen. 4431 * Returns the width of the screen.
4432 */ 4432 */
4433 int dw_screen_width(void) 4433 int API dw_screen_width(void)
4434 { 4434 {
4435 return GetSystemMetrics(SM_CXSCREEN); 4435 return GetSystemMetrics(SM_CXSCREEN);
4436 } 4436 }
4437 4437
4438 /* 4438 /*
4439 * Returns the height of the screen. 4439 * Returns the height of the screen.
4440 */ 4440 */
4441 int dw_screen_height(void) 4441 int API dw_screen_height(void)
4442 { 4442 {
4443 return GetSystemMetrics(SM_CYSCREEN); 4443 return GetSystemMetrics(SM_CYSCREEN);
4444 } 4444 }
4445 4445
4446 /* This should return the current color depth */ 4446 /* This should return the current color depth */
4447 unsigned long dw_color_depth(void) 4447 unsigned long API dw_color_depth(void)
4448 { 4448 {
4449 int bpp; 4449 int bpp;
4450 HDC hdc = GetDC(HWND_DESKTOP); 4450 HDC hdc = GetDC(HWND_DESKTOP);
4451 4451
4452 bpp = GetDeviceCaps(hdc, BITSPIXEL); 4452 bpp = GetDeviceCaps(hdc, BITSPIXEL);
4462 * Parameters: 4462 * Parameters:
4463 * handle: Window (widget) handle. 4463 * handle: Window (widget) handle.
4464 * x: X location from the bottom left. 4464 * x: X location from the bottom left.
4465 * y: Y location from the bottom left. 4465 * y: Y location from the bottom left.
4466 */ 4466 */
4467 void dw_window_set_pos(HWND handle, ULONG x, ULONG y) 4467 void API dw_window_set_pos(HWND handle, ULONG x, ULONG y)
4468 { 4468 {
4469 SetWindowPos(handle, (HWND)NULL, x, y, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE); 4469 SetWindowPos(handle, (HWND)NULL, x, y, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
4470 } 4470 }
4471 4471
4472 /* 4472 /*
4476 * x: X location from the bottom left. 4476 * x: X location from the bottom left.
4477 * y: Y location from the bottom left. 4477 * y: Y location from the bottom left.
4478 * width: Width of the widget. 4478 * width: Width of the widget.
4479 * height: Height of the widget. 4479 * height: Height of the widget.
4480 */ 4480 */
4481 void dw_window_set_pos_size(HWND handle, ULONG x, ULONG y, ULONG width, ULONG height) 4481 void API dw_window_set_pos_size(HWND handle, ULONG x, ULONG y, ULONG width, ULONG height)
4482 { 4482 {
4483 SetWindowPos(handle, (HWND)NULL, x, y, width, height, SWP_NOZORDER | SWP_SHOWWINDOW | SWP_NOACTIVATE); 4483 SetWindowPos(handle, (HWND)NULL, x, y, width, height, SWP_NOZORDER | SWP_SHOWWINDOW | SWP_NOACTIVATE);
4484 } 4484 }
4485 4485
4486 /* 4486 /*
4490 * x: X location from the bottom left. 4490 * x: X location from the bottom left.
4491 * y: Y location from the bottom left. 4491 * y: Y location from the bottom left.
4492 * width: Width of the widget. 4492 * width: Width of the widget.
4493 * height: Height of the widget. 4493 * height: Height of the widget.
4494 */ 4494 */
4495 void dw_window_get_pos_size(HWND handle, ULONG *x, ULONG *y, ULONG *width, ULONG *height) 4495 void API dw_window_get_pos_size(HWND handle, ULONG *x, ULONG *y, ULONG *width, ULONG *height)
4496 { 4496 {
4497 WINDOWPLACEMENT wp; 4497 WINDOWPLACEMENT wp;
4498 4498
4499 wp.length = sizeof(WINDOWPLACEMENT); 4499 wp.length = sizeof(WINDOWPLACEMENT);
4500 4500
4515 * Parameters: 4515 * Parameters:
4516 * handle: Window (widget) handle. 4516 * handle: Window (widget) handle.
4517 * width: New width in pixels. 4517 * width: New width in pixels.
4518 * height: New height in pixels. 4518 * height: New height in pixels.
4519 */ 4519 */
4520 void dw_window_set_style(HWND handle, ULONG style, ULONG mask) 4520 void API dw_window_set_style(HWND handle, ULONG style, ULONG mask)
4521 { 4521 {
4522 ULONG tmp, currentstyle = GetWindowLong(handle, GWL_STYLE); 4522 ULONG tmp, currentstyle = GetWindowLong(handle, GWL_STYLE);
4523 ColorInfo *cinfo = (ColorInfo *)GetWindowLong(handle, GWL_USERDATA); 4523 ColorInfo *cinfo = (ColorInfo *)GetWindowLong(handle, GWL_USERDATA);
4524 4524
4525 tmp = currentstyle | mask; 4525 tmp = currentstyle | mask;
4567 * Parameters: 4567 * Parameters:
4568 * handle: Window (widget) handle. 4568 * handle: Window (widget) handle.
4569 * flags: Any additional page creation flags. 4569 * flags: Any additional page creation flags.
4570 * front: If TRUE page is added at the beginning. 4570 * front: If TRUE page is added at the beginning.
4571 */ 4571 */
4572 ULONG dw_notebook_page_new(HWND handle, ULONG flags, int front) 4572 unsigned long API dw_notebook_page_new(HWND handle, ULONG flags, int front)
4573 { 4573 {
4574 NotebookPage **array = (NotebookPage **)GetWindowLong(handle, GWL_USERDATA); 4574 NotebookPage **array = (NotebookPage **)GetWindowLong(handle, GWL_USERDATA);
4575 4575
4576 if(array) 4576 if(array)
4577 { 4577 {
4618 * Parameters: 4618 * Parameters:
4619 * handle: Notebook handle. 4619 * handle: Notebook handle.
4620 * pageid: Page ID of the tab to set. 4620 * pageid: Page ID of the tab to set.
4621 * text: Pointer to the text to set. 4621 * text: Pointer to the text to set.
4622 */ 4622 */
4623 void dw_notebook_page_set_text(HWND handle, ULONG pageidx, char *text) 4623 void API dw_notebook_page_set_text(HWND handle, ULONG pageidx, char *text)
4624 { 4624 {
4625 4625
4626 NotebookPage **array = (NotebookPage **)GetWindowLong(handle, GWL_USERDATA); 4626 NotebookPage **array = (NotebookPage **)GetWindowLong(handle, GWL_USERDATA);
4627 int pageid; 4627 int pageid;
4628 4628
4645 * Parameters: 4645 * Parameters:
4646 * handle: Notebook handle. 4646 * handle: Notebook handle.
4647 * pageid: Page ID of the tab to set. 4647 * pageid: Page ID of the tab to set.
4648 * text: Pointer to the text to set. 4648 * text: Pointer to the text to set.
4649 */ 4649 */
4650 void dw_notebook_page_set_status_text(HWND handle, ULONG pageid, char *text) 4650 void API dw_notebook_page_set_status_text(HWND handle, ULONG pageid, char *text)
4651 { 4651 {
4652 } 4652 }
4653 4653
4654 /* 4654 /*
4655 * Packs the specified box into the notebook page. 4655 * Packs the specified box into the notebook page.
4656 * Parameters: 4656 * Parameters:
4657 * handle: Handle to the notebook to be packed. 4657 * handle: Handle to the notebook to be packed.
4658 * pageid: Page ID in the notebook which is being packed. 4658 * pageid: Page ID in the notebook which is being packed.
4659 * page: Box handle to be packed. 4659 * page: Box handle to be packed.
4660 */ 4660 */
4661 void dw_notebook_pack(HWND handle, ULONG pageidx, HWND page) 4661 void API dw_notebook_pack(HWND handle, ULONG pageidx, HWND page)
4662 { 4662 {
4663 NotebookPage **array = (NotebookPage **)GetWindowLong(handle, GWL_USERDATA); 4663 NotebookPage **array = (NotebookPage **)GetWindowLong(handle, GWL_USERDATA);
4664 int pageid; 4664 int pageid;
4665 4665
4666 if(!array) 4666 if(!array)
4689 * Remove a page from a notebook. 4689 * Remove a page from a notebook.
4690 * Parameters: 4690 * Parameters:
4691 * handle: Handle to the notebook widget. 4691 * handle: Handle to the notebook widget.
4692 * pageid: ID of the page to be destroyed. 4692 * pageid: ID of the page to be destroyed.
4693 */ 4693 */
4694 void dw_notebook_page_destroy(HWND handle, unsigned int pageidx) 4694 void API dw_notebook_page_destroy(HWND handle, unsigned int pageidx)
4695 { 4695 {
4696 NotebookPage **array = (NotebookPage **)GetWindowLong(handle, GWL_USERDATA); 4696 NotebookPage **array = (NotebookPage **)GetWindowLong(handle, GWL_USERDATA);
4697 int newid = -1, z, pageid; 4697 int newid = -1, z, pageid;
4698 4698
4699 if(!array) 4699 if(!array)
4737 /* 4737 /*
4738 * Queries the currently visible page ID. 4738 * Queries the currently visible page ID.
4739 * Parameters: 4739 * Parameters:
4740 * handle: Handle to the notebook widget. 4740 * handle: Handle to the notebook widget.
4741 */ 4741 */
4742 unsigned int dw_notebook_page_query(HWND handle) 4742 unsigned int API dw_notebook_page_query(HWND handle)
4743 { 4743 {
4744 NotebookPage **array = (NotebookPage **)GetWindowLong(handle, GWL_USERDATA); 4744 NotebookPage **array = (NotebookPage **)GetWindowLong(handle, GWL_USERDATA);
4745 int physid = TabCtrl_GetCurSel(handle); 4745 int physid = TabCtrl_GetCurSel(handle);
4746 4746
4747 if(physid > -1 && physid < 256 && array && array[physid]) 4747 if(physid > -1 && physid < 256 && array && array[physid])
4753 * Sets the currently visible page ID. 4753 * Sets the currently visible page ID.
4754 * Parameters: 4754 * Parameters:
4755 * handle: Handle to the notebook widget. 4755 * handle: Handle to the notebook widget.
4756 * pageid: ID of the page to be made visible. 4756 * pageid: ID of the page to be made visible.
4757 */ 4757 */
4758 void dw_notebook_page_set(HWND handle, unsigned int pageidx) 4758 void API dw_notebook_page_set(HWND handle, unsigned int pageidx)
4759 { 4759 {
4760 NotebookPage **array = (NotebookPage **)GetWindowLong(handle, GWL_USERDATA); 4760 NotebookPage **array = (NotebookPage **)GetWindowLong(handle, GWL_USERDATA);
4761 int pageid; 4761 int pageid;
4762 4762
4763 if(!array) 4763 if(!array)
4783 * Appends the specified text to the listbox's (or combobox) entry list. 4783 * Appends the specified text to the listbox's (or combobox) entry list.
4784 * Parameters: 4784 * Parameters:
4785 * handle: Handle to the listbox to be appended to. 4785 * handle: Handle to the listbox to be appended to.
4786 * text: Text to append into listbox. 4786 * text: Text to append into listbox.
4787 */ 4787 */
4788 void dw_listbox_append(HWND handle, char *text) 4788 void API dw_listbox_append(HWND handle, char *text)
4789 { 4789 {
4790 char tmpbuf[100]; 4790 char tmpbuf[100];
4791 4791
4792 GetClassName(handle, tmpbuf, 99); 4792 GetClassName(handle, tmpbuf, 99);
4793 4793
4804 /* 4804 /*
4805 * Clears the listbox's (or combobox) list of all entries. 4805 * Clears the listbox's (or combobox) list of all entries.
4806 * Parameters: 4806 * Parameters:
4807 * handle: Handle to the listbox to be cleared. 4807 * handle: Handle to the listbox to be cleared.
4808 */ 4808 */
4809 void dw_listbox_clear(HWND handle) 4809 void API dw_listbox_clear(HWND handle)
4810 { 4810 {
4811 char tmpbuf[100]; 4811 char tmpbuf[100];
4812 4812
4813 GetClassName(handle, tmpbuf, 99); 4813 GetClassName(handle, tmpbuf, 99);
4814 4814
4835 * Parameters: 4835 * Parameters:
4836 * handle: Handle to the listbox to be queried. 4836 * handle: Handle to the listbox to be queried.
4837 * index: Index into the list to be queried. 4837 * index: Index into the list to be queried.
4838 * buffer: Buffer where text will be copied. 4838 * buffer: Buffer where text will be copied.
4839 */ 4839 */
4840 void dw_listbox_set_text(HWND handle, unsigned int index, char *buffer) 4840 void API dw_listbox_set_text(HWND handle, unsigned int index, char *buffer)
4841 { 4841 {
4842 unsigned int sel = (unsigned int)SendMessage(handle, LB_GETCURSEL, 0, 0); 4842 unsigned int sel = (unsigned int)SendMessage(handle, LB_GETCURSEL, 0, 0);
4843 SendMessage(handle, LB_DELETESTRING, (WPARAM)index, 0); 4843 SendMessage(handle, LB_DELETESTRING, (WPARAM)index, 0);
4844 SendMessage(handle, LB_INSERTSTRING, (WPARAM)index, (LPARAM)buffer); 4844 SendMessage(handle, LB_INSERTSTRING, (WPARAM)index, (LPARAM)buffer);
4845 SendMessage(handle, LB_SETCURSEL, (WPARAM)sel, 0); 4845 SendMessage(handle, LB_SETCURSEL, (WPARAM)sel, 0);
4852 * handle: Handle to the listbox to be queried. 4852 * handle: Handle to the listbox to be queried.
4853 * index: Index into the list to be queried. 4853 * index: Index into the list to be queried.
4854 * buffer: Buffer where text will be copied. 4854 * buffer: Buffer where text will be copied.
4855 * length: Length of the buffer (including NULL). 4855 * length: Length of the buffer (including NULL).
4856 */ 4856 */
4857 void dw_listbox_query_text(HWND handle, unsigned int index, char *buffer, unsigned int length) 4857 void API dw_listbox_query_text(HWND handle, unsigned int index, char *buffer, unsigned int length)
4858 { 4858 {
4859 SendMessage(handle, 4859 SendMessage(handle,
4860 LB_GETTEXT, (WPARAM)index, (LPARAM)buffer); 4860 LB_GETTEXT, (WPARAM)index, (LPARAM)buffer);
4861 } 4861 }
4862 4862
4863 /* 4863 /*
4864 * Returns the index to the item in the list currently selected. 4864 * Returns the index to the item in the list currently selected.
4865 * Parameters: 4865 * Parameters:
4866 * handle: Handle to the listbox to be queried. 4866 * handle: Handle to the listbox to be queried.
4867 */ 4867 */
4868 unsigned int dw_listbox_selected(HWND handle) 4868 unsigned int API dw_listbox_selected(HWND handle)
4869 { 4869 {
4870 char tmpbuf[100]; 4870 char tmpbuf[100];
4871 4871
4872 GetClassName(handle, tmpbuf, 99); 4872 GetClassName(handle, tmpbuf, 99);
4873 4873
4885 * Returns the index to the current selected item or -1 when done. 4885 * Returns the index to the current selected item or -1 when done.
4886 * Parameters: 4886 * Parameters:
4887 * handle: Handle to the listbox to be queried. 4887 * handle: Handle to the listbox to be queried.
4888 * where: Either the previous return or -1 to restart. 4888 * where: Either the previous return or -1 to restart.
4889 */ 4889 */
4890 int dw_listbox_selected_multi(HWND handle, int where) 4890 int API dw_listbox_selected_multi(HWND handle, int where)
4891 { 4891 {
4892 int *array, count, z; 4892 int *array, count, z;
4893 4893
4894 count = (int)SendMessage(handle, LB_GETSELCOUNT, 0, 0); 4894 count = (int)SendMessage(handle, LB_GETSELCOUNT, 0, 0);
4895 if(count > 0) 4895 if(count > 0)
4922 * Parameters: 4922 * Parameters:
4923 * handle: Handle to the listbox to be set. 4923 * handle: Handle to the listbox to be set.
4924 * index: Item index. 4924 * index: Item index.
4925 * state: TRUE if selected FALSE if unselected. 4925 * state: TRUE if selected FALSE if unselected.
4926 */ 4926 */
4927 void dw_listbox_select(HWND handle, int index, int state) 4927 void API dw_listbox_select(HWND handle, int index, int state)
4928 { 4928 {
4929 char tmpbuf[100]; 4929 char tmpbuf[100];
4930 4930
4931 GetClassName(handle, tmpbuf, 99); 4931 GetClassName(handle, tmpbuf, 99);
4932 4932
4944 * Deletes the item with given index from the list. 4944 * Deletes the item with given index from the list.
4945 * Parameters: 4945 * Parameters:
4946 * handle: Handle to the listbox to be set. 4946 * handle: Handle to the listbox to be set.
4947 * index: Item index. 4947 * index: Item index.
4948 */ 4948 */
4949 void dw_listbox_delete(HWND handle, int index) 4949 void API dw_listbox_delete(HWND handle, int index)
4950 { 4950 {
4951 SendMessage(handle, LB_DELETESTRING, (WPARAM)index, 0); 4951 SendMessage(handle, LB_DELETESTRING, (WPARAM)index, 0);
4952 } 4952 }
4953 4953
4954 /* 4954 /*
4955 * Returns the listbox's item count. 4955 * Returns the listbox's item count.
4956 * Parameters: 4956 * Parameters:
4957 * handle: Handle to the listbox to be cleared. 4957 * handle: Handle to the listbox to be cleared.
4958 */ 4958 */
4959 int dw_listbox_count(HWND handle) 4959 int API dw_listbox_count(HWND handle)
4960 { 4960 {
4961 char tmpbuf[100]; 4961 char tmpbuf[100];
4962 4962
4963 GetClassName(handle, tmpbuf, 99); 4963 GetClassName(handle, tmpbuf, 99);
4964 4964
4974 * Sets the topmost item in the viewport. 4974 * Sets the topmost item in the viewport.
4975 * Parameters: 4975 * Parameters:
4976 * handle: Handle to the listbox to be cleared. 4976 * handle: Handle to the listbox to be cleared.
4977 * top: Index to the top item. 4977 * top: Index to the top item.
4978 */ 4978 */
4979 void dw_listbox_set_top(HWND handle, int top) 4979 void API dw_listbox_set_top(HWND handle, int top)
4980 { 4980 {
4981 SendMessage(handle, LB_SETTOPINDEX, (WPARAM)top, 0); 4981 SendMessage(handle, LB_SETTOPINDEX, (WPARAM)top, 0);
4982 } 4982 }
4983 4983
4984 /* 4984 /*
4986 * Parameters: 4986 * Parameters:
4987 * handle: Handle to the MLE to be queried. 4987 * handle: Handle to the MLE to be queried.
4988 * buffer: Text buffer to be imported. 4988 * buffer: Text buffer to be imported.
4989 * startpoint: Point to start entering text. 4989 * startpoint: Point to start entering text.
4990 */ 4990 */
4991 unsigned int dw_mle_import(HWND handle, char *buffer, int startpoint) 4991 unsigned int API dw_mle_import(HWND handle, char *buffer, int startpoint)
4992 { 4992 {
4993 int textlen, len = GetWindowTextLength(handle); 4993 int textlen, len = GetWindowTextLength(handle);
4994 char *tmpbuf; 4994 char *tmpbuf;
4995 4995
4996 if((textlen = strlen(buffer)) < 1) 4996 if((textlen = strlen(buffer)) < 1)
5029 * handle: Handle to the MLE to be queried. 5029 * handle: Handle to the MLE to be queried.
5030 * buffer: Text buffer to be exported. 5030 * buffer: Text buffer to be exported.
5031 * startpoint: Point to start grabbing text. 5031 * startpoint: Point to start grabbing text.
5032 * length: Amount of text to be grabbed. 5032 * length: Amount of text to be grabbed.
5033 */ 5033 */
5034 void dw_mle_export(HWND handle, char *buffer, int startpoint, int length) 5034 void API dw_mle_export(HWND handle, char *buffer, int startpoint, int length)
5035 { 5035 {
5036 int max, len = GetWindowTextLength(handle); 5036 int max, len = GetWindowTextLength(handle);
5037 char *tmpbuf = calloc(1, len+2); 5037 char *tmpbuf = calloc(1, len+2);
5038 5038
5039 if(len) 5039 if(len)
5056 * Parameters: 5056 * Parameters:
5057 * handle: Handle to the MLE to be queried. 5057 * handle: Handle to the MLE to be queried.
5058 * bytes: A pointer to a variable to return the total bytes. 5058 * bytes: A pointer to a variable to return the total bytes.
5059 * lines: A pointer to a variable to return the number of lines. 5059 * lines: A pointer to a variable to return the number of lines.
5060 */ 5060 */
5061 void dw_mle_query(HWND handle, unsigned long *bytes, unsigned long *lines) 5061 void API dw_mle_query(HWND handle, unsigned long *bytes, unsigned long *lines)
5062 { 5062 {
5063 if(bytes) 5063 if(bytes)
5064 *bytes = GetWindowTextLength(handle); 5064 *bytes = GetWindowTextLength(handle);
5065 if(lines) 5065 if(lines)
5066 *lines = (unsigned long)SendMessage(handle, EM_GETLINECOUNT, 0, 0); 5066 *lines = (unsigned long)SendMessage(handle, EM_GETLINECOUNT, 0, 0);
5071 * Parameters: 5071 * Parameters:
5072 * handle: Handle to the MLE to be deleted from. 5072 * handle: Handle to the MLE to be deleted from.
5073 * startpoint: Point to start deleting text. 5073 * startpoint: Point to start deleting text.
5074 * length: Amount of text to be deleted. 5074 * length: Amount of text to be deleted.
5075 */ 5075 */
5076 void dw_mle_delete(HWND handle, int startpoint, int length) 5076 void API dw_mle_delete(HWND handle, int startpoint, int length)
5077 { 5077 {
5078 int len = GetWindowTextLength(handle); 5078 int len = GetWindowTextLength(handle);
5079 char *tmpbuf = calloc(1, len+2); 5079 char *tmpbuf = calloc(1, len+2);
5080 5080
5081 GetWindowText(handle, tmpbuf, len+1); 5081 GetWindowText(handle, tmpbuf, len+1);
5093 /* 5093 /*
5094 * Clears all text from an MLE box. 5094 * Clears all text from an MLE box.
5095 * Parameters: 5095 * Parameters:
5096 * handle: Handle to the MLE to be cleared. 5096 * handle: Handle to the MLE to be cleared.
5097 */ 5097 */
5098 void dw_mle_clear(HWND handle) 5098 void API dw_mle_clear(HWND handle)
5099 { 5099 {
5100 SetWindowText(handle, ""); 5100 SetWindowText(handle, "");
5101 } 5101 }
5102 5102
5103 /* 5103 /*
5104 * Sets the visible line of an MLE box. 5104 * Sets the visible line of an MLE box.
5105 * Parameters: 5105 * Parameters:
5106 * handle: Handle to the MLE. 5106 * handle: Handle to the MLE.
5107 * line: Line to be visible. 5107 * line: Line to be visible.
5108 */ 5108 */
5109 void dw_mle_set_visible(HWND handle, int line) 5109 void API dw_mle_set_visible(HWND handle, int line)
5110 { 5110 {
5111 int point = (int)SendMessage(handle, EM_LINEINDEX, (WPARAM)line, 0); 5111 int point = (int)SendMessage(handle, EM_LINEINDEX, (WPARAM)line, 0);
5112 dw_mle_set(handle, point); 5112 dw_mle_set(handle, point);
5113 } 5113 }
5114 5114
5116 * Sets the editablity of an MLE box. 5116 * Sets the editablity of an MLE box.
5117 * Parameters: 5117 * Parameters:
5118 * handle: Handle to the MLE. 5118 * handle: Handle to the MLE.
5119 * state: TRUE if it can be edited, FALSE for readonly. 5119 * state: TRUE if it can be edited, FALSE for readonly.
5120 */ 5120 */
5121 void dw_mle_set_editable(HWND handle, int state) 5121 void API dw_mle_set_editable(HWND handle, int state)
5122 { 5122 {
5123 SendMessage(handle, EM_SETREADONLY, (WPARAM)(state ? FALSE : TRUE), 0); 5123 SendMessage(handle, EM_SETREADONLY, (WPARAM)(state ? FALSE : TRUE), 0);
5124 } 5124 }
5125 5125
5126 /* 5126 /*
5127 * Sets the word wrap state of an MLE box. 5127 * Sets the word wrap state of an MLE box.
5128 * Parameters: 5128 * Parameters:
5129 * handle: Handle to the MLE. 5129 * handle: Handle to the MLE.
5130 * state: TRUE if it wraps, FALSE if it doesn't. 5130 * state: TRUE if it wraps, FALSE if it doesn't.
5131 */ 5131 */
5132 void dw_mle_set_word_wrap(HWND handle, int state) 5132 void API dw_mle_set_word_wrap(HWND handle, int state)
5133 { 5133 {
5134 /* If ES_AUTOHSCROLL is not set and there is not 5134 /* If ES_AUTOHSCROLL is not set and there is not
5135 * horizontal scrollbar it word wraps. 5135 * horizontal scrollbar it word wraps.
5136 */ 5136 */
5137 if(state) 5137 if(state)
5144 * Sets the current cursor position of an MLE box. 5144 * Sets the current cursor position of an MLE box.
5145 * Parameters: 5145 * Parameters:
5146 * handle: Handle to the MLE to be positioned. 5146 * handle: Handle to the MLE to be positioned.
5147 * point: Point to position cursor. 5147 * point: Point to position cursor.
5148 */ 5148 */
5149 void dw_mle_set(HWND handle, int point) 5149 void API dw_mle_set(HWND handle, int point)
5150 { 5150 {
5151 SendMessage(handle, EM_SETSEL, (WPARAM)point, (LPARAM)point); 5151 SendMessage(handle, EM_SETSEL, (WPARAM)point, (LPARAM)point);
5152 SendMessage(handle, EM_SCROLLCARET, 0, 0); 5152 SendMessage(handle, EM_SCROLLCARET, 0, 0);
5153 } 5153 }
5154 5154
5158 * handle: Handle to the MLE to be cleared. 5158 * handle: Handle to the MLE to be cleared.
5159 * text: Text to search for. 5159 * text: Text to search for.
5160 * point: Start point of search. 5160 * point: Start point of search.
5161 * flags: Search specific flags. 5161 * flags: Search specific flags.
5162 */ 5162 */
5163 int dw_mle_search(HWND handle, char *text, int point, unsigned long flags) 5163 int API dw_mle_search(HWND handle, char *text, int point, unsigned long flags)
5164 { 5164 {
5165 int len = GetWindowTextLength(handle); 5165 int len = GetWindowTextLength(handle);
5166 char *tmpbuf = calloc(1, len+2); 5166 char *tmpbuf = calloc(1, len+2);
5167 int z, textlen, retval = 0; 5167 int z, textlen, retval = 0;
5168 5168
5201 /* 5201 /*
5202 * Stops redrawing of an MLE box. 5202 * Stops redrawing of an MLE box.
5203 * Parameters: 5203 * Parameters:
5204 * handle: Handle to the MLE to freeze. 5204 * handle: Handle to the MLE to freeze.
5205 */ 5205 */
5206 void dw_mle_freeze(HWND handle) 5206 void API dw_mle_freeze(HWND handle)
5207 { 5207 {
5208 } 5208 }
5209 5209
5210 /* 5210 /*
5211 * Resumes redrawing of an MLE box. 5211 * Resumes redrawing of an MLE box.
5212 * Parameters: 5212 * Parameters:
5213 * handle: Handle to the MLE to thaw. 5213 * handle: Handle to the MLE to thaw.
5214 */ 5214 */
5215 void dw_mle_thaw(HWND handle) 5215 void API dw_mle_thaw(HWND handle)
5216 { 5216 {
5217 } 5217 }
5218 5218
5219 /* 5219 /*
5220 * Returns the range of the percent bar. 5220 * Returns the range of the percent bar.
5221 * Parameters: 5221 * Parameters:
5222 * handle: Handle to the percent bar to be queried. 5222 * handle: Handle to the percent bar to be queried.
5223 */ 5223 */
5224 unsigned int dw_percent_query_range(HWND handle) 5224 unsigned int API dw_percent_query_range(HWND handle)
5225 { 5225 {
5226 return (unsigned int)SendMessage(handle, PBM_GETRANGE, (WPARAM)FALSE, 0); 5226 return (unsigned int)SendMessage(handle, PBM_GETRANGE, (WPARAM)FALSE, 0);
5227 } 5227 }
5228 5228
5229 /* 5229 /*
5230 * Sets the percent bar position. 5230 * Sets the percent bar position.
5231 * Parameters: 5231 * Parameters:
5232 * handle: Handle to the percent bar to be set. 5232 * handle: Handle to the percent bar to be set.
5233 * position: Position of the percent bar withing the range. 5233 * position: Position of the percent bar withing the range.
5234 */ 5234 */
5235 void dw_percent_set_pos(HWND handle, unsigned int position) 5235 void API dw_percent_set_pos(HWND handle, unsigned int position)
5236 { 5236 {
5237 SendMessage(handle, PBM_SETPOS, (WPARAM)position, 0); 5237 SendMessage(handle, PBM_SETPOS, (WPARAM)position, 0);
5238 } 5238 }
5239 5239
5240 /* 5240 /*
5241 * Returns the position of the slider. 5241 * Returns the position of the slider.
5242 * Parameters: 5242 * Parameters:
5243 * handle: Handle to the slider to be queried. 5243 * handle: Handle to the slider to be queried.
5244 */ 5244 */
5245 unsigned int dw_slider_query_pos(HWND handle) 5245 unsigned int API dw_slider_query_pos(HWND handle)
5246 { 5246 {
5247 int max = (int)SendMessage(handle, TBM_GETRANGEMAX, 0, 0); 5247 int max = (int)SendMessage(handle, TBM_GETRANGEMAX, 0, 0);
5248 ULONG currentstyle = GetWindowLong(handle, GWL_STYLE); 5248 ULONG currentstyle = GetWindowLong(handle, GWL_STYLE);
5249 5249
5250 if(currentstyle & TBS_VERT) 5250 if(currentstyle & TBS_VERT)
5256 * Sets the slider position. 5256 * Sets the slider position.
5257 * Parameters: 5257 * Parameters:
5258 * handle: Handle to the slider to be set. 5258 * handle: Handle to the slider to be set.
5259 * position: Position of the slider withing the range. 5259 * position: Position of the slider withing the range.
5260 */ 5260 */
5261 void dw_slider_set_pos(HWND handle, unsigned int position) 5261 void API dw_slider_set_pos(HWND handle, unsigned int position)
5262 { 5262 {
5263 int max = (int)SendMessage(handle, TBM_GETRANGEMAX, 0, 0); 5263 int max = (int)SendMessage(handle, TBM_GETRANGEMAX, 0, 0);
5264 ULONG currentstyle = GetWindowLong(handle, GWL_STYLE); 5264 ULONG currentstyle = GetWindowLong(handle, GWL_STYLE);
5265 5265
5266 if(currentstyle & TBS_VERT) 5266 if(currentstyle & TBS_VERT)
5273 * Sets the spinbutton value. 5273 * Sets the spinbutton value.
5274 * Parameters: 5274 * Parameters:
5275 * handle: Handle to the spinbutton to be set. 5275 * handle: Handle to the spinbutton to be set.
5276 * position: Current value of the spinbutton. 5276 * position: Current value of the spinbutton.
5277 */ 5277 */
5278 void dw_spinbutton_set_pos(HWND handle, long position) 5278 void API dw_spinbutton_set_pos(HWND handle, long position)
5279 { 5279 {
5280 char tmpbuf[100]; 5280 char tmpbuf[100];
5281 ColorInfo *cinfo = (ColorInfo *)GetWindowLong(handle, GWL_USERDATA); 5281 ColorInfo *cinfo = (ColorInfo *)GetWindowLong(handle, GWL_USERDATA);
5282 5282
5283 sprintf(tmpbuf, "%d", position); 5283 sprintf(tmpbuf, "%d", position);
5296 * Parameters: 5296 * Parameters:
5297 * handle: Handle to the spinbutton to be set. 5297 * handle: Handle to the spinbutton to be set.
5298 * position: Current value of the spinbutton. 5298 * position: Current value of the spinbutton.
5299 * position: Current value of the spinbutton. 5299 * position: Current value of the spinbutton.
5300 */ 5300 */
5301 void dw_spinbutton_set_limits(HWND handle, long upper, long lower) 5301 void API dw_spinbutton_set_limits(HWND handle, long upper, long lower)
5302 { 5302 {
5303 if(IS_IE5PLUS) 5303 if(IS_IE5PLUS)
5304 SendMessage(handle, UDM_SETRANGE32, (WPARAM)lower,(LPARAM)upper); 5304 SendMessage(handle, UDM_SETRANGE32, (WPARAM)lower,(LPARAM)upper);
5305 else 5305 else
5306 SendMessage(handle, UDM_SETRANGE32, (WPARAM)((short)lower), 5306 SendMessage(handle, UDM_SETRANGE32, (WPARAM)((short)lower),
5311 * Sets the entryfield character limit. 5311 * Sets the entryfield character limit.
5312 * Parameters: 5312 * Parameters:
5313 * handle: Handle to the spinbutton to be set. 5313 * handle: Handle to the spinbutton to be set.
5314 * limit: Number of characters the entryfield will take. 5314 * limit: Number of characters the entryfield will take.
5315 */ 5315 */
5316 void dw_entryfield_set_limit(HWND handle, ULONG limit) 5316 void API dw_entryfield_set_limit(HWND handle, ULONG limit)
5317 { 5317 {
5318 SendMessage(handle, EM_SETLIMITTEXT, (WPARAM)limit, 0); 5318 SendMessage(handle, EM_SETLIMITTEXT, (WPARAM)limit, 0);
5319 } 5319 }
5320 5320
5321 /* 5321 /*
5322 * Returns the current value of the spinbutton. 5322 * Returns the current value of the spinbutton.
5323 * Parameters: 5323 * Parameters:
5324 * handle: Handle to the spinbutton to be queried. 5324 * handle: Handle to the spinbutton to be queried.
5325 */ 5325 */
5326 long dw_spinbutton_query(HWND handle) 5326 long API dw_spinbutton_query(HWND handle)
5327 { 5327 {
5328 if(IS_IE5PLUS) 5328 if(IS_IE5PLUS)
5329 return (long)SendMessage(handle, UDM_GETPOS32, 0, 0); 5329 return (long)SendMessage(handle, UDM_GETPOS32, 0, 0);
5330 else 5330 else
5331 return (long)SendMessage(handle, UDM_GETPOS, 0, 0); 5331 return (long)SendMessage(handle, UDM_GETPOS, 0, 0);
5334 /* 5334 /*
5335 * Returns the state of the checkbox. 5335 * Returns the state of the checkbox.
5336 * Parameters: 5336 * Parameters:
5337 * handle: Handle to the checkbox to be queried. 5337 * handle: Handle to the checkbox to be queried.
5338 */ 5338 */
5339 int dw_checkbox_query(HWND handle) 5339 int API dw_checkbox_query(HWND handle)
5340 { 5340 {
5341 if(SendMessage(handle, BM_GETCHECK, 0, 0) == BST_CHECKED) 5341 if(SendMessage(handle, BM_GETCHECK, 0, 0) == BST_CHECKED)
5342 return (in_checkbox_handler ? FALSE : TRUE); 5342 return (in_checkbox_handler ? FALSE : TRUE);
5343 return (in_checkbox_handler ? TRUE : FALSE); 5343 return (in_checkbox_handler ? TRUE : FALSE);
5344 } 5344 }
5363 * Sets the state of the checkbox. 5363 * Sets the state of the checkbox.
5364 * Parameters: 5364 * Parameters:
5365 * handle: Handle to the checkbox to be queried. 5365 * handle: Handle to the checkbox to be queried.
5366 * value: TRUE for checked, FALSE for unchecked. 5366 * value: TRUE for checked, FALSE for unchecked.
5367 */ 5367 */
5368 void dw_checkbox_set(HWND handle, int value) 5368 void API dw_checkbox_set(HWND handle, int value)
5369 { 5369 {
5370 BubbleButton *bubble= (BubbleButton *)GetWindowLong(handle, GWL_USERDATA); 5370 BubbleButton *bubble= (BubbleButton *)GetWindowLong(handle, GWL_USERDATA);
5371 5371
5372 if(bubble && !bubble->checkbox) 5372 if(bubble && !bubble->checkbox)
5373 { 5373 {
5387 * title: The text title of the entry. 5387 * title: The text title of the entry.
5388 * icon: Handle to coresponding icon. 5388 * icon: Handle to coresponding icon.
5389 * parent: Parent handle or 0 if root. 5389 * parent: Parent handle or 0 if root.
5390 * itemdata: Item specific data. 5390 * itemdata: Item specific data.
5391 */ 5391 */
5392 HWND dw_tree_insert_after(HWND handle, HWND item, char *title, unsigned long icon, HWND parent, void *itemdata) 5392 HWND API dw_tree_insert_after(HWND handle, HWND item, char *title, unsigned long icon, HWND parent, void *itemdata)
5393 { 5393 {
5394 TVITEM tvi; 5394 TVITEM tvi;
5395 TVINSERTSTRUCT tvins; 5395 TVINSERTSTRUCT tvins;
5396 HTREEITEM hti; 5396 HTREEITEM hti;
5397 void **ptrs= malloc(sizeof(void *) * 2); 5397 void **ptrs= malloc(sizeof(void *) * 2);
5421 * title: The text title of the entry. 5421 * title: The text title of the entry.
5422 * icon: Handle to coresponding icon. 5422 * icon: Handle to coresponding icon.
5423 * parent: Parent handle or 0 if root. 5423 * parent: Parent handle or 0 if root.
5424 * itemdata: Item specific data. 5424 * itemdata: Item specific data.
5425 */ 5425 */
5426 HWND dw_tree_insert(HWND handle, char *title, unsigned long icon, HWND parent, void *itemdata) 5426 HWND API dw_tree_insert(HWND handle, char *title, unsigned long icon, HWND parent, void *itemdata)
5427 { 5427 {
5428 TVITEM tvi; 5428 TVITEM tvi;
5429 TVINSERTSTRUCT tvins; 5429 TVINSERTSTRUCT tvins;
5430 HTREEITEM hti; 5430 HTREEITEM hti;
5431 void **ptrs= malloc(sizeof(void *) * 2); 5431 void **ptrs= malloc(sizeof(void *) * 2);
5454 * handle: Handle to the tree containing the item. 5454 * handle: Handle to the tree containing the item.
5455 * item: Handle of the item to be modified. 5455 * item: Handle of the item to be modified.
5456 * title: The text title of the entry. 5456 * title: The text title of the entry.
5457 * icon: Handle to coresponding icon. 5457 * icon: Handle to coresponding icon.
5458 */ 5458 */
5459 void dw_tree_set(HWND handle, HWND item, char *title, unsigned long icon) 5459 void API dw_tree_set(HWND handle, HWND item, char *title, unsigned long icon)
5460 { 5460 {
5461 TVITEM tvi; 5461 TVITEM tvi;
5462 void **ptrs; 5462 void **ptrs;
5463 5463
5464 tvi.mask = TVIF_HANDLE; 5464 tvi.mask = TVIF_HANDLE;
5485 * Parameters: 5485 * Parameters:
5486 * handle: Handle to the tree containing the item. 5486 * handle: Handle to the tree containing the item.
5487 * item: Handle of the item to be modified. 5487 * item: Handle of the item to be modified.
5488 * itemdata: User defined data to be associated with item. 5488 * itemdata: User defined data to be associated with item.
5489 */ 5489 */
5490 void dw_tree_set_data(HWND handle, HWND item, void *itemdata) 5490 void API dw_tree_set_data(HWND handle, HWND item, void *itemdata)
5491 { 5491 {
5492 TVITEM tvi; 5492 TVITEM tvi;
5493 void **ptrs; 5493 void **ptrs;
5494 5494
5495 tvi.mask = TVIF_HANDLE; 5495 tvi.mask = TVIF_HANDLE;
5506 * Sets this item as the active selection. 5506 * Sets this item as the active selection.
5507 * Parameters: 5507 * Parameters:
5508 * handle: Handle to the tree window (widget) to be selected. 5508 * handle: Handle to the tree window (widget) to be selected.
5509 * item: Handle to the item to be selected. 5509 * item: Handle to the item to be selected.
5510 */ 5510 */
5511 void dw_tree_item_select(HWND handle, HWND item) 5511 void API dw_tree_item_select(HWND handle, HWND item)
5512 { 5512 {
5513 TreeView_SelectItem(handle, (HTREEITEM)item); 5513 TreeView_SelectItem(handle, (HTREEITEM)item);
5514 } 5514 }
5515 5515
5516 /* 5516 /*
5517 * Removes all nodes from a tree. 5517 * Removes all nodes from a tree.
5518 * Parameters: 5518 * Parameters:
5519 * handle: Handle to the window (widget) to be cleared. 5519 * handle: Handle to the window (widget) to be cleared.
5520 */ 5520 */
5521 void dw_tree_clear(HWND handle) 5521 void API dw_tree_clear(HWND handle)
5522 { 5522 {
5523 TreeView_DeleteAllItems(handle); 5523 TreeView_DeleteAllItems(handle);
5524 } 5524 }
5525 5525
5526 /* 5526 /*
5527 * Expands a node on a tree. 5527 * Expands a node on a tree.
5528 * Parameters: 5528 * Parameters:
5529 * handle: Handle to the tree window (widget). 5529 * handle: Handle to the tree window (widget).
5530 * item: Handle to node to be expanded. 5530 * item: Handle to node to be expanded.
5531 */ 5531 */
5532 void dw_tree_expand(HWND handle, HWND item) 5532 void API dw_tree_expand(HWND handle, HWND item)
5533 { 5533 {
5534 TreeView_Expand(handle, (HTREEITEM)item, TVE_EXPAND); 5534 TreeView_Expand(handle, (HTREEITEM)item, TVE_EXPAND);
5535 } 5535 }
5536 5536
5537 /* 5537 /*
5538 * Collapses a node on a tree. 5538 * Collapses a node on a tree.
5539 * Parameters: 5539 * Parameters:
5540 * handle: Handle to the tree window (widget). 5540 * handle: Handle to the tree window (widget).
5541 * item: Handle to node to be collapsed. 5541 * item: Handle to node to be collapsed.
5542 */ 5542 */
5543 void dw_tree_collapse(HWND handle, HWND item) 5543 void API dw_tree_collapse(HWND handle, HWND item)
5544 { 5544 {
5545 TreeView_Expand(handle, (HTREEITEM)item, TVE_COLLAPSE); 5545 TreeView_Expand(handle, (HTREEITEM)item, TVE_COLLAPSE);
5546 } 5546 }
5547 5547
5548 /* 5548 /*
5549 * Removes a node from a tree. 5549 * Removes a node from a tree.
5550 * Parameters: 5550 * Parameters:
5551 * handle: Handle to the window (widget) to be cleared. 5551 * handle: Handle to the window (widget) to be cleared.
5552 * item: Handle to node to be deleted. 5552 * item: Handle to node to be deleted.
5553 */ 5553 */
5554 void dw_tree_delete(HWND handle, HWND item) 5554 void API dw_tree_delete(HWND handle, HWND item)
5555 { 5555 {
5556 if((HTREEITEM)item == TVI_ROOT || !item) 5556 if((HTREEITEM)item == TVI_ROOT || !item)
5557 return; 5557 return;
5558 5558
5559 TreeView_DeleteItem(handle, (HTREEITEM)item); 5559 TreeView_DeleteItem(handle, (HTREEITEM)item);
5567 * titles: An array of strings with column text titles. 5567 * titles: An array of strings with column text titles.
5568 * count: The number of columns (this should match the arrays). 5568 * count: The number of columns (this should match the arrays).
5569 * separator: The column number that contains the main separator. 5569 * separator: The column number that contains the main separator.
5570 * (only used on OS/2 but must be >= 0 on all) 5570 * (only used on OS/2 but must be >= 0 on all)
5571 */ 5571 */
5572 int dw_container_setup(HWND handle, unsigned long *flags, char **titles, int count, int separator) 5572 int API dw_container_setup(HWND handle, unsigned long *flags, char **titles, int count, int separator)
5573 { 5573 {
5574 ContainerInfo *cinfo = (ContainerInfo *)GetWindowLong(handle, GWL_USERDATA); 5574 ContainerInfo *cinfo = (ContainerInfo *)GetWindowLong(handle, GWL_USERDATA);
5575 int z, l = 0; 5575 int z, l = 0;
5576 unsigned long *tempflags = calloc(sizeof(unsigned long), count + 2); 5576 unsigned long *tempflags = calloc(sizeof(unsigned long), count + 2);
5577 LV_COLUMN lvc; 5577 LV_COLUMN lvc;
5611 * handle: Handle to the container to be configured. 5611 * handle: Handle to the container to be configured.
5612 * flags: An array of unsigned longs with column flags. 5612 * flags: An array of unsigned longs with column flags.
5613 * titles: An array of strings with column text titles. 5613 * titles: An array of strings with column text titles.
5614 * count: The number of columns (this should match the arrays). 5614 * count: The number of columns (this should match the arrays).
5615 */ 5615 */
5616 int dw_filesystem_setup(HWND handle, unsigned long *flags, char **titles, int count) 5616 int API dw_filesystem_setup(HWND handle, unsigned long *flags, char **titles, int count)
5617 { 5617 {
5618 LV_COLUMN lvc; 5618 LV_COLUMN lvc;
5619 5619
5620 lvc.mask = LVCF_TEXT | LVCF_WIDTH | LVCF_SUBITEM; 5620 lvc.mask = LVCF_TEXT | LVCF_WIDTH | LVCF_SUBITEM;
5621 lvc.pszText = "Filename"; 5621 lvc.pszText = "Filename";
5637 * module: Handle to module (DLL) in OS/2 and Windows. 5637 * module: Handle to module (DLL) in OS/2 and Windows.
5638 * id: A unsigned long id int the resources on OS/2 and 5638 * id: A unsigned long id int the resources on OS/2 and
5639 * Windows, on GTK this is converted to a pointer 5639 * Windows, on GTK this is converted to a pointer
5640 * to an embedded XPM. 5640 * to an embedded XPM.
5641 */ 5641 */
5642 unsigned long dw_icon_load(unsigned long module, unsigned long id) 5642 unsigned long API dw_icon_load(unsigned long module, unsigned long id)
5643 { 5643 {
5644 return (unsigned long)LoadIcon(DWInstance, MAKEINTRESOURCE(id)); 5644 return (unsigned long)LoadIcon(DWInstance, MAKEINTRESOURCE(id));
5645 } 5645 }
5646 5646
5647 /* 5647 /*
5648 * Frees a loaded resource in OS/2 and Windows. 5648 * Frees a loaded resource in OS/2 and Windows.
5649 * Parameters: 5649 * Parameters:
5650 * handle: Handle to icon returned by dw_icon_load(). 5650 * handle: Handle to icon returned by dw_icon_load().
5651 */ 5651 */
5652 void dw_icon_free(unsigned long handle) 5652 void API dw_icon_free(unsigned long handle)
5653 { 5653 {
5654 DestroyIcon((HICON)handle); 5654 DestroyIcon((HICON)handle);
5655 } 5655 }
5656 5656
5657 /* 5657 /*
5658 * Allocates memory used to populate a container. 5658 * Allocates memory used to populate a container.
5659 * Parameters: 5659 * Parameters:
5660 * handle: Handle to the container window (widget). 5660 * handle: Handle to the container window (widget).
5661 * rowcount: The number of items to be populated. 5661 * rowcount: The number of items to be populated.
5662 */ 5662 */
5663 void *dw_container_alloc(HWND handle, int rowcount) 5663 void * API dw_container_alloc(HWND handle, int rowcount)
5664 { 5664 {
5665 LV_ITEM lvi; 5665 LV_ITEM lvi;
5666 int z; 5666 int z;
5667 5667
5668 lvi.mask = LVIF_DI_SETITEM | LVIF_TEXT | LVIF_IMAGE; 5668 lvi.mask = LVIF_DI_SETITEM | LVIF_TEXT | LVIF_IMAGE;
5740 * pointer: Pointer to the allocated memory in dw_container_alloc(). 5740 * pointer: Pointer to the allocated memory in dw_container_alloc().
5741 * column: Zero based column of data being set. 5741 * column: Zero based column of data being set.
5742 * row: Zero based row of data being set. 5742 * row: Zero based row of data being set.
5743 * data: Pointer to the data to be added. 5743 * data: Pointer to the data to be added.
5744 */ 5744 */
5745 void dw_filesystem_set_file(HWND handle, void *pointer, int row, char *filename, unsigned long icon) 5745 void API dw_filesystem_set_file(HWND handle, void *pointer, int row, char *filename, unsigned long icon)
5746 { 5746 {
5747 LV_ITEM lvi; 5747 LV_ITEM lvi;
5748 5748
5749 lvi.iItem = row; 5749 lvi.iItem = row;
5750 lvi.iSubItem = 0; 5750 lvi.iSubItem = 0;
5763 * pointer: Pointer to the allocated memory in dw_container_alloc(). 5763 * pointer: Pointer to the allocated memory in dw_container_alloc().
5764 * column: Zero based column of data being set. 5764 * column: Zero based column of data being set.
5765 * row: Zero based row of data being set. 5765 * row: Zero based row of data being set.
5766 * data: Pointer to the data to be added. 5766 * data: Pointer to the data to be added.
5767 */ 5767 */
5768 void dw_filesystem_set_item(HWND handle, void *pointer, int column, int row, void *data) 5768 void API dw_filesystem_set_item(HWND handle, void *pointer, int column, int row, void *data)
5769 { 5769 {
5770 dw_container_set_item(handle, pointer, column + 1, row, data); 5770 dw_container_set_item(handle, pointer, column + 1, row, data);
5771 } 5771 }
5772 5772
5773 /* 5773 /*
5777 * pointer: Pointer to the allocated memory in dw_container_alloc(). 5777 * pointer: Pointer to the allocated memory in dw_container_alloc().
5778 * column: Zero based column of data being set. 5778 * column: Zero based column of data being set.
5779 * row: Zero based row of data being set. 5779 * row: Zero based row of data being set.
5780 * data: Pointer to the data to be added. 5780 * data: Pointer to the data to be added.
5781 */ 5781 */
5782 void dw_container_set_item(HWND handle, void *pointer, int column, int row, void *data) 5782 void API dw_container_set_item(HWND handle, void *pointer, int column, int row, void *data)
5783 { 5783 {
5784 ContainerInfo *cinfo = (ContainerInfo *)GetWindowLong(handle, GWL_USERDATA); 5784 ContainerInfo *cinfo = (ContainerInfo *)GetWindowLong(handle, GWL_USERDATA);
5785 ULONG *flags; 5785 ULONG *flags;
5786 LV_ITEM lvi; 5786 LV_ITEM lvi;
5787 char textbuffer[100], *destptr = textbuffer; 5787 char textbuffer[100], *destptr = textbuffer;
5863 * handle: Handle to the container window (widget). 5863 * handle: Handle to the container window (widget).
5864 * column: Zero based column of data being set. 5864 * column: Zero based column of data being set.
5865 * row: Zero based row of data being set. 5865 * row: Zero based row of data being set.
5866 * data: Pointer to the data to be added. 5866 * data: Pointer to the data to be added.
5867 */ 5867 */
5868 void dw_container_change_item(HWND handle, int column, int row, void *data) 5868 void API dw_container_change_item(HWND handle, int column, int row, void *data)
5869 { 5869 {
5870 dw_container_set_item(handle, NULL, column, row, data); 5870 dw_container_set_item(handle, NULL, column, row, data);
5871 } 5871 }
5872 5872
5873 /* 5873 /*
5875 * Parameters: 5875 * Parameters:
5876 * handle: Handle to window (widget) of container. 5876 * handle: Handle to window (widget) of container.
5877 * column: Zero based column of width being set. 5877 * column: Zero based column of width being set.
5878 * width: Width of column in pixels. 5878 * width: Width of column in pixels.
5879 */ 5879 */
5880 void dw_container_set_column_width(HWND handle, int column, int width) 5880 void API dw_container_set_column_width(HWND handle, int column, int width)
5881 { 5881 {
5882 ListView_SetColumnWidth(handle, column, width); 5882 ListView_SetColumnWidth(handle, column, width);
5883 } 5883 }
5884 5884
5885 /* 5885 /*
5887 * Parameters: 5887 * Parameters:
5888 * pointer: Pointer to the allocated memory in dw_container_alloc(). 5888 * pointer: Pointer to the allocated memory in dw_container_alloc().
5889 * row: Zero based row of data being set. 5889 * row: Zero based row of data being set.
5890 * title: String title of the item. 5890 * title: String title of the item.
5891 */ 5891 */
5892 void dw_container_set_row_title(void *pointer, int row, char *title) 5892 void API dw_container_set_row_title(void *pointer, int row, char *title)
5893 { 5893 {
5894 LV_ITEM lvi; 5894 LV_ITEM lvi;
5895 HWND container = (HWND)pointer; 5895 HWND container = (HWND)pointer;
5896 5896
5897 lvi.iItem = row; 5897 lvi.iItem = row;
5909 * Parameters: 5909 * Parameters:
5910 * handle: Handle to the container window (widget). 5910 * handle: Handle to the container window (widget).
5911 * pointer: Pointer to the allocated memory in dw_container_alloc(). 5911 * pointer: Pointer to the allocated memory in dw_container_alloc().
5912 * rowcount: The number of rows to be inserted. 5912 * rowcount: The number of rows to be inserted.
5913 */ 5913 */
5914 void dw_container_insert(HWND handle, void *pointer, int rowcount) 5914 void API dw_container_insert(HWND handle, void *pointer, int rowcount)
5915 { 5915 {
5916 ShowWindow(handle, SW_SHOW); 5916 ShowWindow(handle, SW_SHOW);
5917 } 5917 }
5918 5918
5919 /* 5919 /*
5920 * Removes all rows from a container. 5920 * Removes all rows from a container.
5921 * Parameters: 5921 * Parameters:
5922 * handle: Handle to the window (widget) to be cleared. 5922 * handle: Handle to the window (widget) to be cleared.
5923 * redraw: TRUE to cause the container to redraw immediately. 5923 * redraw: TRUE to cause the container to redraw immediately.
5924 */ 5924 */
5925 void dw_container_clear(HWND handle, int redraw) 5925 void API dw_container_clear(HWND handle, int redraw)
5926 { 5926 {
5927 ListView_DeleteAllItems(handle); 5927 ListView_DeleteAllItems(handle);
5928 } 5928 }
5929 5929
5930 /* 5930 /*
5931 * Removes the first x rows from a container. 5931 * Removes the first x rows from a container.
5932 * Parameters: 5932 * Parameters:
5933 * handle: Handle to the window (widget) to be deleted from. 5933 * handle: Handle to the window (widget) to be deleted from.
5934 * rowcount: The number of rows to be deleted. 5934 * rowcount: The number of rows to be deleted.
5935 */ 5935 */
5936 void dw_container_delete(HWND handle, int rowcount) 5936 void API dw_container_delete(HWND handle, int rowcount)
5937 { 5937 {
5938 int z; 5938 int z;
5939 5939
5940 for(z=0;z<rowcount;z++) 5940 for(z=0;z<rowcount;z++)
5941 { 5941 {
5949 * handle: Handle to the window (widget) to be scrolled. 5949 * handle: Handle to the window (widget) to be scrolled.
5950 * direction: DW_SCROLL_UP, DW_SCROLL_DOWN, DW_SCROLL_TOP or 5950 * direction: DW_SCROLL_UP, DW_SCROLL_DOWN, DW_SCROLL_TOP or
5951 * DW_SCROLL_BOTTOM. (rows is ignored for last two) 5951 * DW_SCROLL_BOTTOM. (rows is ignored for last two)
5952 * rows: The number of rows to be scrolled. 5952 * rows: The number of rows to be scrolled.
5953 */ 5953 */
5954 void dw_container_scroll(HWND handle, int direction, long rows) 5954 void API dw_container_scroll(HWND handle, int direction, long rows)
5955 { 5955 {
5956 switch(direction) 5956 switch(direction)
5957 { 5957 {
5958 case DW_SCROLL_TOP: 5958 case DW_SCROLL_TOP:
5959 ListView_Scroll(handle, 0, -10000000); 5959 ListView_Scroll(handle, 0, -10000000);
5967 /* 5967 /*
5968 * Removes all rows from a container. 5968 * Removes all rows from a container.
5969 * Parameters: 5969 * Parameters:
5970 * handle: Handle to the window (widget) to be cleared. 5970 * handle: Handle to the window (widget) to be cleared.
5971 */ 5971 */
5972 void dw_container_set_view(HWND handle, unsigned long flags, int iconwidth, int iconheight) 5972 void API dw_container_set_view(HWND handle, unsigned long flags, int iconwidth, int iconheight)
5973 { 5973 {
5974 } 5974 }
5975 5975
5976 /* 5976 /*
5977 * Starts a new query of a container. 5977 * Starts a new query of a container.
5979 * handle: Handle to the window (widget) to be queried. 5979 * handle: Handle to the window (widget) to be queried.
5980 * flags: If this parameter is DW_CRA_SELECTED it will only 5980 * flags: If this parameter is DW_CRA_SELECTED it will only
5981 * return items that are currently selected. Otherwise 5981 * return items that are currently selected. Otherwise
5982 * it will return all records in the container. 5982 * it will return all records in the container.
5983 */ 5983 */
5984 char *dw_container_query_start(HWND handle, unsigned long flags) 5984 char * API dw_container_query_start(HWND handle, unsigned long flags)
5985 { 5985 {
5986 LV_ITEM lvi; 5986 LV_ITEM lvi;
5987 5987
5988 _index = ListView_GetNextItem(handle, -1, flags); 5988 _index = ListView_GetNextItem(handle, -1, flags);
5989 5989
6006 * handle: Handle to the window (widget) to be queried. 6006 * handle: Handle to the window (widget) to be queried.
6007 * flags: If this parameter is DW_CRA_SELECTED it will only 6007 * flags: If this parameter is DW_CRA_SELECTED it will only
6008 * return items that are currently selected. Otherwise 6008 * return items that are currently selected. Otherwise
6009 * it will return all records in the container. 6009 * it will return all records in the container.
6010 */ 6010 */
6011 char *dw_container_query_next(HWND handle, unsigned long flags) 6011 char * API dw_container_query_next(HWND handle, unsigned long flags)
6012 { 6012 {
6013 LV_ITEM lvi; 6013 LV_ITEM lvi;
6014 6014
6015 _index = ListView_GetNextItem(handle, _index, flags); 6015 _index = ListView_GetNextItem(handle, _index, flags);
6016 6016
6031 * Cursors the item with the text speficied, and scrolls to that item. 6031 * Cursors the item with the text speficied, and scrolls to that item.
6032 * Parameters: 6032 * Parameters:
6033 * handle: Handle to the window (widget) to be queried. 6033 * handle: Handle to the window (widget) to be queried.
6034 * text: Text usually returned by dw_container_query(). 6034 * text: Text usually returned by dw_container_query().
6035 */ 6035 */
6036 void dw_container_cursor(HWND handle, char *text) 6036 void API dw_container_cursor(HWND handle, char *text)
6037 { 6037 {
6038 int index = ListView_GetNextItem(handle, -1, LVNI_ALL); 6038 int index = ListView_GetNextItem(handle, -1, LVNI_ALL);
6039 6039
6040 while(index != -1) 6040 while(index != -1)
6041 { 6041 {
6065 * Deletes the item with the text speficied. 6065 * Deletes the item with the text speficied.
6066 * Parameters: 6066 * Parameters:
6067 * handle: Handle to the window (widget). 6067 * handle: Handle to the window (widget).
6068 * text: Text usually returned by dw_container_query(). 6068 * text: Text usually returned by dw_container_query().
6069 */ 6069 */
6070 void dw_container_delete_row(HWND handle, char *text) 6070 void API dw_container_delete_row(HWND handle, char *text)
6071 { 6071 {
6072 int index = ListView_GetNextItem(handle, -1, LVNI_ALL); 6072 int index = ListView_GetNextItem(handle, -1, LVNI_ALL);
6073 6073
6074 while(index != -1) 6074 while(index != -1)
6075 { 6075 {
6095 /* 6095 /*
6096 * Optimizes the column widths so that all data is visible. 6096 * Optimizes the column widths so that all data is visible.
6097 * Parameters: 6097 * Parameters:
6098 * handle: Handle to the window (widget) to be optimized. 6098 * handle: Handle to the window (widget) to be optimized.
6099 */ 6099 */
6100 void dw_container_optimize(HWND handle) 6100 void API dw_container_optimize(HWND handle)
6101 { 6101 {
6102 ContainerInfo *cinfo = (ContainerInfo *)GetWindowLong(handle, GWL_USERDATA); 6102 ContainerInfo *cinfo = (ContainerInfo *)GetWindowLong(handle, GWL_USERDATA);
6103 ULONG *flags; 6103 ULONG *flags;
6104 LV_ITEM lvi; 6104 LV_ITEM lvi;
6105 6105
6181 * Parameters: 6181 * Parameters:
6182 * id: An id to be used with dw_window_from_id. 6182 * id: An id to be used with dw_window_from_id.
6183 * Returns: 6183 * Returns:
6184 * A handle to the widget or NULL on failure. 6184 * A handle to the widget or NULL on failure.
6185 */ 6185 */
6186 HWND dw_render_new(unsigned long id) 6186 HWND API dw_render_new(unsigned long id)
6187 { 6187 {
6188 Box *newbox = calloc(sizeof(Box), 1); 6188 Box *newbox = calloc(sizeof(Box), 1);
6189 HWND tmp = CreateWindow(ObjectClassName, 6189 HWND tmp = CreateWindow(ObjectClassName,
6190 "", 6190 "",
6191 WS_VISIBLE | WS_CHILD | WS_CLIPCHILDREN, 6191 WS_VISIBLE | WS_CHILD | WS_CLIPCHILDREN,
6209 * Parameters: 6209 * Parameters:
6210 * red: red value. 6210 * red: red value.
6211 * green: green value. 6211 * green: green value.
6212 * blue: blue value. 6212 * blue: blue value.
6213 */ 6213 */
6214 void dw_color_foreground_set(unsigned long value) 6214 void API dw_color_foreground_set(unsigned long value)
6215 { 6215 {
6216 int threadid = dw_thread_id(); 6216 int threadid = dw_thread_id();
6217 6217
6218 if(threadid < 0 || threadid >= THREAD_LIMIT) 6218 if(threadid < 0 || threadid >= THREAD_LIMIT)
6219 threadid = 0; 6219 threadid = 0;
6229 * Parameters: 6229 * Parameters:
6230 * red: red value. 6230 * red: red value.
6231 * green: green value. 6231 * green: green value.
6232 * blue: blue value. 6232 * blue: blue value.
6233 */ 6233 */
6234 void dw_color_background_set(unsigned long value) 6234 void API dw_color_background_set(unsigned long value)
6235 { 6235 {
6236 int threadid = dw_thread_id(); 6236 int threadid = dw_thread_id();
6237 6237
6238 if(threadid < 0 || threadid >= THREAD_LIMIT) 6238 if(threadid < 0 || threadid >= THREAD_LIMIT)
6239 threadid = 0; 6239 threadid = 0;
6246 * handle: Handle to the window. 6246 * handle: Handle to the window.
6247 * pixmap: Handle to the pixmap. (choose only one of these) 6247 * pixmap: Handle to the pixmap. (choose only one of these)
6248 * x: X coordinate. 6248 * x: X coordinate.
6249 * y: Y coordinate. 6249 * y: Y coordinate.
6250 */ 6250 */
6251 void dw_draw_point(HWND handle, HPIXMAP pixmap, int x, int y) 6251 void API dw_draw_point(HWND handle, HPIXMAP pixmap, int x, int y)
6252 { 6252 {
6253 HDC hdcPaint; 6253 HDC hdcPaint;
6254 int threadid = dw_thread_id(); 6254 int threadid = dw_thread_id();
6255 6255
6256 if(threadid < 0 || threadid >= THREAD_LIMIT) 6256 if(threadid < 0 || threadid >= THREAD_LIMIT)
6275 * x1: First X coordinate. 6275 * x1: First X coordinate.
6276 * y1: First Y coordinate. 6276 * y1: First Y coordinate.
6277 * x2: Second X coordinate. 6277 * x2: Second X coordinate.
6278 * y2: Second Y coordinate. 6278 * y2: Second Y coordinate.
6279 */ 6279 */
6280 void dw_draw_line(HWND handle, HPIXMAP pixmap, int x1, int y1, int x2, int y2) 6280 void API dw_draw_line(HWND handle, HPIXMAP pixmap, int x1, int y1, int x2, int y2)
6281 { 6281 {
6282 HDC hdcPaint; 6282 HDC hdcPaint;
6283 HPEN oldPen; 6283 HPEN oldPen;
6284 int threadid = dw_thread_id(); 6284 int threadid = dw_thread_id();
6285 6285
6312 * x: X coordinate. 6312 * x: X coordinate.
6313 * y: Y coordinate. 6313 * y: Y coordinate.
6314 * width: Width of rectangle. 6314 * width: Width of rectangle.
6315 * height: Height of rectangle. 6315 * height: Height of rectangle.
6316 */ 6316 */
6317 void dw_draw_rect(HWND handle, HPIXMAP pixmap, int fill, int x, int y, int width, int height) 6317 void API dw_draw_rect(HWND handle, HPIXMAP pixmap, int fill, int x, int y, int width, int height)
6318 { 6318 {
6319 HDC hdcPaint; 6319 HDC hdcPaint;
6320 HPEN oldPen; 6320 HPEN oldPen;
6321 HBRUSH oldBrush; 6321 HBRUSH oldBrush;
6322 int threadid = dw_thread_id(); 6322 int threadid = dw_thread_id();
6346 * pixmap: Handle to the pixmap. (choose only one of these) 6346 * pixmap: Handle to the pixmap. (choose only one of these)
6347 * x: X coordinate. 6347 * x: X coordinate.
6348 * y: Y coordinate. 6348 * y: Y coordinate.
6349 * text: Text to be displayed. 6349 * text: Text to be displayed.
6350 */ 6350 */
6351 void dw_draw_text(HWND handle, HPIXMAP pixmap, int x, int y, char *text) 6351 void API dw_draw_text(HWND handle, HPIXMAP pixmap, int x, int y, char *text)
6352 { 6352 {
6353 HDC hdc; 6353 HDC hdc;
6354 int size = 9, z, mustdelete = 0; 6354 int size = 9, z, mustdelete = 0;
6355 HFONT hFont, oldFont; 6355 HFONT hFont, oldFont;
6356 int threadid = dw_thread_id(); 6356 int threadid = dw_thread_id();
6396 * pixmap: Handle to the pixmap. (choose only one of these) 6396 * pixmap: Handle to the pixmap. (choose only one of these)
6397 * text: Text to be queried. 6397 * text: Text to be queried.
6398 * width: Pointer to a variable to be filled in with the width. 6398 * width: Pointer to a variable to be filled in with the width.
6399 * height Pointer to a variable to be filled in with the height. 6399 * height Pointer to a variable to be filled in with the height.
6400 */ 6400 */
6401 void dw_font_text_extents(HWND handle, HPIXMAP pixmap, char *text, int *width, int *height) 6401 void API dw_font_text_extents(HWND handle, HPIXMAP pixmap, char *text, int *width, int *height)
6402 { 6402 {
6403 HDC hdc; 6403 HDC hdc;
6404 int mustdelete = 0; 6404 int mustdelete = 0;
6405 HFONT hFont = NULL, oldFont; 6405 HFONT hFont = NULL, oldFont;
6406 SIZE sz; 6406 SIZE sz;
6444 } 6444 }
6445 6445
6446 /* Call this after drawing to the screen to make sure 6446 /* Call this after drawing to the screen to make sure
6447 * anything you have drawn is visible. 6447 * anything you have drawn is visible.
6448 */ 6448 */
6449 void dw_flush(void) 6449 void API dw_flush(void)
6450 { 6450 {
6451 } 6451 }
6452 6452
6453 /* 6453 /*
6454 * Creates a pixmap with given parameters. 6454 * Creates a pixmap with given parameters.
6458 * height: Height of the pixmap in pixels. 6458 * height: Height of the pixmap in pixels.
6459 * depth: Color depth of the pixmap. 6459 * depth: Color depth of the pixmap.
6460 * Returns: 6460 * Returns:
6461 * A handle to a pixmap or NULL on failure. 6461 * A handle to a pixmap or NULL on failure.
6462 */ 6462 */
6463 HPIXMAP dw_pixmap_new(HWND handle, unsigned long width, unsigned long height, int depth) 6463 HPIXMAP API dw_pixmap_new(HWND handle, unsigned long width, unsigned long height, int depth)
6464 { 6464 {
6465 HPIXMAP pixmap; 6465 HPIXMAP pixmap;
6466 BITMAP bm; 6466 BITMAP bm;
6467 HDC hdc; 6467 HDC hdc;
6468 6468
6490 * handle: Window handle the pixmap is associated with. 6490 * handle: Window handle the pixmap is associated with.
6491 * id: Resource ID associated with requested pixmap. 6491 * id: Resource ID associated with requested pixmap.
6492 * Returns: 6492 * Returns:
6493 * A handle to a pixmap or NULL on failure. 6493 * A handle to a pixmap or NULL on failure.
6494 */ 6494 */
6495 HPIXMAP dw_pixmap_grab(HWND handle, ULONG id) 6495 HPIXMAP API dw_pixmap_grab(HWND handle, ULONG id)
6496 { 6496 {
6497 HPIXMAP pixmap; 6497 HPIXMAP pixmap;
6498 BITMAP bm; 6498 BITMAP bm;
6499 HDC hdc; 6499 HDC hdc;
6500 6500
6522 * Destroys an allocated pixmap. 6522 * Destroys an allocated pixmap.
6523 * Parameters: 6523 * Parameters:
6524 * pixmap: Handle to a pixmap returned by 6524 * pixmap: Handle to a pixmap returned by
6525 * dw_pixmap_new.. 6525 * dw_pixmap_new..
6526 */ 6526 */
6527 void dw_pixmap_destroy(HPIXMAP pixmap) 6527 void API dw_pixmap_destroy(HPIXMAP pixmap)
6528 { 6528 {
6529 if(pixmap) 6529 if(pixmap)
6530 { 6530 {
6531 DeleteDC(pixmap->hdc); 6531 DeleteDC(pixmap->hdc);
6532 DeleteObject(pixmap->hbm); 6532 DeleteObject(pixmap->hbm);
6546 * src: Source window handle. 6546 * src: Source window handle.
6547 * srcp: Source pixmap. (choose only one). 6547 * srcp: Source pixmap. (choose only one).
6548 * xsrc: X coordinate of source. 6548 * xsrc: X coordinate of source.
6549 * ysrc: Y coordinate of source. 6549 * ysrc: Y coordinate of source.
6550 */ 6550 */
6551 void dw_pixmap_bitblt(HWND dest, HPIXMAP destp, int xdest, int ydest, int width, int height, HWND src, HPIXMAP srcp, int xsrc, int ysrc) 6551 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)
6552 { 6552 {
6553 HDC hdcdest; 6553 HDC hdcdest;
6554 HDC hdcsrc; 6554 HDC hdcsrc;
6555 6555
6556 if(dest) 6556 if(dest)
6579 * Emits a beep. 6579 * Emits a beep.
6580 * Parameters: 6580 * Parameters:
6581 * freq: Frequency. 6581 * freq: Frequency.
6582 * dur: Duration. 6582 * dur: Duration.
6583 */ 6583 */
6584 void dw_beep(int freq, int dur) 6584 void API dw_beep(int freq, int dur)
6585 { 6585 {
6586 Beep(freq, dur); 6586 Beep(freq, dur);
6587 } 6587 }
6588 6588
6589 /* Open a shared library and return a handle. 6589 /* Open a shared library and return a handle.
6590 * Parameters: 6590 * Parameters:
6591 * name: Base name of the shared library. 6591 * name: Base name of the shared library.
6592 * handle: Pointer to a module handle, 6592 * handle: Pointer to a module handle,
6593 * will be filled in with the handle. 6593 * will be filled in with the handle.
6594 */ 6594 */
6595 int dw_module_load(char *name, HMOD *handle) 6595 int API dw_module_load(char *name, HMOD *handle)
6596 { 6596 {
6597 if(!handle) 6597 if(!handle)
6598 return -1; 6598 return -1;
6599 6599
6600 *handle = LoadLibrary(name); 6600 *handle = LoadLibrary(name);
6606 * handle: Module handle returned by dw_module_load() 6606 * handle: Module handle returned by dw_module_load()
6607 * name: Name of the symbol you want the address of. 6607 * name: Name of the symbol you want the address of.
6608 * func: A pointer to a function pointer, to obtain 6608 * func: A pointer to a function pointer, to obtain
6609 * the address. 6609 * the address.
6610 */ 6610 */
6611 int dw_module_symbol(HMOD handle, char *name, void**func) 6611 int API dw_module_symbol(HMOD handle, char *name, void**func)
6612 { 6612 {
6613 if(!func || !name) 6613 if(!func || !name)
6614 return -1; 6614 return -1;
6615 6615
6616 if(0 == strlen(name)) 6616 if(0 == strlen(name))
6622 6622
6623 /* Frees the shared library previously opened. 6623 /* Frees the shared library previously opened.
6624 * Parameters: 6624 * Parameters:
6625 * handle: Module handle returned by dw_module_load() 6625 * handle: Module handle returned by dw_module_load()
6626 */ 6626 */
6627 int dw_module_close(HMOD handle) 6627 int API dw_module_close(HMOD handle)
6628 { 6628 {
6629 return FreeLibrary(handle); 6629 return FreeLibrary(handle);
6630 } 6630 }
6631 6631
6632 /* 6632 /*
6633 * Returns the handle to an unnamed mutex semaphore. 6633 * Returns the handle to an unnamed mutex semaphore.
6634 */ 6634 */
6635 HMTX dw_mutex_new(void) 6635 HMTX API dw_mutex_new(void)
6636 { 6636 {
6637 return (HMTX)CreateMutex(NULL, FALSE, NULL); 6637 return (HMTX)CreateMutex(NULL, FALSE, NULL);
6638 } 6638 }
6639 6639
6640 /* 6640 /*
6641 * Closes a semaphore created by dw_mutex_new(). 6641 * Closes a semaphore created by dw_mutex_new().
6642 * Parameters: 6642 * Parameters:
6643 * mutex: The handle to the mutex returned by dw_mutex_new(). 6643 * mutex: The handle to the mutex returned by dw_mutex_new().
6644 */ 6644 */
6645 void dw_mutex_close(HMTX mutex) 6645 void API dw_mutex_close(HMTX mutex)
6646 { 6646 {
6647 CloseHandle((HANDLE)mutex); 6647 CloseHandle((HANDLE)mutex);
6648 } 6648 }
6649 6649
6650 /* 6650 /*
6651 * Tries to gain access to the semaphore, if it can't it blocks. 6651 * Tries to gain access to the semaphore, if it can't it blocks.
6652 * Parameters: 6652 * Parameters:
6653 * mutex: The handle to the mutex returned by dw_mutex_new(). 6653 * mutex: The handle to the mutex returned by dw_mutex_new().
6654 */ 6654 */
6655 void dw_mutex_lock(HMTX mutex) 6655 void API dw_mutex_lock(HMTX mutex)
6656 { 6656 {
6657 if(_dwtid == dw_thread_id()) 6657 if(_dwtid == dw_thread_id())
6658 { 6658 {
6659 int rc = WaitForSingleObject((HANDLE)mutex, 0); 6659 int rc = WaitForSingleObject((HANDLE)mutex, 0);
6660 6660
6671 /* 6671 /*
6672 * Reliquishes the access to the semaphore. 6672 * Reliquishes the access to the semaphore.
6673 * Parameters: 6673 * Parameters:
6674 * mutex: The handle to the mutex returned by dw_mutex_new(). 6674 * mutex: The handle to the mutex returned by dw_mutex_new().
6675 */ 6675 */
6676 void dw_mutex_unlock(HMTX mutex) 6676 void API dw_mutex_unlock(HMTX mutex)
6677 { 6677 {
6678 ReleaseMutex((HANDLE)mutex); 6678 ReleaseMutex((HANDLE)mutex);
6679 } 6679 }
6680 6680
6681 /* 6681 /*
6682 * Returns the handle to an unnamed event semaphore. 6682 * Returns the handle to an unnamed event semaphore.
6683 */ 6683 */
6684 HEV dw_event_new(void) 6684 HEV API dw_event_new(void)
6685 { 6685 {
6686 return CreateEvent(NULL, TRUE, FALSE, NULL); 6686 return CreateEvent(NULL, TRUE, FALSE, NULL);
6687 } 6687 }
6688 6688
6689 /* 6689 /*
6690 * Resets a semaphore created by dw_event_new(). 6690 * Resets a semaphore created by dw_event_new().
6691 * Parameters: 6691 * Parameters:
6692 * eve: The handle to the event returned by dw_event_new(). 6692 * eve: The handle to the event returned by dw_event_new().
6693 */ 6693 */
6694 int dw_event_reset(HEV eve) 6694 int API dw_event_reset(HEV eve)
6695 { 6695 {
6696 return ResetEvent(eve); 6696 return ResetEvent(eve);
6697 } 6697 }
6698 6698
6699 /* 6699 /*
6700 * Posts a semaphore created by dw_event_new(). Causing all threads 6700 * Posts a semaphore created by dw_event_new(). Causing all threads
6701 * waiting on this event in dw_event_wait to continue. 6701 * waiting on this event in dw_event_wait to continue.
6702 * Parameters: 6702 * Parameters:
6703 * eve: The handle to the event returned by dw_event_new(). 6703 * eve: The handle to the event returned by dw_event_new().
6704 */ 6704 */
6705 int dw_event_post(HEV eve) 6705 int API dw_event_post(HEV eve)
6706 { 6706 {
6707 return SetEvent(eve); 6707 return SetEvent(eve);
6708 } 6708 }
6709 6709
6710 /* 6710 /*
6711 * Waits on a semaphore created by dw_event_new(), until the 6711 * Waits on a semaphore created by dw_event_new(), until the
6712 * event gets posted or until the timeout expires. 6712 * event gets posted or until the timeout expires.
6713 * Parameters: 6713 * Parameters:
6714 * eve: The handle to the event returned by dw_event_new(). 6714 * eve: The handle to the event returned by dw_event_new().
6715 */ 6715 */
6716 int dw_event_wait(HEV eve, unsigned long timeout) 6716 int API dw_event_wait(HEV eve, unsigned long timeout)
6717 { 6717 {
6718 int rc; 6718 int rc;
6719 6719
6720 rc = WaitForSingleObject(eve, timeout); 6720 rc = WaitForSingleObject(eve, timeout);
6721 if(rc == WAIT_OBJECT_0) 6721 if(rc == WAIT_OBJECT_0)
6728 /* 6728 /*
6729 * Closes a semaphore created by dw_event_new(). 6729 * Closes a semaphore created by dw_event_new().
6730 * Parameters: 6730 * Parameters:
6731 * eve: The handle to the event returned by dw_event_new(). 6731 * eve: The handle to the event returned by dw_event_new().
6732 */ 6732 */
6733 int dw_event_close(HEV *eve) 6733 int API dw_event_close(HEV *eve)
6734 { 6734 {
6735 if(eve) 6735 if(eve)
6736 return CloseHandle(*eve); 6736 return CloseHandle(*eve);
6737 return FALSE; 6737 return FALSE;
6738 } 6738 }
6742 * Parameters: 6742 * Parameters:
6743 * func: Function which will be run in the new thread. 6743 * func: Function which will be run in the new thread.
6744 * data: Parameter(s) passed to the function. 6744 * data: Parameter(s) passed to the function.
6745 * stack: Stack size of new thread (OS/2 and Windows only). 6745 * stack: Stack size of new thread (OS/2 and Windows only).
6746 */ 6746 */
6747 DWTID dw_thread_new(void *func, void *data, int stack) 6747 DWTID API dw_thread_new(void *func, void *data, int stack)
6748 { 6748 {
6749 #if defined(__CYGWIN__) 6749 #if defined(__CYGWIN__)
6750 return 0; 6750 return 0;
6751 #else 6751 #else
6752 return (DWTID)_beginthread((void(*)(void *))func, stack, data); 6752 return (DWTID)_beginthread((void(*)(void *))func, stack, data);
6754 } 6754 }
6755 6755
6756 /* 6756 /*
6757 * Ends execution of current thread immediately. 6757 * Ends execution of current thread immediately.
6758 */ 6758 */
6759 void dw_thread_end(void) 6759 void API dw_thread_end(void)
6760 { 6760 {
6761 #if !defined(__CYGWIN__) 6761 #if !defined(__CYGWIN__)
6762 _endthread(); 6762 _endthread();
6763 #endif 6763 #endif
6764 } 6764 }
6765 6765
6766 /* 6766 /*
6767 * Returns the current thread's ID. 6767 * Returns the current thread's ID.
6768 */ 6768 */
6769 DWTID dw_thread_id(void) 6769 DWTID API dw_thread_id(void)
6770 { 6770 {
6771 #if defined(__CYGWIN__) 6771 #if defined(__CYGWIN__)
6772 return 0; 6772 return 0;
6773 #else 6773 #else
6774 return (DWTID)GetCurrentThreadId(); 6774 return (DWTID)GetCurrentThreadId();
6778 /* 6778 /*
6779 * Cleanly terminates a DW session, should be signal handler safe. 6779 * Cleanly terminates a DW session, should be signal handler safe.
6780 * Parameters: 6780 * Parameters:
6781 * exitcode: Exit code reported to the operating system. 6781 * exitcode: Exit code reported to the operating system.
6782 */ 6782 */
6783 void dw_exit(int exitcode) 6783 void API dw_exit(int exitcode)
6784 { 6784 {
6785 exit(exitcode); 6785 exit(exitcode);
6786 } 6786 }
6787 6787
6788 /* 6788 /*
6792 * topleft: Handle to the window to be top or left. 6792 * topleft: Handle to the window to be top or left.
6793 * bottomright: Handle to the window to be bottom or right. 6793 * bottomright: Handle to the window to be bottom or right.
6794 * Returns: 6794 * Returns:
6795 * A handle to a splitbar window or NULL on failure. 6795 * A handle to a splitbar window or NULL on failure.
6796 */ 6796 */
6797 HWND dw_splitbar_new(int type, HWND topleft, HWND bottomright, unsigned long id) 6797 HWND API dw_splitbar_new(int type, HWND topleft, HWND bottomright, unsigned long id)
6798 { 6798 {
6799 HWND tmp = CreateWindow(SplitbarClassName, 6799 HWND tmp = CreateWindow(SplitbarClassName,
6800 "", 6800 "",
6801 WS_VISIBLE | WS_CHILD | WS_CLIPCHILDREN, 6801 WS_VISIBLE | WS_CHILD | WS_CLIPCHILDREN,
6802 0,0,2000,1000, 6802 0,0,2000,1000,
6828 /* 6828 /*
6829 * Sets the position of a splitbar (pecentage). 6829 * Sets the position of a splitbar (pecentage).
6830 * Parameters: 6830 * Parameters:
6831 * handle: The handle to the splitbar returned by dw_splitbar_new(). 6831 * handle: The handle to the splitbar returned by dw_splitbar_new().
6832 */ 6832 */
6833 void dw_splitbar_set(HWND handle, float percent) 6833 void API dw_splitbar_set(HWND handle, float percent)
6834 { 6834 {
6835 float *mypercent = (float *)dw_window_get_data(handle, "_dw_percent"); 6835 float *mypercent = (float *)dw_window_get_data(handle, "_dw_percent");
6836 int type = (int)dw_window_get_data(handle, "_dw_type"); 6836 int type = (int)dw_window_get_data(handle, "_dw_type");
6837 unsigned long width, height; 6837 unsigned long width, height;
6838 6838
6847 /* 6847 /*
6848 * Gets the position of a splitbar (pecentage). 6848 * Gets the position of a splitbar (pecentage).
6849 * Parameters: 6849 * Parameters:
6850 * handle: The handle to the splitbar returned by dw_splitbar_new(). 6850 * handle: The handle to the splitbar returned by dw_splitbar_new().
6851 */ 6851 */
6852 float dw_splitbar_get(HWND handle) 6852 float API dw_splitbar_get(HWND handle)
6853 { 6853 {
6854 float *percent = (float *)dw_window_get_data(handle, "_dw_percent"); 6854 float *percent = (float *)dw_window_get_data(handle, "_dw_percent");
6855 6855
6856 if(percent) 6856 if(percent)
6857 return *percent; 6857 return *percent;
6867 * height: Height in pixels of the item or -1 to be self determined. 6867 * height: Height in pixels of the item or -1 to be self determined.
6868 * hsize: TRUE if the window (widget) should expand horizontally to fill space given. 6868 * hsize: TRUE if the window (widget) should expand horizontally to fill space given.
6869 * vsize: TRUE if the window (widget) should expand vertically to fill space given. 6869 * vsize: TRUE if the window (widget) should expand vertically to fill space given.
6870 * pad: Number of pixels of padding around the item. 6870 * pad: Number of pixels of padding around the item.
6871 */ 6871 */
6872 void dw_box_pack_end(HWND box, HWND item, int width, int height, int hsize, int vsize, int pad) 6872 void API dw_box_pack_end(HWND box, HWND item, int width, int height, int hsize, int vsize, int pad)
6873 { 6873 {
6874 Box *thisbox; 6874 Box *thisbox;
6875 6875
6876 thisbox = (Box *)GetWindowLong(box, GWL_USERDATA); 6876 thisbox = (Box *)GetWindowLong(box, GWL_USERDATA);
6877 if(thisbox) 6877 if(thisbox)
6934 * Sets the default focus item for a window/dialog. 6934 * Sets the default focus item for a window/dialog.
6935 * Parameters: 6935 * Parameters:
6936 * window: Toplevel window or dialog. 6936 * window: Toplevel window or dialog.
6937 * defaultitem: Handle to the dialog item to be default. 6937 * defaultitem: Handle to the dialog item to be default.
6938 */ 6938 */
6939 void dw_window_default(HWND window, HWND defaultitem) 6939 void API dw_window_default(HWND window, HWND defaultitem)
6940 { 6940 {
6941 Box *thisbox = (Box *)GetWindowLong(window, GWL_USERDATA); 6941 Box *thisbox = (Box *)GetWindowLong(window, GWL_USERDATA);
6942 6942
6943 if(thisbox) 6943 if(thisbox)
6944 thisbox->defaultitem = defaultitem; 6944 thisbox->defaultitem = defaultitem;
6948 * Sets window to click the default dialog item when an ENTER is pressed. 6948 * Sets window to click the default dialog item when an ENTER is pressed.
6949 * Parameters: 6949 * Parameters:
6950 * window: Window (widget) to look for the ENTER press. 6950 * window: Window (widget) to look for the ENTER press.
6951 * next: Window (widget) to move to next (or click) 6951 * next: Window (widget) to move to next (or click)
6952 */ 6952 */
6953 void dw_window_click_default(HWND window, HWND next) 6953 void API dw_window_click_default(HWND window, HWND next)
6954 { 6954 {
6955 ColorInfo *cinfo = (ColorInfo *)GetWindowLong(window, GWL_USERDATA); 6955 ColorInfo *cinfo = (ColorInfo *)GetWindowLong(window, GWL_USERDATA);
6956 6956
6957 if(cinfo) 6957 if(cinfo)
6958 cinfo->clickdefault = next; 6958 cinfo->clickdefault = next;
6961 /* 6961 /*
6962 * Returns some information about the current operating environment. 6962 * Returns some information about the current operating environment.
6963 * Parameters: 6963 * Parameters:
6964 * env: Pointer to a DWEnv struct. 6964 * env: Pointer to a DWEnv struct.
6965 */ 6965 */
6966 void dw_environment_query(DWEnv *env) 6966 void API dw_environment_query(DWEnv *env)
6967 { 6967 {
6968 if(!env) 6968 if(!env)
6969 return; 6969 return;
6970 6970
6971 /* Get the Windows version. */ 6971 /* Get the Windows version. */
7011 * Returns: 7011 * Returns:
7012 * NULL on error. A malloced buffer containing 7012 * NULL on error. A malloced buffer containing
7013 * the file path on success. 7013 * the file path on success.
7014 * 7014 *
7015 */ 7015 */
7016 char *dw_file_browse(char *title, char *defpath, char *ext, int flags) 7016 char * API dw_file_browse(char *title, char *defpath, char *ext, int flags)
7017 { 7017 {
7018 OPENFILENAME of; 7018 OPENFILENAME of;
7019 char filenamebuf[1001] = ""; 7019 char filenamebuf[1001] = "";
7020 int rc; 7020 int rc;
7021 7021
7055 * type: Either DW_EXEC_CON or DW_EXEC_GUI. 7055 * type: Either DW_EXEC_CON or DW_EXEC_GUI.
7056 * params: An array of pointers to string arguements. 7056 * params: An array of pointers to string arguements.
7057 * Returns: 7057 * Returns:
7058 * -1 on error. 7058 * -1 on error.
7059 */ 7059 */
7060 int dw_exec(char *program, int type, char **params) 7060 int API dw_exec(char *program, int type, char **params)
7061 { 7061 {
7062 char **newparams; 7062 char **newparams;
7063 int retcode, count = 0, z; 7063 int retcode, count = 0, z;
7064 7064
7065 while(params[count]) 7065 while(params[count])
7092 /* 7092 /*
7093 * Loads a web browser pointed at the given URL. 7093 * Loads a web browser pointed at the given URL.
7094 * Parameters: 7094 * Parameters:
7095 * url: Uniform resource locator. 7095 * url: Uniform resource locator.
7096 */ 7096 */
7097 int dw_browse(char *url) 7097 int API dw_browse(char *url)
7098 { 7098 {
7099 char *browseurl = url; 7099 char *browseurl = url;
7100 int retcode; 7100 int retcode;
7101 7101
7102 if(strlen(url) > 7 && strncmp(url, "file://", 7) == 0) 7102 if(strlen(url) > 7 && strncmp(url, "file://", 7) == 0)
7124 /* 7124 /*
7125 * Returns a pointer to a static buffer which containes the 7125 * Returns a pointer to a static buffer which containes the
7126 * current user directory. Or the root directory (C:\ on 7126 * current user directory. Or the root directory (C:\ on
7127 * OS/2 and Windows). 7127 * OS/2 and Windows).
7128 */ 7128 */
7129 char *dw_user_dir(void) 7129 char * API dw_user_dir(void)
7130 { 7130 {
7131 static char _user_dir[1024] = ""; 7131 static char _user_dir[1024] = "";
7132 7132
7133 if(!_user_dir[0]) 7133 if(!_user_dir[0])
7134 { 7134 {
7148 * Parameters: 7148 * Parameters:
7149 * handle: Window handle of the widget. 7149 * handle: Window handle of the widget.
7150 * function: Function pointer to be called. 7150 * function: Function pointer to be called.
7151 * data: Pointer to the data to be passed to the function. 7151 * data: Pointer to the data to be passed to the function.
7152 */ 7152 */
7153 void dw_window_function(HWND handle, void *function, void *data) 7153 void API dw_window_function(HWND handle, void *function, void *data)
7154 { 7154 {
7155 SendMessage(handle, WM_USER, (WPARAM)function, (LPARAM)data); 7155 SendMessage(handle, WM_USER, (WPARAM)function, (LPARAM)data);
7156 } 7156 }
7157 7157
7158 /* Functions for managing the user data lists that are associated with 7158 /* Functions for managing the user data lists that are associated with
7246 * Parameters: 7246 * Parameters:
7247 * window: Window handle of signal to be called back. 7247 * window: Window handle of signal to be called back.
7248 * dataname: A string pointer identifying which signal to be hooked. 7248 * dataname: A string pointer identifying which signal to be hooked.
7249 * data: User data to be passed to the handler function. 7249 * data: User data to be passed to the handler function.
7250 */ 7250 */
7251 void dw_window_set_data(HWND window, char *dataname, void *data) 7251 void API dw_window_set_data(HWND window, char *dataname, void *data)
7252 { 7252 {
7253 ColorInfo *cinfo = (ColorInfo *)GetWindowLong(window, GWL_USERDATA); 7253 ColorInfo *cinfo = (ColorInfo *)GetWindowLong(window, GWL_USERDATA);
7254 7254
7255 if(!cinfo) 7255 if(!cinfo)
7256 { 7256 {
7277 * Parameters: 7277 * Parameters:
7278 * window: Window handle of signal to be called back. 7278 * window: Window handle of signal to be called back.
7279 * dataname: A string pointer identifying which signal to be hooked. 7279 * dataname: A string pointer identifying which signal to be hooked.
7280 * data: User data to be passed to the handler function. 7280 * data: User data to be passed to the handler function.
7281 */ 7281 */
7282 void *dw_window_get_data(HWND window, char *dataname) 7282 void * API dw_window_get_data(HWND window, char *dataname)
7283 { 7283 {
7284 ColorInfo *cinfo = (ColorInfo *)GetWindowLong(window, GWL_USERDATA); 7284 ColorInfo *cinfo = (ColorInfo *)GetWindowLong(window, GWL_USERDATA);
7285 7285
7286 if(cinfo && cinfo->root && dataname) 7286 if(cinfo && cinfo->root && dataname)
7287 { 7287 {
7298 * window: Window handle of signal to be called back. 7298 * window: Window handle of signal to be called back.
7299 * signame: A string pointer identifying which signal to be hooked. 7299 * signame: A string pointer identifying which signal to be hooked.
7300 * sigfunc: The pointer to the function to be used as the callback. 7300 * sigfunc: The pointer to the function to be used as the callback.
7301 * data: User data to be passed to the handler function. 7301 * data: User data to be passed to the handler function.
7302 */ 7302 */
7303 void dw_signal_connect(HWND window, char *signame, void *sigfunc, void *data) 7303 void API dw_signal_connect(HWND window, char *signame, void *sigfunc, void *data)
7304 { 7304 {
7305 ULONG message = 0L; 7305 ULONG message = 0L;
7306 7306
7307 if(window && signame && sigfunc) 7307 if(window && signame && sigfunc)
7308 { 7308 {
7317 /* 7317 /*
7318 * Removes callbacks for a given window with given name. 7318 * Removes callbacks for a given window with given name.
7319 * Parameters: 7319 * Parameters:
7320 * window: Window handle of callback to be removed. 7320 * window: Window handle of callback to be removed.
7321 */ 7321 */
7322 void dw_signal_disconnect_by_name(HWND window, char *signame) 7322 void API dw_signal_disconnect_by_name(HWND window, char *signame)
7323 { 7323 {
7324 SignalHandler *prev = NULL, *tmp = Root; 7324 SignalHandler *prev = NULL, *tmp = Root;
7325 ULONG message; 7325 ULONG message;
7326 7326
7327 if(!window || !signame || (message = _findsigmessage(signame)) == 0) 7327 if(!window || !signame || (message = _findsigmessage(signame)) == 0)
7355 /* 7355 /*
7356 * Removes all callbacks for a given window. 7356 * Removes all callbacks for a given window.
7357 * Parameters: 7357 * Parameters:
7358 * window: Window handle of callback to be removed. 7358 * window: Window handle of callback to be removed.
7359 */ 7359 */
7360 void dw_signal_disconnect_by_window(HWND window) 7360 void API dw_signal_disconnect_by_window(HWND window)
7361 { 7361 {
7362 SignalHandler *prev = NULL, *tmp = Root; 7362 SignalHandler *prev = NULL, *tmp = Root;
7363 7363
7364 while(tmp) 7364 while(tmp)
7365 { 7365 {
7390 * Removes all callbacks for a given window with specified data. 7390 * Removes all callbacks for a given window with specified data.
7391 * Parameters: 7391 * Parameters:
7392 * window: Window handle of callback to be removed. 7392 * window: Window handle of callback to be removed.
7393 * data: Pointer to the data to be compared against. 7393 * data: Pointer to the data to be compared against.
7394 */ 7394 */
7395 void dw_signal_disconnect_by_data(HWND window, void *data) 7395 void API dw_signal_disconnect_by_data(HWND window, void *data)
7396 { 7396 {
7397 SignalHandler *prev = NULL, *tmp = Root; 7397 SignalHandler *prev = NULL, *tmp = Root;
7398 7398
7399 while(tmp) 7399 while(tmp)
7400 { 7400 {