comparison mac/dw.c @ 445:d9a5f98a1127

Reformatted source code, I am now using FTE on MacOS X. Implemented _get_window_pointer() and _set_window_pointer(), so now dw_window_get_data and dw_window_set_data should work. A
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Tue, 03 Jun 2003 07:33:26 +0000
parents e99cd6e45c0b
children bc156294dd16
comparison
equal deleted inserted replaced
444:faaeec0dba1d 445:d9a5f98a1127
5 * (C) 2003 Brian Smith <dbsoft@technologist.com> 5 * (C) 2003 Brian Smith <dbsoft@technologist.com>
6 * 6 *
7 */ 7 */
8 #include "dw.h" 8 #include "dw.h"
9 9
10 void _do_resize(Box *thisbox, int x, int y); 10 static void _do_resize(Box *thisbox, int x, int y);
11 11
12 typedef struct _sighandler 12 typedef struct _sighandler
13 { 13 {
14 struct _sighandler *next; 14 struct _sighandler *next;
15 ULONG message; 15 ULONG message;
91 Root = new; 91 Root = new;
92 } 92 }
93 } 93 }
94 94
95 /* Finds the message number for a given signal name */ 95 /* Finds the message number for a given signal name */
96 ULONG _findsigmessage(char *signame) 96 static ULONG _findsigmessage(char *signame)
97 { 97 {
98 int z; 98 int z;
99 99
100 for(z=0;z<SIGNALMAX;z++) 100 for(z=0;z<SIGNALMAX;z++)
101 { 101 {
103 return SignalTranslate[z].message; 103 return SignalTranslate[z].message;
104 } 104 }
105 return 0L; 105 return 0L;
106 } 106 }
107 107
108 void *_get_window_pointer(HWND handle) 108 static void *_get_window_pointer(HWND handle)
109 { 109 {
110 return NULL; 110 void *ret = NULL;
111 } 111
112 112 if(IsValidWindowRef((WindowRef)handle))
113 void _set_window_pointer(HWND handle, void *pointer) 113 GetWindowProperty((WindowRef)handle, 0, 'user', sizeof(void *), NULL, &ret);
114 { 114 else
115 GetControlProperty(handle, 0, 'user', sizeof(void *), NULL, &ret);
116 return ret;
117 }
118
119 static void _set_window_pointer(HWND handle, void *pointer)
120 {
121 if(IsValidWindowRef((WindowRef)handle))
122 SetWindowProperty((WindowRef)handle, 0, 'user', sizeof(void *), &pointer);
123 else
124 SetControlProperty(handle, 0, 'user', sizeof(void *), &pointer);
115 } 125 }
116 126
117 /* This function will recursively search a box and add up the total height of it */ 127 /* This function will recursively search a box and add up the total height of it */
118 void _count_size(HWND box, int type, int *xsize, int *xorigsize) 128 static void _count_size(HWND box, int type, int *xsize, int *xorigsize)
119 { 129 {
120 int size = 0, origsize = 0, z; 130 int size = 0, origsize = 0, z;
121 Box *tmp = _get_window_pointer(box); 131 Box *tmp = _get_window_pointer(box);
122 132
123 if(!tmp) 133 if(!tmp)
175 } 185 }
176 186
177 /* This function calculates how much space the widgets and boxes require 187 /* This function calculates how much space the widgets and boxes require
178 * and does expansion as necessary. 188 * and does expansion as necessary.
179 */ 189 */
180 int _resize_box(Box *thisbox, int *depth, int x, int y, int *usedx, int *usedy, 190 static int _resize_box(Box *thisbox, int *depth, int x, int y, int *usedx, int *usedy,
181 int pass, int *usedpadx, int *usedpady) 191 int pass, int *usedpadx, int *usedpady)
182 { 192 {
183 int z, currentx = 0, currenty = 0; 193 int z, currentx = 0, currenty = 0;
184 int uymax = 0, uxmax = 0; 194 int uymax = 0, uxmax = 0;
185 int upymax = 0, upxmax = 0; 195 int upymax = 0, upxmax = 0;
469 if(thisbox->items[z].vsize != SIZEEXPAND) 479 if(thisbox->items[z].vsize != SIZEEXPAND)
470 vectory = 0; 480 vectory = 0;
471 if(thisbox->items[z].hsize != SIZEEXPAND) 481 if(thisbox->items[z].hsize != SIZEEXPAND)
472 vectorx = 0; 482 vectorx = 0;
473 483
474 #if 0 484 MoveControl(handle, currentx + pad, currenty + pad);
475 WinSetWindowPos(handle, HWND_TOP, currentx + pad, currenty + pad, 485 SizeControl(handle, width + vectorx, height + vectory);
476 width + vectorx, height + vectory, SWP_MOVE | SWP_SIZE | SWP_ZORDER);
477 #endif
478 486
479 if(thisbox->type == DW_HORZ) 487 if(thisbox->type == DW_HORZ)
480 currentx += width + vectorx + (pad * 2); 488 currentx += width + vectorx + (pad * 2);
481 if(thisbox->type == DW_VERT) 489 if(thisbox->type == DW_VERT)
482 currenty += height + vectory + (pad * 2); 490 currenty += height + vectory + (pad * 2);
484 } 492 }
485 } 493 }
486 return 0; 494 return 0;
487 } 495 }
488 496
489 void _do_resize(Box *thisbox, int x, int y) 497 static void _do_resize(Box *thisbox, int x, int y)
490 { 498 {
491 if(x != 0 && y != 0) 499 if(x != 0 && y != 0)
492 { 500 {
493 if(thisbox) 501 if(thisbox)
494 { 502 {
507 _resize_box(thisbox, &depth, x, y, &usedx, &usedy, 2, &usedpadx, &usedpady); 515 _resize_box(thisbox, &depth, x, y, &usedx, &usedy, 2, &usedpadx, &usedpady);
508 } 516 }
509 } 517 }
510 } 518 }
511 519
512 int _dw_int_pos(HWND hwnd) 520 static int _dw_int_pos(HWND hwnd)
513 { 521 {
514 int pos = (int)dw_window_get_data(hwnd, "_dw_percent_value"); 522 int pos = (int)dw_window_get_data(hwnd, "_dw_percent_value");
515 int range = dw_percent_query_range(hwnd); 523 int range = dw_percent_query_range(hwnd);
516 float fpos = (float)pos; 524 float fpos = (float)pos;
517 float frange = (float)range; 525 float frange = (float)range;
518 float fnew = (fpos/1000.0)*frange; 526 float fnew = (fpos/1000.0)*frange;
519 return (int)fnew; 527 return (int)fnew;
520 } 528 }
521 529
522 void _dw_int_set(HWND hwnd, int pos) 530 static void _dw_int_set(HWND hwnd, int pos)
523 { 531 {
524 int inew, range = dw_percent_query_range(hwnd); 532 int inew, range = dw_percent_query_range(hwnd);
525 if(range) 533 if(range)
526 { 534 {
527 float fpos = (float)pos; 535 float fpos = (float)pos;
530 inew = (int)fnew; 538 inew = (int)fnew;
531 dw_window_set_data(hwnd, "_dw_percent_value", (void *)inew); 539 dw_window_set_data(hwnd, "_dw_percent_value", (void *)inew);
532 } 540 }
533 } 541 }
534 542
535 void _changebox(Box *thisbox, int percent, int type) 543 static void _changebox(Box *thisbox, int percent, int type)
536 { 544 {
537 int z; 545 int z;
538 546
539 for(z=0;z<thisbox->count;z++) 547 for(z=0;z<thisbox->count;z++)
540 { 548 {
558 } 566 }
559 } 567 }
560 } 568 }
561 569
562 /* Main MacOS Message loop, all events are handled here. */ 570 /* Main MacOS Message loop, all events are handled here. */
563 void _doEvents(EventRecord *eventStrucPtr) 571 static void _doEvents(EventRecord *eventStrucPtr)
564 { 572 {
565 SignalHandler *tmp = Root; 573 SignalHandler *tmp = Root;
566 574
567 while(tmp) 575 while(tmp)
568 { 576 {
569 if(tmp->message == eventStrucPtr->what) 577 if(tmp->message == eventStrucPtr->what)
570 { 578 {
571 switch(eventStrucPtr->what) 579 switch(eventStrucPtr->what)
572 { 580 {
573 case mouseDown: 581 case mouseDown:
574 break; 582 break;
575 case mouseUp: 583 case mouseUp:
576 break; 584 break;
577 case keyDown: 585 case keyDown:
578 break; 586 break;
579 } 587 }
580 } 588 }
581 if(tmp) 589 if(tmp)
582 tmp = tmp->next; 590 tmp = tmp->next;
583 } 591 }
584 } 592 }
585 593
586 /* 594 /*
587 * Initializes the Dynamic Windows engine. 595 * Initializes the Dynamic Windows engine.
588 * Parameters: 596 * Parameters:
590 * False if there is already a message loop running. 598 * False if there is already a message loop running.
591 */ 599 */
592 int API dw_init(int newthread, int argc, char *argv[]) 600 int API dw_init(int newthread, int argc, char *argv[])
593 { 601 {
594 CreateNewWindow (kDocumentWindowClass, 0, 602 CreateNewWindow (kDocumentWindowClass, 0,
595 &CreationRect, &CreationWindow); 603 &CreationRect, &CreationWindow);
596 CreateRootControl(CreationWindow, &RootControl); 604 CreateRootControl(CreationWindow, &RootControl);
597 HideWindow(CreationWindow); 605 HideWindow(CreationWindow);
598 return 0; 606 return 0;
599 } 607 }
600 608
601 /* 609 /*
602 * Runs a message loop for Dynamic Windows. 610 * Runs a message loop for Dynamic Windows.
603 */ 611 */
604 void API dw_main(void) 612 void API dw_main(void)
605 { 613 {
606 EventRecord eventStructure; 614 EventRecord eventStructure;
607 int gDone = false; 615 int gDone = false;
608 616
609 while(!gDone) 617 while(!gDone)
610 { 618 {
611 if(WaitNextEvent(everyEvent, &eventStructure, 180, 0)) 619 if(WaitNextEvent(everyEvent, &eventStructure, 180, 0))
612 _doEvents(&eventStructure); 620 _doEvents(&eventStructure);
613 } 621 }
614 } 622 }
615 623
616 /* 624 /*
617 * Runs a message loop for Dynamic Windows, for a period of milliseconds. 625 * Runs a message loop for Dynamic Windows, for a period of milliseconds.
618 * Parameters: 626 * Parameters:
619 * milliseconds: Number of milliseconds to run the loop for. 627 * milliseconds: Number of milliseconds to run the loop for.
620 */ 628 */
621 void API dw_main_sleep(int milliseconds) 629 void API dw_main_sleep(int milliseconds)
622 { 630 {
623 double start = (double)clock(); 631 double start = (double)clock();
624 632
625 while(((clock() - start) / (CLOCKS_PER_SEC/1000)) <= milliseconds) 633 while(((((clock() - start) / CLOCKS_PER_SEC)/1000)) <= milliseconds)
626 { 634 {
627 EventRecord eventStructure; 635 EventRecord eventStructure;
628 if(WaitNextEvent(everyEvent, &eventStructure, 1, 0)) 636 if(WaitNextEvent(everyEvent, &eventStructure, 1, 0))
629 _doEvents(&eventStructure); 637 _doEvents(&eventStructure);
630 } 638 }
631 } 639 }
632 640
633 /* 641 /*
634 * Processes a single message iteration and returns. 642 * Processes a single message iteration and returns.
635 */ 643 */
636 void API dw_main_iteration(void) 644 void API dw_main_iteration(void)
637 { 645 {
638 EventRecord eventStructure; 646 EventRecord eventStructure;
639 647
640 if(WaitNextEvent(everyEvent, &eventStructure, 0, 0)) 648 if(WaitNextEvent(everyEvent, &eventStructure, 0, 0))
641 _doEvents(&eventStructure); 649 _doEvents(&eventStructure);
642 } 650 }
643 651
644 /* 652 /*
645 * Free's memory allocated by dynamic windows. 653 * Free's memory allocated by dynamic windows.
646 * Parameters: 654 * Parameters:
665 dw_event_reset(tmp->eve); 673 dw_event_reset(tmp->eve);
666 tmp->data = data; 674 tmp->data = data;
667 tmp->done = FALSE; 675 tmp->done = FALSE;
668 tmp->result = NULL; 676 tmp->result = NULL;
669 677
670 return tmp; 678 return tmp;
671 } 679 }
672 680
673 /* 681 /*
674 * Accepts a dialog struct and returns the given data to the 682 * Accepts a dialog struct and returns the given data to the
675 * initial called of dw_dialog_wait(). 683 * initial called of dw_dialog_wait().
691 * Parameters: 699 * Parameters:
692 * dialog: Pointer to a dialog struct aquired by dw_dialog_new). 700 * dialog: Pointer to a dialog struct aquired by dw_dialog_new).
693 */ 701 */
694 void * API dw_dialog_wait(DWDialog *dialog) 702 void * API dw_dialog_wait(DWDialog *dialog)
695 { 703 {
696 void *tmp; 704 void *tmp;
697 EventRecord eventStructure; 705 EventRecord eventStructure;
698 706
699 while(!dialog->done) 707 while(!dialog->done)
700 { 708 {
701 if(WaitNextEvent(everyEvent, &eventStructure, 180, 0)) 709 if(WaitNextEvent(everyEvent, &eventStructure, 180, 0))
702 _doEvents(&eventStructure); 710 _doEvents(&eventStructure);
703 } 711 }
704 dw_event_close(&dialog->eve); 712 dw_event_close(&dialog->eve);
705 tmp = dialog->result; 713 tmp = dialog->result;
706 free(dialog); 714 free(dialog);
707 return tmp; 715 return tmp;
708 } 716 }
717 */ 725 */
718 int API dw_messagebox(char *title, int flags, char *format, ...) 726 int API dw_messagebox(char *title, int flags, char *format, ...)
719 { 727 {
720 va_list args; 728 va_list args;
721 char outbuf[1024]; 729 char outbuf[1024];
722 AlertStdCFStringAlertParamRec param; 730 AlertStdCFStringAlertParamRec param;
723 DialogRef dialog; 731 DialogRef dialog;
724 CFStringRef cftext, cftitle; 732 CFStringRef cftext, cftitle;
725 DialogItemIndex item; 733 DialogItemIndex item;
726 int ret = DW_MB_RETURN_OK; 734 int ret = DW_MB_RETURN_OK;
727 AlertType alert = kAlertPlainAlert; 735 AlertType alert = kAlertPlainAlert;
728 736
729 va_start(args, format); 737 va_start(args, format);
730 vsprintf(outbuf, format, args); 738 vsprintf(outbuf, format, args);
731 va_end(args); 739 va_end(args);
732 740
733 GetStandardAlertDefaultParams(&param, kStdCFStringAlertVersionOne); 741 GetStandardAlertDefaultParams(&param, kStdCFStringAlertVersionOne);
734 param.movable = TRUE; 742 param.movable = TRUE;
735 param.helpButton = FALSE; 743 param.helpButton = FALSE;
736 if(flags & DW_MB_INFORMATION) 744 if(flags & DW_MB_INFORMATION)
737 alert = kAlertNoteAlert; 745 alert = kAlertNoteAlert;
738 else if(flags & DW_MB_ERROR) 746 else if(flags & DW_MB_ERROR)
739 alert = kAlertStopAlert; 747 alert = kAlertStopAlert;
740 else if(flags & DW_MB_WARNING) 748 else if(flags & DW_MB_WARNING)
741 alert = kAlertCautionAlert; 749 alert = kAlertCautionAlert;
742 750
743 if(flags & DW_MB_OK || flags & DW_MB_OKCANCEL) 751 if(flags & DW_MB_OK || flags & DW_MB_OKCANCEL)
744 { 752 {
745 param.defaultText = CFSTR("Ok"); 753 param.defaultText = CFSTR("Ok");
746 param.cancelText = flags & DW_MB_OK ? 0 : CFSTR("Cancel"); 754 param.cancelText = flags & DW_MB_OK ? 0 : CFSTR("Cancel");
755 }
756 else
757 {
758 param.defaultText = CFSTR("Yes");
759 param.cancelText = CFSTR("No");
760 param.otherText = CFSTR("Cancel");
761 }
762 cftext = CFStringCreateWithCString(NULL, outbuf, kCFStringEncodingDOSLatinUS);
763 cftitle = CFStringCreateWithCString(NULL, title, kCFStringEncodingDOSLatinUS);
764 if(CreateStandardAlert(alert, cftext, cftitle, &param, &dialog) == noErr)
765 {
766 if(RunStandardAlert(dialog, NULL, &item) == noErr)
767 {
768 if(item == kAlertStdAlertOtherButton)
769 ret = DW_MB_RETURN_CANCEL;
770 else if(item == kAlertStdAlertCancelButton)
771 {
772 if(flags & DW_MB_OK || flags & DW_MB_OKCANCEL)
773 ret = DW_MB_RETURN_CANCEL;
774 else
775 ret = DW_MB_RETURN_NO;
776 }
777 else if(item == kAlertStdAlertOKButton)
778 {
779 if(flags & DW_MB_YESNO || flags & DW_MB_YESNOCANCEL)
780 ret = DW_MB_RETURN_YES;
781 }
782 }
747 } 783 }
748 else 784 CFRelease(cftext);
749 { 785 CFRelease(cftitle);
750 param.defaultText = CFSTR("Yes"); 786 return ret;
751 param.cancelText = CFSTR("No");
752 param.otherText = CFSTR("Cancel");
753 }
754 cftext = CFStringCreateWithCString(NULL, outbuf, kCFStringEncodingDOSLatinUS);
755 cftitle = CFStringCreateWithCString(NULL, title, kCFStringEncodingDOSLatinUS);
756 if(CreateStandardAlert(alert, cftext, cftitle, &param, &dialog) == noErr)
757 {
758 if(RunStandardAlert(dialog, NULL, &item) == noErr)
759 {
760 if(item == kAlertStdAlertOtherButton)
761 ret = DW_MB_RETURN_CANCEL;
762 else if(item == kAlertStdAlertCancelButton)
763 {
764 if(flags & DW_MB_OK || flags & DW_MB_OKCANCEL)
765 ret = DW_MB_RETURN_CANCEL;
766 else
767 ret = DW_MB_RETURN_NO;
768 }
769 }
770 }
771 CFRelease(cftext);
772 CFRelease(cftitle);
773 return ret;
774 } 787 }
775 788
776 /* 789 /*
777 * Makes the window topmost. 790 * Makes the window topmost.
778 * Parameters: 791 * Parameters:
779 * handle: The window handle to make topmost. 792 * handle: The window handle to make topmost.
780 */ 793 */
781 int API dw_window_raise(HWND handle) 794 int API dw_window_raise(HWND handle)
782 { 795 {
783 BringToFront((WindowRef)handle); 796 BringToFront((WindowRef)handle);
784 return 0; 797 return 0;
785 } 798 }
786 799
787 /* 800 /*
788 * Makes the window bottommost. 801 * Makes the window bottommost.
799 * Parameters: 812 * Parameters:
800 * handle: The window handle to make visible. 813 * handle: The window handle to make visible.
801 */ 814 */
802 int API dw_window_show(HWND handle) 815 int API dw_window_show(HWND handle)
803 { 816 {
804 ShowWindow((WindowRef)handle); 817 ShowWindow((WindowRef)handle);
805 return 0; 818 return 0;
806 } 819 }
807 820
808 /* 821 /*
809 * Minimizes or Iconifies a top-level window. 822 * Minimizes or Iconifies a top-level window.
820 * Parameters: 833 * Parameters:
821 * handle: The window handle to make visible. 834 * handle: The window handle to make visible.
822 */ 835 */
823 int API dw_window_hide(HWND handle) 836 int API dw_window_hide(HWND handle)
824 { 837 {
825 HideWindow((WindowRef)handle); 838 HideWindow((WindowRef)handle);
826 return 0; 839 return 0;
827 } 840 }
828 841
829 /* 842 /*
830 * Destroys a window and all of it's children. 843 * Destroys a window and all of it's children.
831 * Parameters: 844 * Parameters:
832 * handle: The window handle to destroy. 845 * handle: The window handle to destroy.
833 */ 846 */
834 int API dw_window_destroy(HWND handle) 847 int API dw_window_destroy(HWND handle)
835 { 848 {
836 DisposeWindow((WindowRef)handle); 849 DisposeWindow((WindowRef)handle);
837 return 0; 850 return 0;
838 } 851 }
839 852
840 /* Causes entire window to be invalidated and redrawn. 853 /* Causes entire window to be invalidated and redrawn.
841 * Parameters: 854 * Parameters:
920 * handle: Handle to widget for which to change. 933 * handle: Handle to widget for which to change.
921 * cursortype: ID of the pointer you want. 934 * cursortype: ID of the pointer you want.
922 */ 935 */
923 void API dw_window_pointer(HWND handle, int pointertype) 936 void API dw_window_pointer(HWND handle, int pointertype)
924 { 937 {
925 SetCursor(*GetCursor(pointertype)); 938 SetCursor(*GetCursor(pointertype));
926 } 939 }
927 940
928 /* 941 /*
929 * Create a new Window Frame. 942 * Create a new Window Frame.
930 * Parameters: 943 * Parameters:
933 * flStyle: Style flags, see the PM reference. 946 * flStyle: Style flags, see the PM reference.
934 */ 947 */
935 HWND API dw_window_new(HWND hwndOwner, char *title, ULONG flStyle) 948 HWND API dw_window_new(HWND hwndOwner, char *title, ULONG flStyle)
936 { 949 {
937 WindowRef hwnd = 0; 950 WindowRef hwnd = 0;
938 ControlRef rootcontrol = 0; 951 ControlRef rootcontrol = 0;
939 952
940 CreateNewWindow (kDocumentWindowClass, flStyle, 953 CreateNewWindow (kDocumentWindowClass, flStyle,
941 &CreationRect, &hwnd); 954 &CreationRect, &hwnd);
942 CreateRootControl(hwnd, &rootcontrol); 955 CreateRootControl(hwnd, &rootcontrol);
943 dw_window_set_text((HWND)hwnd, title); 956 dw_window_set_text((HWND)hwnd, title);
944 return (HWND)hwnd; 957 return (HWND)hwnd;
945 } 958 }
946 959
947 /* 960 /*
948 * Create a new Box to be packed. 961 * Create a new Box to be packed.
949 * Parameters: 962 * Parameters:
962 * pad: Number of pixels to pad around the box. 975 * pad: Number of pixels to pad around the box.
963 * title: Text to be displayined in the group outline. 976 * title: Text to be displayined in the group outline.
964 */ 977 */
965 HWND API dw_groupbox_new(int type, int pad, char *title) 978 HWND API dw_groupbox_new(int type, int pad, char *title)
966 { 979 {
967 HWND hwnd = 0; 980 HWND hwnd = 0;
968 CreateRadioGroupControl(CreationWindow, &CreationRect, &hwnd); 981 CreateRadioGroupControl(CreationWindow, &CreationRect, &hwnd);
969 return hwnd; 982 return hwnd;
970 } 983 }
971 984
972 /* 985 /*
973 * Create a new MDI Frame to be packed. 986 * Create a new MDI Frame to be packed.
974 * Parameters: 987 * Parameters:
984 * Parameters: 997 * Parameters:
985 * id: An ID to be used with dw_window_from_id() or 0L. 998 * id: An ID to be used with dw_window_from_id() or 0L.
986 */ 999 */
987 HWND API dw_bitmap_new(ULONG id) 1000 HWND API dw_bitmap_new(ULONG id)
988 { 1001 {
989 HWND hwnd = 0; 1002 HWND hwnd = 0;
990 CreateImageWellControl(CreationWindow, &CreationRect, NULL, &hwnd); 1003 CreateImageWellControl(CreationWindow, &CreationRect, NULL, &hwnd);
991 return hwnd; 1004 return hwnd;
992 } 1005 }
993 1006
994 /* 1007 /*
995 * Create a notebook object to be packed. 1008 * Create a notebook object to be packed.
996 * Parameters: 1009 * Parameters:
997 * id: An ID to be used for getting the resource from the 1010 * id: An ID to be used for getting the resource from the
998 * resource file. 1011 * resource file.
999 */ 1012 */
1000 HWND API dw_notebook_new(ULONG id, int top) 1013 HWND API dw_notebook_new(ULONG id, int top)
1001 { 1014 {
1002 HWND hwnd = 0; 1015 HWND hwnd = 0;
1003 CreateTabsControl(CreationWindow, &CreationRect, kControlTabSizeSmall, kControlTabDirectionNorth, 1, NULL, &hwnd); 1016 CreateTabsControl(CreationWindow, &CreationRect, kControlTabSizeSmall, kControlTabDirectionNorth, 1, NULL, &hwnd);
1004 return hwnd; 1017 return hwnd;
1005 } 1018 }
1006 1019
1007 /* 1020 /*
1008 * Create a menu object to be popped up. 1021 * Create a menu object to be popped up.
1009 * Parameters: 1022 * Parameters:
1100 * id: An ID to be used for getting the resource from the 1113 * id: An ID to be used for getting the resource from the
1101 * resource file. 1114 * resource file.
1102 */ 1115 */
1103 HWND API dw_container_new(ULONG id, int multi) 1116 HWND API dw_container_new(ULONG id, int multi)
1104 { 1117 {
1105 ListHandle hwnd = 0; 1118 ListHandle hwnd = 0;
1106 Point CellSize; 1119 Point CellSize;
1107 ListDefSpec def; 1120 ListDefSpec def;
1108 1121
1109 SetPt(&CellSize, 52, 52); 1122 SetPt(&CellSize, 52, 52);
1110 /*def.u.userProc = listDefinitionFunctionUPP;*/ 1123 /*def.u.userProc = listDefinitionFunctionUPP;*/
1111 1124
1112 CreateCustomList(&CreationRect, &CreationRect, CellSize, &def, CreationWindow, TRUE, TRUE, TRUE, TRUE, &hwnd); 1125 CreateCustomList(&CreationRect, &CreationRect, CellSize, &def, CreationWindow, TRUE, TRUE, TRUE, TRUE, &hwnd);
1113 return (HWND)hwnd; 1126 return (HWND)hwnd;
1114 } 1127 }
1115 1128
1116 /* 1129 /*
1117 * Create a tree object to be packed. 1130 * Create a tree object to be packed.
1118 * Parameters: 1131 * Parameters:
1130 * text: The text to be display by the static text widget. 1143 * text: The text to be display by the static text widget.
1131 * id: An ID to be used with dw_window_from_id() or 0L. 1144 * id: An ID to be used with dw_window_from_id() or 0L.
1132 */ 1145 */
1133 HWND API dw_text_new(char *text, ULONG id) 1146 HWND API dw_text_new(char *text, ULONG id)
1134 { 1147 {
1135 HWND hwnd = 0; 1148 HWND hwnd = 0;
1136 CFStringRef cftext = CFStringCreateWithCString(NULL, text, kCFStringEncodingDOSLatinUS); 1149 CFStringRef cftext = CFStringCreateWithCString(NULL, text, kCFStringEncodingDOSLatinUS);
1137 CreateStaticTextControl (CreationWindow, &CreationRect, cftext, NULL, &hwnd); 1150 CreateStaticTextControl (CreationWindow, &CreationRect, cftext, NULL, &hwnd);
1138 CFRelease(cftext); 1151 CFRelease(cftext);
1139 return hwnd; 1152 return hwnd;
1140 } 1153 }
1141 1154
1142 /* 1155 /*
1143 * Create a new status text window (widget) to be packed. 1156 * Create a new status text window (widget) to be packed.
1144 * Parameters: 1157 * Parameters:
1145 * text: The text to be display by the static text widget. 1158 * text: The text to be display by the static text widget.
1146 * id: An ID to be used with dw_window_from_id() or 0L. 1159 * id: An ID to be used with dw_window_from_id() or 0L.
1147 */ 1160 */
1148 HWND API dw_status_text_new(char *text, ULONG id) 1161 HWND API dw_status_text_new(char *text, ULONG id)
1149 { 1162 {
1150 HWND hwnd = 0; 1163 HWND hwnd = 0;
1151 CFStringRef cftext = CFStringCreateWithCString(NULL, text, kCFStringEncodingDOSLatinUS); 1164 CFStringRef cftext = CFStringCreateWithCString(NULL, text, kCFStringEncodingDOSLatinUS);
1152 CreateStaticTextControl (CreationWindow, &CreationRect, cftext, NULL, &hwnd); 1165 CreateStaticTextControl (CreationWindow, &CreationRect, cftext, NULL, &hwnd);
1153 CFRelease(cftext); 1166 CFRelease(cftext);
1154 return hwnd; 1167 return hwnd;
1155 } 1168 }
1156 1169
1157 /* 1170 /*
1158 * Create a new Multiline Editbox window (widget) to be packed. 1171 * Create a new Multiline Editbox window (widget) to be packed.
1159 * Parameters: 1172 * Parameters:
1160 * id: An ID to be used with dw_window_from_id() or 0L. 1173 * id: An ID to be used with dw_window_from_id() or 0L.
1161 */ 1174 */
1162 HWND API dw_mle_new(ULONG id) 1175 HWND API dw_mle_new(ULONG id)
1163 { 1176 {
1164 HWND hwnd = 0; 1177 HWND hwnd = 0;
1165 CreateScrollingTextBoxControl(CreationWindow, &CreationRect, id, FALSE, 0, 0, 0, &hwnd); 1178 CreateScrollingTextBoxControl(CreationWindow, &CreationRect, id, FALSE, 0, 0, 0, &hwnd);
1166 return hwnd; 1179 return hwnd;
1167 } 1180 }
1168 1181
1169 /* 1182 /*
1170 * Create a new Entryfield window (widget) to be packed. 1183 * Create a new Entryfield window (widget) to be packed.
1171 * Parameters: 1184 * Parameters:
1172 * text: The default text to be in the entryfield widget. 1185 * text: The default text to be in the entryfield widget.
1173 * id: An ID to be used with dw_window_from_id() or 0L. 1186 * id: An ID to be used with dw_window_from_id() or 0L.
1174 */ 1187 */
1175 HWND API dw_entryfield_new(char *text, ULONG id) 1188 HWND API dw_entryfield_new(char *text, ULONG id)
1176 { 1189 {
1177 HWND hwnd = 0; 1190 HWND hwnd = 0;
1178 CFStringRef cftext = CFStringCreateWithCString(NULL, text, kCFStringEncodingDOSLatinUS); 1191 CFStringRef cftext = CFStringCreateWithCString(NULL, text, kCFStringEncodingDOSLatinUS);
1179 CreateEditTextControl(CreationWindow, &CreationRect, cftext, FALSE, FALSE, NULL, &hwnd); 1192 CreateEditTextControl(CreationWindow, &CreationRect, cftext, FALSE, FALSE, NULL, &hwnd);
1180 CFRelease(cftext); 1193 CFRelease(cftext);
1181 return hwnd; 1194 return hwnd;
1182 } 1195 }
1183 1196
1184 /* 1197 /*
1185 * Create a new Entryfield (password) window (widget) to be packed. 1198 * Create a new Entryfield (password) window (widget) to be packed.
1186 * Parameters: 1199 * Parameters:
1187 * text: The default text to be in the entryfield widget. 1200 * text: The default text to be in the entryfield widget.
1188 * id: An ID to be used with dw_window_from_id() or 0L. 1201 * id: An ID to be used with dw_window_from_id() or 0L.
1189 */ 1202 */
1190 HWND API dw_entryfield_password_new(char *text, ULONG id) 1203 HWND API dw_entryfield_password_new(char *text, ULONG id)
1191 { 1204 {
1192 HWND hwnd = 0; 1205 HWND hwnd = 0;
1193 CFStringRef cftext = CFStringCreateWithCString(NULL, text, kCFStringEncodingDOSLatinUS); 1206 CFStringRef cftext = CFStringCreateWithCString(NULL, text, kCFStringEncodingDOSLatinUS);
1194 CreateEditTextControl(CreationWindow, &CreationRect, cftext, TRUE, FALSE, NULL, &hwnd); 1207 CreateEditTextControl(CreationWindow, &CreationRect, cftext, TRUE, FALSE, NULL, &hwnd);
1195 CFRelease(cftext); 1208 CFRelease(cftext);
1196 return hwnd; 1209 return hwnd;
1197 } 1210 }
1198 1211
1199 /* 1212 /*
1200 * Create a new Combobox window (widget) to be packed. 1213 * Create a new Combobox window (widget) to be packed.
1201 * Parameters: 1214 * Parameters:
1213 * text: The text to be display by the static text widget. 1226 * text: The text to be display by the static text widget.
1214 * id: An ID to be used with dw_window_from_id() or 0L. 1227 * id: An ID to be used with dw_window_from_id() or 0L.
1215 */ 1228 */
1216 HWND API dw_button_new(char *text, ULONG id) 1229 HWND API dw_button_new(char *text, ULONG id)
1217 { 1230 {
1218 HWND hwnd = 0; 1231 HWND hwnd = 0;
1219 CFStringRef cftext = CFStringCreateWithCString(NULL, text, kCFStringEncodingDOSLatinUS); 1232 CFStringRef cftext = CFStringCreateWithCString(NULL, text, kCFStringEncodingDOSLatinUS);
1220 CreatePushButtonControl(CreationWindow, &CreationRect, cftext, &hwnd); 1233 CreatePushButtonControl(CreationWindow, &CreationRect, cftext, &hwnd);
1221 CFRelease(cftext); 1234 CFRelease(cftext);
1222 return hwnd; 1235 return hwnd;
1223 } 1236 }
1224 1237
1225 /* 1238 /*
1226 * Create a new bitmap button window (widget) to be packed. 1239 * Create a new bitmap button window (widget) to be packed.
1227 * Parameters: 1240 * Parameters:
1228 * text: Bubble help text to be displayed. 1241 * text: Bubble help text to be displayed.
1229 * id: An ID of a bitmap in the resource file. 1242 * id: An ID of a bitmap in the resource file.
1230 */ 1243 */
1231 HWND API dw_bitmapbutton_new(char *text, ULONG id) 1244 HWND API dw_bitmapbutton_new(char *text, ULONG id)
1232 { 1245 {
1233 HWND hwnd = 0; 1246 HWND hwnd = 0;
1234 CreatePushButtonWithIconControl(CreationWindow, &CreationRect, 0, NULL, kControlPushButtonIconOnLeft, &hwnd); 1247 CreatePushButtonWithIconControl(CreationWindow, &CreationRect, 0, NULL, kControlPushButtonIconOnLeft, &hwnd);
1235 return hwnd; 1248 return hwnd;
1236 } 1249 }
1237 1250
1238 /* 1251 /*
1239 * Create a new bitmap button window (widget) to be packed from a file. 1252 * Create a new bitmap button window (widget) to be packed from a file.
1240 * Parameters: 1253 * Parameters:
1266 * text: The text to be display by the static text widget. 1279 * text: The text to be display by the static text widget.
1267 * id: An ID to be used with dw_window_from_id() or 0L. 1280 * id: An ID to be used with dw_window_from_id() or 0L.
1268 */ 1281 */
1269 HWND API dw_radiobutton_new(char *text, ULONG id) 1282 HWND API dw_radiobutton_new(char *text, ULONG id)
1270 { 1283 {
1271 HWND hwnd = 0; 1284 HWND hwnd = 0;
1272 CFStringRef cftext = CFStringCreateWithCString(NULL, text, kCFStringEncodingDOSLatinUS); 1285 CFStringRef cftext = CFStringCreateWithCString(NULL, text, kCFStringEncodingDOSLatinUS);
1273 CreateRadioButtonControl(CreationWindow, &CreationRect, cftext, 0, FALSE, &hwnd); 1286 CreateRadioButtonControl(CreationWindow, &CreationRect, cftext, 0, FALSE, &hwnd);
1274 CFRelease(cftext); 1287 CFRelease(cftext);
1275 return hwnd; 1288 return hwnd;
1276 } 1289 }
1277 1290
1278 1291
1279 /* 1292 /*
1280 * Create a new slider window (widget) to be packed. 1293 * Create a new slider window (widget) to be packed.
1283 * increments: Number of increments available. 1296 * increments: Number of increments available.
1284 * id: An ID to be used with dw_window_from_id() or 0L. 1297 * id: An ID to be used with dw_window_from_id() or 0L.
1285 */ 1298 */
1286 HWND API dw_slider_new(int vertical, int increments, ULONG id) 1299 HWND API dw_slider_new(int vertical, int increments, ULONG id)
1287 { 1300 {
1288 HWND hwnd = 0; 1301 HWND hwnd = 0;
1289 CreateSliderControl(CreationWindow, &CreationRect, 0, 0, increments, kControlSliderDoesNotPoint, 0, FALSE, 0, &hwnd); 1302 CreateSliderControl(CreationWindow, &CreationRect, 0, 0, increments, kControlSliderDoesNotPoint, 0, FALSE, 0, &hwnd);
1290 return hwnd; 1303 return hwnd;
1291 } 1304 }
1292 1305
1293 /* 1306 /*
1294 * Create a new scrollbar window (widget) to be packed. 1307 * Create a new scrollbar window (widget) to be packed.
1295 * Parameters: 1308 * Parameters:
1297 * increments: Number of increments available. 1310 * increments: Number of increments available.
1298 * id: An ID to be used with dw_window_from_id() or 0L. 1311 * id: An ID to be used with dw_window_from_id() or 0L.
1299 */ 1312 */
1300 HWND API dw_scrollbar_new(int vertical, int increments, ULONG id) 1313 HWND API dw_scrollbar_new(int vertical, int increments, ULONG id)
1301 { 1314 {
1302 HWND hwnd; 1315 HWND hwnd;
1303 CreateScrollBarControl(CreationWindow, &CreationRect, 0, 0, increments, increments, FALSE, 0, &hwnd); 1316 CreateScrollBarControl(CreationWindow, &CreationRect, 0, 0, increments, increments, FALSE, 0, &hwnd);
1304 return hwnd; 1317 return hwnd;
1305 } 1318 }
1306 1319
1307 /* 1320 /*
1308 * Create a new percent bar window (widget) to be packed. 1321 * Create a new percent bar window (widget) to be packed.
1309 * Parameters: 1322 * Parameters:
1310 * id: An ID to be used with dw_window_from_id() or 0L. 1323 * id: An ID to be used with dw_window_from_id() or 0L.
1311 */ 1324 */
1312 HWND API dw_percent_new(ULONG id) 1325 HWND API dw_percent_new(ULONG id)
1313 { 1326 {
1314 HWND hwnd = 0; 1327 HWND hwnd = 0;
1315 CreateProgressBarControl(CreationWindow, &CreationRect, 0, 0, 100, FALSE, &hwnd); 1328 CreateProgressBarControl(CreationWindow, &CreationRect, 0, 0, 100, FALSE, &hwnd);
1316 return hwnd; 1329 return hwnd;
1317 } 1330 }
1318 1331
1319 /* 1332 /*
1320 * Create a new checkbox window (widget) to be packed. 1333 * Create a new checkbox window (widget) to be packed.
1321 * Parameters: 1334 * Parameters:
1322 * text: The text to be display by the static text widget. 1335 * text: The text to be display by the static text widget.
1323 * id: An ID to be used with dw_window_from_id() or 0L. 1336 * id: An ID to be used with dw_window_from_id() or 0L.
1324 */ 1337 */
1325 HWND API dw_checkbox_new(char *text, ULONG id) 1338 HWND API dw_checkbox_new(char *text, ULONG id)
1326 { 1339 {
1327 HWND hwnd = 0; 1340 HWND hwnd = 0;
1328 CFStringRef cftext = CFStringCreateWithCString(NULL, text, kCFStringEncodingDOSLatinUS); 1341 CFStringRef cftext = CFStringCreateWithCString(NULL, text, kCFStringEncodingDOSLatinUS);
1329 CreateCheckBoxControl(CreationWindow, &CreationRect, cftext, 0, TRUE, &hwnd); 1342 CreateCheckBoxControl(CreationWindow, &CreationRect, cftext, 0, TRUE, &hwnd);
1330 CFRelease(cftext); 1343 CFRelease(cftext);
1331 return hwnd; 1344 return hwnd;
1332 } 1345 }
1333 1346
1334 /* 1347 /*
1335 * Create a new listbox window (widget) to be packed. 1348 * Create a new listbox window (widget) to be packed.
1336 * Parameters: 1349 * Parameters:
1337 * id: An ID to be used with dw_window_from_id() or 0L. 1350 * id: An ID to be used with dw_window_from_id() or 0L.
1338 * multi: Multiple select TRUE or FALSE. 1351 * multi: Multiple select TRUE or FALSE.
1339 */ 1352 */
1340 HWND API dw_listbox_new(ULONG id, int multi) 1353 HWND API dw_listbox_new(ULONG id, int multi)
1341 { 1354 {
1342 HWND hwnd = 0; 1355 HWND hwnd = 0;
1343 CreateListBoxControl(CreationWindow, &CreationRect, TRUE, 0, 1, FALSE, TRUE, 50, 50, TRUE, NULL, &hwnd); 1356 CreateListBoxControl(CreationWindow, &CreationRect, TRUE, 0, 1, FALSE, TRUE, 50, 50, TRUE, NULL, &hwnd);
1344 return hwnd; 1357 return hwnd;
1345 } 1358 }
1346 1359
1347 /* 1360 /*
1348 * Sets the icon used for a given window. 1361 * Sets the icon used for a given window.
1349 * Parameters: 1362 * Parameters:
1374 * handle: Handle to the window. 1387 * handle: Handle to the window.
1375 * text: The text associsated with a given window. 1388 * text: The text associsated with a given window.
1376 */ 1389 */
1377 void API dw_window_set_text(HWND handle, char *text) 1390 void API dw_window_set_text(HWND handle, char *text)
1378 { 1391 {
1379 CFStringRef cftext = CFStringCreateWithCString(NULL, text, kCFStringEncodingDOSLatinUS); 1392 CFStringRef cftext = CFStringCreateWithCString(NULL, text, kCFStringEncodingDOSLatinUS);
1380 if(IsValidWindowRef((WindowRef)handle)) 1393 if(IsValidWindowRef((WindowRef)handle))
1381 SetWindowTitleWithCFString((WindowRef)handle, cftext); 1394 SetWindowTitleWithCFString((WindowRef)handle, cftext);
1382 else 1395 else
1383 SetControlTitleWithCFString(handle, cftext); 1396 SetControlTitleWithCFString(handle, cftext);
1384 CFRelease(cftext); 1397 CFRelease(cftext);
1385 } 1398 }
1386 1399
1387 /* 1400 /*
1388 * Gets the text used for a given window. 1401 * Gets the text used for a given window.
1389 * Parameters: 1402 * Parameters:
1391 * Returns: 1404 * Returns:
1392 * text: The text associsated with a given window. 1405 * text: The text associsated with a given window.
1393 */ 1406 */
1394 char * API dw_window_get_text(HWND handle) 1407 char * API dw_window_get_text(HWND handle)
1395 { 1408 {
1396 CFStringRef cftext; 1409 CFStringRef cftext;
1397 char *ret = NULL; 1410 char *ret = NULL;
1398 1411
1399 if(IsValidWindowRef((WindowRef)handle)) 1412 if(IsValidWindowRef((WindowRef)handle))
1400 CopyWindowTitleAsCFString((WindowRef)handle, &cftext); 1413 CopyWindowTitleAsCFString((WindowRef)handle, &cftext);
1401 else 1414 else
1402 { 1415 {
1403 Str255 str; 1416 Str255 str;
1404 1417
1405 GetControlTitle(handle, str); 1418 GetControlTitle(handle, str);
1406 cftext = CFStringCreateWithPascalString(NULL, str, CFStringGetSystemEncoding()); 1419 cftext = CFStringCreateWithPascalString(NULL, str, CFStringGetSystemEncoding());
1407 } 1420 }
1408 1421
1409 if(cftext) 1422 if(cftext)
1410 { 1423 {
1411 int length = CFStringGetLength(cftext) + 1; 1424 int length = CFStringGetLength(cftext) + 1;
1412 char *ret = malloc(length); 1425 char *ret = malloc(length);
1413 CFStringGetCString(cftext, ret, length, kCFStringEncodingDOSLatinUS); 1426 CFStringGetCString(cftext, ret, length, kCFStringEncodingDOSLatinUS);
1414 CFRelease(cftext); 1427 CFRelease(cftext);
1415 } 1428 }
1416 return ret; 1429 return ret;
1417 } 1430 }
1418 1431
1419 /* 1432 /*
1420 * Disables given window (widget). 1433 * Disables given window (widget).
1510 * x: X location from the bottom left. 1523 * x: X location from the bottom left.
1511 * y: Y location from the bottom left. 1524 * y: Y location from the bottom left.
1512 */ 1525 */
1513 void API dw_window_set_pos(HWND handle, ULONG x, ULONG y) 1526 void API dw_window_set_pos(HWND handle, ULONG x, ULONG y)
1514 { 1527 {
1515 MoveWindow((WindowRef)handle, (short)x, (short)y, FALSE); 1528 MoveWindow((WindowRef)handle, (short)x, (short)y, FALSE);
1516 } 1529 }
1517 1530
1518 /* 1531 /*
1519 * Sets the position and size of a given window (widget). 1532 * Sets the position and size of a given window (widget).
1520 * Parameters: 1533 * Parameters:
1524 * width: Width of the widget. 1537 * width: Width of the widget.
1525 * height: Height of the widget. 1538 * height: Height of the widget.
1526 */ 1539 */
1527 void API dw_window_set_pos_size(HWND handle, ULONG x, ULONG y, ULONG width, ULONG height) 1540 void API dw_window_set_pos_size(HWND handle, ULONG x, ULONG y, ULONG width, ULONG height)
1528 { 1541 {
1529 dw_window_set_pos(handle, x, y); 1542 dw_window_set_pos(handle, x, y);
1530 dw_window_set_usize(handle, width, height); 1543 dw_window_set_usize(handle, width, height);
1531 } 1544 }
1532 1545
1533 /* 1546 /*
1534 * Gets the position and size of a given window (widget). 1547 * Gets the position and size of a given window (widget).
1535 * Parameters: 1548 * Parameters:
2676 * data: Parameter(s) passed to the function. 2689 * data: Parameter(s) passed to the function.
2677 * stack: Stack size of new thread (OS/2 and Windows only). 2690 * stack: Stack size of new thread (OS/2 and Windows only).
2678 */ 2691 */
2679 DWTID API dw_thread_new(void *func, void *data, int stack) 2692 DWTID API dw_thread_new(void *func, void *data, int stack)
2680 { 2693 {
2681 return (DWTID)-1; 2694 return (DWTID)-1;
2682 } 2695 }
2683 2696
2684 /* 2697 /*
2685 * Ends execution of current thread immediately. 2698 * Ends execution of current thread immediately.
2686 */ 2699 */
2780 * env: Pointer to a DWEnv struct. 2793 * env: Pointer to a DWEnv struct.
2781 */ 2794 */
2782 void API dw_environment_query(DWEnv *env) 2795 void API dw_environment_query(DWEnv *env)
2783 { 2796 {
2784 ULONG Build; 2797 ULONG Build;
2785 char verbuf[10]; 2798 char verbuf[10];
2786 2799
2787 if(!env) 2800 if(!env)
2788 return; 2801 return;
2789 2802
2790 Gestalt(gestaltSystemVersion, &Build); 2803 Gestalt(gestaltSystemVersion, &Build);
2791 2804
2792 sprintf(verbuf, "%04x", Build); 2805 sprintf(verbuf, "%04x", (int)Build);
2793 2806
2794 strcpy(env->osName,"MacOS"); 2807 strcpy(env->osName,"MacOS");
2795 env->MajorBuild = atoi(&verbuf[3]); 2808 env->MajorBuild = atoi(&verbuf[3]);
2796 verbuf[3] = 0; 2809 verbuf[3] = 0;
2797 env->MinorVersion = atoi(&verbuf[2]); 2810 env->MinorVersion = atoi(&verbuf[2]);
2798 verbuf[2] = 0; 2811 verbuf[2] = 0;
2799 env->MajorVersion = atoi(verbuf); 2812 env->MajorVersion = atoi(verbuf);
2800 2813
2801 env->MinorBuild = 0; 2814 env->MinorBuild = 0;
2802 2815
2803 strcpy(env->buildDate, __DATE__); 2816 strcpy(env->buildDate, __DATE__);
2882 2895
2883 /* Functions for managing the user data lists that are associated with 2896 /* Functions for managing the user data lists that are associated with
2884 * a given window handle. Used in dw_window_set_data() and 2897 * a given window handle. Used in dw_window_set_data() and
2885 * dw_window_get_data(). 2898 * dw_window_get_data().
2886 */ 2899 */
2887 UserData *_find_userdata(UserData **root, char *varname) 2900 static UserData *_find_userdata(UserData **root, char *varname)
2888 { 2901 {
2889 UserData *tmp = *root; 2902 UserData *tmp = *root;
2890 2903
2891 while(tmp) 2904 while(tmp)
2892 { 2905 {
2895 tmp = tmp->next; 2908 tmp = tmp->next;
2896 } 2909 }
2897 return NULL; 2910 return NULL;
2898 } 2911 }
2899 2912
2900 int _new_userdata(UserData **root, char *varname, void *data) 2913 static int _new_userdata(UserData **root, char *varname, void *data)
2901 { 2914 {
2902 UserData *new = _find_userdata(root, varname); 2915 UserData *new = _find_userdata(root, varname);
2903 2916
2904 if(new) 2917 if(new)
2905 { 2918 {
2935 } 2948 }
2936 } 2949 }
2937 return FALSE; 2950 return FALSE;
2938 } 2951 }
2939 2952
2940 int _remove_userdata(UserData **root, char *varname, int all) 2953 static int _remove_userdata(UserData **root, char *varname, int all)
2941 { 2954 {
2942 UserData *prev = NULL, *tmp = *root; 2955 UserData *prev = NULL, *tmp = *root;
2943 2956
2944 while(tmp) 2957 while(tmp)
2945 { 2958 {