Mercurial > dwindows
annotate mac/dw.m @ 728:55f22b39ab57
Changes to correctly set the main thread and lock the run mutex when not running a loop and when called from a callback.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Mon, 14 Mar 2011 22:25:01 +0000 |
parents | f190b5c2ce16 |
children | 6712e4211522 |
rev | line source |
---|---|
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2 * Dynamic Windows: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3 * A GTK like implementation of the MacOS GUI using Cocoa |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4 * |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5 * (C) 2011 Brian Smith <brian@dbsoft.org> |
721
56053f1af9ee
Fixes for dw_container/filessystem_get_column_type from Mark Hessling... adding him to the copyright section.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
720
diff
changeset
|
6 * (C) 2011 Mark Hessling <mark@rexx.org> |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7 * |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8 * Using garbage collection so requires 10.5 or later. |
671
c60a4f6cfae8
Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
670
diff
changeset
|
9 * clang -std=c99 -g -o dwtest -D__MAC__ -I. dwtest.c mac/dw.m -framework Cocoa -framework WebKit -fobjc-gc-only |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
10 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
11 #import <Cocoa/Cocoa.h> |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
12 #import <WebKit/WebKit.h> |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
13 #include "dw.h" |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
14 #include <sys/utsname.h> |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
15 #include <sys/socket.h> |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
16 #include <sys/un.h> |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
17 #include <sys/mman.h> |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
18 #include <sys/time.h> |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
19 #include <sys/stat.h> |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
20 |
719
d5e49ef8f541
Updated the #if for Snow Leopard/Leopard builds to handle them not being defined properly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
718
diff
changeset
|
21 /* Create a define to let us know to include Snow Leopard specific features */ |
d5e49ef8f541
Updated the #if for Snow Leopard/Leopard builds to handle them not being defined properly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
718
diff
changeset
|
22 #if defined(MAC_OS_X_VERSION_10_6) && ((defined(MAC_OS_X_VERSION_MIN_REQUIRED) && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6) || !defined(MAC_OS_X_VERSION_MIN_REQUIRED)) |
d5e49ef8f541
Updated the #if for Snow Leopard/Leopard builds to handle them not being defined properly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
718
diff
changeset
|
23 #define BUILDING_FOR_SNOW_LEOPARD |
d5e49ef8f541
Updated the #if for Snow Leopard/Leopard builds to handle them not being defined properly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
718
diff
changeset
|
24 #endif |
d5e49ef8f541
Updated the #if for Snow Leopard/Leopard builds to handle them not being defined properly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
718
diff
changeset
|
25 |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
26 /* Macros to protect access to thread unsafe classes */ |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
27 #define DW_MUTEX_LOCK { \ |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
28 if(DWThread != (DWTID)-1 && pthread_self() != DWThread && pthread_self() != _dw_mutex_locked) { \ |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
29 dw_mutex_lock(DWThreadMutex); \ |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
30 _dw_mutex_locked = pthread_self(); \ |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
31 dw_mutex_lock(DWThreadMutex2); \ |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
32 [DWObj performSelectorOnMainThread:@selector(synchronizeThread:) withObject:nil waitUntilDone:NO]; \ |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
33 dw_mutex_lock(DWRunMutex); \ |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
34 _locked_by_me = TRUE; } } |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
35 #define DW_MUTEX_UNLOCK { \ |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
36 if(pthread_self() != DWThread && _locked_by_me == TRUE) { \ |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
37 dw_mutex_unlock(DWRunMutex); \ |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
38 dw_mutex_unlock(DWThreadMutex2); \ |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
39 _dw_mutex_locked = (pthread_t)-1; \ |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
40 dw_mutex_unlock(DWThreadMutex); \ |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
41 _locked_by_me = FALSE; } } |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
42 |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
43 unsigned long _colors[] = |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
44 { |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
45 0x00000000, /* 0 black */ |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
46 0x00bb0000, /* 1 red */ |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
47 0x0000bb00, /* 2 green */ |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
48 0x00aaaa00, /* 3 yellow */ |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
49 0x000000cc, /* 4 blue */ |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
50 0x00bb00bb, /* 5 magenta */ |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
51 0x0000bbbb, /* 6 cyan */ |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
52 0x00bbbbbb, /* 7 white */ |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
53 0x00777777, /* 8 grey */ |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
54 0x00ff0000, /* 9 bright red */ |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
55 0x0000ff00, /* 10 bright green */ |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
56 0x00eeee00, /* 11 bright yellow */ |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
57 0x000000ff, /* 12 bright blue */ |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
58 0x00ff00ff, /* 13 bright magenta */ |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
59 0x0000eeee, /* 14 bright cyan */ |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
60 0x00ffffff, /* 15 bright white */ |
689
4199730e9889
Fixed errors creating scrollbars.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
688
diff
changeset
|
61 0xff000000 /* 16 default color */ |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
62 }; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
63 |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
64 unsigned long _get_color(unsigned long thiscolor) |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
65 { |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
66 if(thiscolor & DW_RGB_COLOR) |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
67 { |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
68 return thiscolor & ~DW_RGB_COLOR; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
69 } |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
70 else if(thiscolor < 17) |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
71 { |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
72 return _colors[thiscolor]; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
73 } |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
74 return 0; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
75 } |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
76 |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
77 typedef struct _sighandler |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
78 { |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
79 struct _sighandler *next; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
80 ULONG message; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
81 HWND window; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
82 int id; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
83 void *signalfunction; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
84 void *data; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
85 |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
86 } SignalHandler; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
87 |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
88 SignalHandler *Root = NULL; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
89 |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
90 /* Some internal prototypes */ |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
91 static void _do_resize(Box *thisbox, int x, int y); |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
92 int _remove_userdata(UserData **root, char *varname, int all); |
725
4e09c92363df
Experimental changes to dw_main_sleep() and dw_main_iteration() to hopefully solve some issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
724
diff
changeset
|
93 int _dw_main_iteration(NSDate *date); |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
94 |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
95 SignalHandler *_get_handler(HWND window, int messageid) |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
96 { |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
97 SignalHandler *tmp = Root; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
98 |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
99 /* Find any callbacks for this function */ |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
100 while(tmp) |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
101 { |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
102 if(tmp->message == messageid && window == tmp->window) |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
103 { |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
104 return tmp; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
105 } |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
106 tmp = tmp->next; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
107 } |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
108 return NULL; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
109 } |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
110 |
703
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
111 typedef struct |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
112 { |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
113 ULONG message; |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
114 char name[30]; |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
115 |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
116 } SignalList; |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
117 |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
118 /* List of signals */ |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
119 #define SIGNALMAX 16 |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
120 |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
121 SignalList SignalTranslate[SIGNALMAX] = { |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
122 { 1, DW_SIGNAL_CONFIGURE }, |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
123 { 2, DW_SIGNAL_KEY_PRESS }, |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
124 { 3, DW_SIGNAL_BUTTON_PRESS }, |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
125 { 4, DW_SIGNAL_BUTTON_RELEASE }, |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
126 { 5, DW_SIGNAL_MOTION_NOTIFY }, |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
127 { 6, DW_SIGNAL_DELETE }, |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
128 { 7, DW_SIGNAL_EXPOSE }, |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
129 { 8, DW_SIGNAL_CLICKED }, |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
130 { 9, DW_SIGNAL_ITEM_ENTER }, |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
131 { 10, DW_SIGNAL_ITEM_CONTEXT }, |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
132 { 11, DW_SIGNAL_LIST_SELECT }, |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
133 { 12, DW_SIGNAL_ITEM_SELECT }, |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
134 { 13, DW_SIGNAL_SET_FOCUS }, |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
135 { 14, DW_SIGNAL_VALUE_CHANGED }, |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
136 { 15, DW_SIGNAL_SWITCH_PAGE }, |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
137 { 16, DW_SIGNAL_TREE_EXPAND } |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
138 }; |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
139 |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
140 int _event_handler(id object, NSEvent *event, int message) |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
141 { |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
142 SignalHandler *handler = _get_handler(object, message); |
706
79b38b1f3346
Scrollbar event fixes... scale was wrong... not sure it is correct but it is better.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
705
diff
changeset
|
143 /* NSLog(@"Event handler - type %d\n", message); */ |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
144 |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
145 if(handler) |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
146 { |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
147 switch(message) |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
148 { |
703
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
149 /* Timer event */ |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
150 case 0: |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
151 { |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
152 int (* API timerfunc)(void *) = (int (* API)(void *))handler->signalfunction; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
153 |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
154 if(!timerfunc(handler->data)) |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
155 dw_timer_disconnect(handler->id); |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
156 return 0; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
157 } |
703
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
158 /* Configure/Resize event */ |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
159 case 1: |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
160 { |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
161 int (*sizefunc)(HWND, int, int, void *) = handler->signalfunction; |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
162 NSSize size; |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
163 |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
164 if([object isMemberOfClass:[NSWindow class]]) |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
165 { |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
166 NSWindow *window = object; |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
167 size = [[window contentView] frame].size; |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
168 } |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
169 else |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
170 { |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
171 NSView *view = object; |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
172 size = [view frame].size; |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
173 } |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
174 |
706
79b38b1f3346
Scrollbar event fixes... scale was wrong... not sure it is correct but it is better.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
705
diff
changeset
|
175 if(size.width > 0 && size.height > 0) |
79b38b1f3346
Scrollbar event fixes... scale was wrong... not sure it is correct but it is better.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
705
diff
changeset
|
176 { |
79b38b1f3346
Scrollbar event fixes... scale was wrong... not sure it is correct but it is better.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
705
diff
changeset
|
177 return sizefunc(object, size.width, size.height, handler->data); |
79b38b1f3346
Scrollbar event fixes... scale was wrong... not sure it is correct but it is better.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
705
diff
changeset
|
178 } |
79b38b1f3346
Scrollbar event fixes... scale was wrong... not sure it is correct but it is better.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
705
diff
changeset
|
179 return 0; |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
180 } |
723
37c8d2b4cec5
Initial key press event/signal handling... does not seem to trap on all controls...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
722
diff
changeset
|
181 case 2: |
37c8d2b4cec5
Initial key press event/signal handling... does not seem to trap on all controls...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
722
diff
changeset
|
182 { |
37c8d2b4cec5
Initial key press event/signal handling... does not seem to trap on all controls...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
722
diff
changeset
|
183 int (*keypressfunc)(HWND, char, int, int, void *) = handler->signalfunction; |
37c8d2b4cec5
Initial key press event/signal handling... does not seem to trap on all controls...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
722
diff
changeset
|
184 NSString *nchar = [event charactersIgnoringModifiers]; |
37c8d2b4cec5
Initial key press event/signal handling... does not seem to trap on all controls...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
722
diff
changeset
|
185 int special = (int)[event modifierFlags]; |
724
41080d22edc8
Couple more fixes to keyhandling... committed before I finished what I was doing...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
723
diff
changeset
|
186 unichar vk = [nchar characterAtIndex:0]; |
723
37c8d2b4cec5
Initial key press event/signal handling... does not seem to trap on all controls...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
722
diff
changeset
|
187 char ch; |
724
41080d22edc8
Couple more fixes to keyhandling... committed before I finished what I was doing...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
723
diff
changeset
|
188 |
723
37c8d2b4cec5
Initial key press event/signal handling... does not seem to trap on all controls...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
722
diff
changeset
|
189 /* Handle a valid key */ |
724
41080d22edc8
Couple more fixes to keyhandling... committed before I finished what I was doing...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
723
diff
changeset
|
190 if([nchar length] == 1) |
723
37c8d2b4cec5
Initial key press event/signal handling... does not seem to trap on all controls...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
722
diff
changeset
|
191 { |
37c8d2b4cec5
Initial key press event/signal handling... does not seem to trap on all controls...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
722
diff
changeset
|
192 const char *tmp = [nchar UTF8String]; |
37c8d2b4cec5
Initial key press event/signal handling... does not seem to trap on all controls...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
722
diff
changeset
|
193 if(tmp) |
37c8d2b4cec5
Initial key press event/signal handling... does not seem to trap on all controls...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
722
diff
changeset
|
194 { |
37c8d2b4cec5
Initial key press event/signal handling... does not seem to trap on all controls...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
722
diff
changeset
|
195 ch = tmp[0]; |
37c8d2b4cec5
Initial key press event/signal handling... does not seem to trap on all controls...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
722
diff
changeset
|
196 } |
37c8d2b4cec5
Initial key press event/signal handling... does not seem to trap on all controls...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
722
diff
changeset
|
197 } |
37c8d2b4cec5
Initial key press event/signal handling... does not seem to trap on all controls...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
722
diff
changeset
|
198 |
724
41080d22edc8
Couple more fixes to keyhandling... committed before I finished what I was doing...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
723
diff
changeset
|
199 return keypressfunc(handler->window, ch, (int)vk, special, handler->data); |
723
37c8d2b4cec5
Initial key press event/signal handling... does not seem to trap on all controls...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
722
diff
changeset
|
200 } |
703
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
201 /* Button press and release event */ |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
202 case 3: |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
203 case 4: |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
204 { |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
205 int (* API buttonfunc)(HWND, int, int, int, void *) = (int (* API)(HWND, int, int, int, void *))handler->signalfunction; |
701
c91a1b345f2e
Fix for button press and context menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
700
diff
changeset
|
206 int button = (int)event; |
c91a1b345f2e
Fix for button press and context menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
700
diff
changeset
|
207 LONG x,y; |
c91a1b345f2e
Fix for button press and context menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
700
diff
changeset
|
208 |
c91a1b345f2e
Fix for button press and context menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
700
diff
changeset
|
209 dw_pointer_query_pos(&x, &y); |
c91a1b345f2e
Fix for button press and context menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
700
diff
changeset
|
210 |
c91a1b345f2e
Fix for button press and context menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
700
diff
changeset
|
211 return buttonfunc(object, (int)x, (int)y, button, handler->data); |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
212 } |
703
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
213 /* Window close event */ |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
214 case 6: |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
215 { |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
216 int (* API closefunc)(HWND, void *) = (int (* API)(HWND, void *))handler->signalfunction; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
217 return closefunc(object, handler->data); |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
218 } |
703
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
219 /* Window expose/draw event */ |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
220 case 7: |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
221 { |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
222 DWExpose exp; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
223 int (* API exposefunc)(HWND, DWExpose *, void *) = (int (* API)(HWND, DWExpose *, void *))handler->signalfunction; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
224 NSRect rect = [object frame]; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
225 |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
226 exp.x = rect.origin.x; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
227 exp.y = rect.origin.y; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
228 exp.width = rect.size.width; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
229 exp.height = rect.size.height; |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
230 int result = exposefunc(object, &exp, handler->data); |
661
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
231 [[object window] flushWindow]; |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
232 return result; |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
233 } |
703
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
234 /* Clicked event for buttons and menu items */ |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
235 case 8: |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
236 { |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
237 int (* API clickfunc)(HWND, void *) = (int (* API)(HWND, void *))handler->signalfunction; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
238 |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
239 return clickfunc(object, handler->data); |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
240 } |
703
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
241 /* Container class selection event */ |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
242 case 9: |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
243 { |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
244 int (*containerselectfunc)(HWND, char *, void *) = handler->signalfunction; |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
245 |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
246 return containerselectfunc(handler->window, (char *)event, handler->data); |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
247 } |
703
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
248 /* Container context menu event */ |
659
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
249 case 10: |
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
250 { |
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
251 int (* API containercontextfunc)(HWND, char *, int, int, void *, void *) = (int (* API)(HWND, char *, int, int, void *, void *))handler->signalfunction; |
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
252 char *text = (char *)event; |
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
253 void *user = NULL; |
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
254 LONG x,y; |
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
255 |
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
256 dw_pointer_query_pos(&x, &y); |
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
257 |
665
e6bec2290f3f
Fixing warnings with Xcode 4 and switched to manual releasing in the draw functions to stop leaking.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
664
diff
changeset
|
258 return containercontextfunc(handler->window, text, (int)x, (int)y, handler->data, user); |
659
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
259 } |
703
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
260 /* Generic selection changed event for several classes */ |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
261 case 11: |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
262 case 14: |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
263 { |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
264 int (* API valuechangedfunc)(HWND, int, void *) = (int (* API)(HWND, int, void *))handler->signalfunction; |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
265 int selected = (int)event; |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
266 |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
267 return valuechangedfunc(handler->window, selected, handler->data);; |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
268 } |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
269 /* Tree class selection event */ |
659
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
270 case 12: |
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
271 { |
709
5a268d5f1cfa
Fixes for tree event handling. Still more to come shortly...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
708
diff
changeset
|
272 int (* API treeselectfunc)(HWND, HTREEITEM, char *, void *, void *) = (int (* API)(HWND, HTREEITEM, char *, void *, void *))handler->signalfunction; |
5a268d5f1cfa
Fixes for tree event handling. Still more to come shortly...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
708
diff
changeset
|
273 char *text = (char *)event; |
5a268d5f1cfa
Fixes for tree event handling. Still more to come shortly...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
708
diff
changeset
|
274 void *user = NULL; |
5a268d5f1cfa
Fixes for tree event handling. Still more to come shortly...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
708
diff
changeset
|
275 id item = nil; |
5a268d5f1cfa
Fixes for tree event handling. Still more to come shortly...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
708
diff
changeset
|
276 |
710
78460ff977c1
Finishing up tree event/signal handlers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
709
diff
changeset
|
277 if([object isKindOfClass:[NSOutlineView class]]) |
709
5a268d5f1cfa
Fixes for tree event handling. Still more to come shortly...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
708
diff
changeset
|
278 { |
5a268d5f1cfa
Fixes for tree event handling. Still more to come shortly...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
708
diff
changeset
|
279 item = (id)event; |
5a268d5f1cfa
Fixes for tree event handling. Still more to come shortly...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
708
diff
changeset
|
280 NSString *nstr = [item pointerAtIndex:1]; |
5a268d5f1cfa
Fixes for tree event handling. Still more to come shortly...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
708
diff
changeset
|
281 |
727
f190b5c2ce16
Fixed 2 errors in the tree select event handler. Also removed unused experimental code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
726
diff
changeset
|
282 if(nstr) |
712
01107d8e033e
Fixed the scrollbar maximum range to be correct. Also added some MLE code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
711
diff
changeset
|
283 { |
01107d8e033e
Fixed the scrollbar maximum range to be correct. Also added some MLE code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
711
diff
changeset
|
284 text = strdup([nstr UTF8String]); |
01107d8e033e
Fixed the scrollbar maximum range to be correct. Also added some MLE code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
711
diff
changeset
|
285 } |
713
2c8fc0fd8c11
Don't send tree events with no selected item. Also don't strdup a NULL string.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
712
diff
changeset
|
286 else |
2c8fc0fd8c11
Don't send tree events with no selected item. Also don't strdup a NULL string.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
712
diff
changeset
|
287 { |
2c8fc0fd8c11
Don't send tree events with no selected item. Also don't strdup a NULL string.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
712
diff
changeset
|
288 text = NULL; |
2c8fc0fd8c11
Don't send tree events with no selected item. Also don't strdup a NULL string.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
712
diff
changeset
|
289 } |
727
f190b5c2ce16
Fixed 2 errors in the tree select event handler. Also removed unused experimental code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
726
diff
changeset
|
290 user = [item pointerAtIndex:2]; |
709
5a268d5f1cfa
Fixes for tree event handling. Still more to come shortly...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
708
diff
changeset
|
291 int result = treeselectfunc(handler->window, item, text, handler->data, user); |
720
357b59e57a31
Some fixes for out of range parameters passed to dw_listbox_g/set_text().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
719
diff
changeset
|
292 if(text) |
357b59e57a31
Some fixes for out of range parameters passed to dw_listbox_g/set_text().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
719
diff
changeset
|
293 { |
357b59e57a31
Some fixes for out of range parameters passed to dw_listbox_g/set_text().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
719
diff
changeset
|
294 free(text); |
357b59e57a31
Some fixes for out of range parameters passed to dw_listbox_g/set_text().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
719
diff
changeset
|
295 } |
709
5a268d5f1cfa
Fixes for tree event handling. Still more to come shortly...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
708
diff
changeset
|
296 return result; |
5a268d5f1cfa
Fixes for tree event handling. Still more to come shortly...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
708
diff
changeset
|
297 } |
659
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
298 |
709
5a268d5f1cfa
Fixes for tree event handling. Still more to come shortly...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
708
diff
changeset
|
299 return treeselectfunc(handler->window, item, text, handler->data, user); |
5a268d5f1cfa
Fixes for tree event handling. Still more to come shortly...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
708
diff
changeset
|
300 } |
703
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
301 /* Set Focus event */ |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
302 case 13: |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
303 { |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
304 int (* API setfocusfunc)(HWND, void *) = (int (* API)(HWND, void *))handler->signalfunction; |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
305 |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
306 return setfocusfunc(handler->window, handler->data); |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
307 } |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
308 /* Notebook page change event */ |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
309 case 15: |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
310 { |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
311 int (* API switchpagefunc)(HWND, unsigned long, void *) = (int (* API)(HWND, unsigned long, void *))handler->signalfunction; |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
312 int pageid = (int)event; |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
313 |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
314 return switchpagefunc(handler->window, pageid, handler->data); |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
315 } |
722
5a8d5161651d
Implemented tree expand event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
721
diff
changeset
|
316 case 16: |
5a8d5161651d
Implemented tree expand event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
721
diff
changeset
|
317 { |
5a8d5161651d
Implemented tree expand event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
721
diff
changeset
|
318 int (* API treeexpandfunc)(HWND, HTREEITEM, void *) = (int (* API)(HWND, HTREEITEM, void *))handler->signalfunction; |
5a8d5161651d
Implemented tree expand event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
721
diff
changeset
|
319 |
5a8d5161651d
Implemented tree expand event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
721
diff
changeset
|
320 return treeexpandfunc(handler->window, (HTREEITEM)event, handler->data); |
5a8d5161651d
Implemented tree expand event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
721
diff
changeset
|
321 } |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
322 } |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
323 } |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
324 return -1; |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
325 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
326 |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
327 /* Subclass for the Timer type */ |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
328 @interface DWTimerHandler : NSObject { } |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
329 -(void)runTimer:(id)sender; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
330 @end |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
331 |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
332 @implementation DWTimerHandler |
674
78f9aa6d6d89
Fixes or fonts and loading images from files. Added Mac specific settings to dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
673
diff
changeset
|
333 -(void)runTimer:(id)sender { _event_handler(sender, nil, 0); } |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
334 @end |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
335 |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
336 NSApplication *DWApp; |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
337 NSMenu *DWMainMenu; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
338 DWTimerHandler *DWHandler; |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
339 #if !defined(GARBAGE_COLLECT) |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
340 NSAutoreleasePool *pool; |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
341 #endif |
661
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
342 HWND _DWLastDrawable; |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
343 HMTX DWRunMutex; |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
344 HMTX DWThreadMutex; |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
345 HMTX DWThreadMutex2; |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
346 DWTID DWThread = (DWTID)-1; |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
347 DWTID _dw_mutex_locked = (DWTID)-1; |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
348 |
699
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
349 /* Used for doing bitblts from the main thread */ |
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
350 typedef struct _bitbltinfo |
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
351 { |
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
352 id src; |
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
353 id dest; |
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
354 int xdest; |
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
355 int ydest; |
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
356 int width; |
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
357 int height; |
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
358 int xsrc; |
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
359 int ysrc; |
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
360 } DWBitBlt; |
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
361 |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
362 /* Subclass for a test object type */ |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
363 @interface DWObject : NSObject {} |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
364 -(void)uselessThread:(id)sender; |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
365 -(void)synchronizeThread:(id)param; |
699
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
366 -(void)doBitBlt:(id)param; |
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
367 -(void)doFlush:(id)param; |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
368 @end |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
369 |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
370 @implementation DWObject |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
371 -(void)uselessThread:(id)sender { /* Thread only to initialize threading */ } |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
372 -(void)synchronizeThread:(id)param |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
373 { |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
374 pthread_mutex_unlock(DWRunMutex); |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
375 pthread_mutex_lock(DWThreadMutex2); |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
376 pthread_mutex_unlock(DWThreadMutex2); |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
377 pthread_mutex_lock(DWRunMutex); |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
378 } |
699
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
379 -(void)doBitBlt:(id)param |
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
380 { |
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
381 NSValue *bi = (NSValue *)param; |
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
382 DWBitBlt *bltinfo = (DWBitBlt *)[bi pointerValue]; |
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
383 id bltdest = bltinfo->dest; |
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
384 id bltsrc = bltinfo->src; |
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
385 |
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
386 if([bltdest isMemberOfClass:[NSImage class]]) |
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
387 { |
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
388 [bltdest lockFocus]; |
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
389 } |
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
390 else |
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
391 { |
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
392 [bltdest lockFocusIfCanDraw]; |
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
393 _DWLastDrawable = bltinfo->dest; |
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
394 } |
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
395 if([bltsrc isMemberOfClass:[NSImage class]]) |
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
396 { |
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
397 NSImage *image = bltsrc; |
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
398 [image drawAtPoint:NSMakePoint(bltinfo->xdest, bltinfo->ydest) fromRect:NSMakeRect(bltinfo->xsrc, bltinfo->ysrc, bltinfo->width, bltinfo->height) |
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
399 operation:NSCompositeCopy fraction:1.0]; |
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
400 [bltsrc release]; |
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
401 } |
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
402 [bltdest unlockFocus]; |
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
403 free(bltinfo); |
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
404 } |
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
405 -(void)doFlush:(id)param |
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
406 { |
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
407 if(_DWLastDrawable) |
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
408 { |
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
409 id object = _DWLastDrawable; |
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
410 NSWindow *window = [object window]; |
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
411 [window flushWindow]; |
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
412 } |
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
413 } |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
414 @end |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
415 |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
416 DWObject *DWObj; |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
417 |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
418 /* So basically to implement our event handlers... |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
419 * it looks like we are going to have to subclass |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
420 * basically everything. Was hoping to add methods |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
421 * to the superclasses but it looks like you can |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
422 * only add methods and no variables, which isn't |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
423 * going to work. -Brian |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
424 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
425 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
426 /* Subclass for a box type */ |
717
17923b931393
Fixes for building for MacOS 10.5 and PPC
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
715
diff
changeset
|
427 @interface DWBox : NSView |
719
d5e49ef8f541
Updated the #if for Snow Leopard/Leopard builds to handle them not being defined properly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
718
diff
changeset
|
428 #ifdef BUILDING_FOR_SNOW_LEOPARD |
717
17923b931393
Fixes for building for MacOS 10.5 and PPC
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
715
diff
changeset
|
429 <NSWindowDelegate> |
17923b931393
Fixes for building for MacOS 10.5 and PPC
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
715
diff
changeset
|
430 #endif |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
431 { |
666
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
432 Box *box; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
433 void *userdata; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
434 NSColor *bgcolor; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
435 } |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
436 -(id)init; |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
437 -(void)dealloc; |
666
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
438 -(Box *)box; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
439 -(void *)userdata; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
440 -(void)setUserdata:(void *)input; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
441 -(void)drawRect:(NSRect)rect; |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
442 -(BOOL)isFlipped; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
443 -(void)mouseDown:(NSEvent *)theEvent; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
444 -(void)mouseUp:(NSEvent *)theEvent; |
701
c91a1b345f2e
Fix for button press and context menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
700
diff
changeset
|
445 -(NSMenu *)menuForEvent:(NSEvent *)theEvent; |
c91a1b345f2e
Fix for button press and context menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
700
diff
changeset
|
446 -(void)rightMouseUp:(NSEvent *)theEvent; |
c91a1b345f2e
Fix for button press and context menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
700
diff
changeset
|
447 -(void)otherMouseDown:(NSEvent *)theEvent; |
c91a1b345f2e
Fix for button press and context menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
700
diff
changeset
|
448 -(void)otherMouseUp:(NSEvent *)theEvent; |
723
37c8d2b4cec5
Initial key press event/signal handling... does not seem to trap on all controls...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
722
diff
changeset
|
449 -(void)keyDown:(NSEvent *)theEvent; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
450 -(void)setColor:(unsigned long)input; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
451 @end |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
452 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
453 @implementation DWBox |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
454 -(id)init |
666
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
455 { |
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
456 self = [super init]; |
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
457 |
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
458 if (self) |
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
459 { |
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
460 box = calloc(1, sizeof(Box)); |
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
461 } |
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
462 return self; |
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
463 } |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
464 -(void)dealloc |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
465 { |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
466 UserData *root = userdata; |
666
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
467 free(box); |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
468 _remove_userdata(&root, NULL, TRUE); |
666
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
469 [super dealloc]; |
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
470 } |
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
471 -(Box *)box { return box; } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
472 -(void *)userdata { return userdata; } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
473 -(void)setUserdata:(void *)input { userdata = input; } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
474 -(void)drawRect:(NSRect)rect |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
475 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
476 if(bgcolor) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
477 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
478 [bgcolor set]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
479 NSRectFill( [self bounds] ); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
480 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
481 } |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
482 -(BOOL)isFlipped { return YES; } |
701
c91a1b345f2e
Fix for button press and context menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
700
diff
changeset
|
483 -(void)mouseDown:(NSEvent *)theEvent { _event_handler(self, (void *)1, 3); } |
c91a1b345f2e
Fix for button press and context menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
700
diff
changeset
|
484 -(void)mouseUp:(NSEvent *)theEvent { _event_handler(self, (void *)1, 4); } |
c91a1b345f2e
Fix for button press and context menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
700
diff
changeset
|
485 -(NSMenu *)menuForEvent:(NSEvent *)theEvent { _event_handler(self, (void *)2, 3); return nil; } |
c91a1b345f2e
Fix for button press and context menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
700
diff
changeset
|
486 -(void)rightMouseUp:(NSEvent *)theEvent { _event_handler(self, (void *)2, 4); } |
c91a1b345f2e
Fix for button press and context menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
700
diff
changeset
|
487 -(void)otherMouseDown:(NSEvent *)theEvent { _event_handler(self, (void *)3, 3); } |
c91a1b345f2e
Fix for button press and context menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
700
diff
changeset
|
488 -(void)otherMouseUp:(NSEvent *)theEvent { _event_handler(self, (void *)3, 4); } |
723
37c8d2b4cec5
Initial key press event/signal handling... does not seem to trap on all controls...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
722
diff
changeset
|
489 -(void)keyDown:(NSEvent *)theEvent { _event_handler(self, theEvent, 2); _event_handler([self window], theEvent, 2); } |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
490 -(void)setColor:(unsigned long)input |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
491 { |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
492 if(input == _colors[DW_CLR_DEFAULT]) |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
493 { |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
494 bgcolor = nil; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
495 } |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
496 else |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
497 { |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
498 bgcolor = [NSColor colorWithDeviceRed: DW_RED_VALUE(input)/255.0 green: DW_GREEN_VALUE(input)/255.0 blue: DW_BLUE_VALUE(input)/255.0 alpha: 1]; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
499 } |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
500 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
501 @end |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
502 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
503 /* Subclass for a top-level window */ |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
504 @interface DWView : DWBox |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
505 { |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
506 NSMenu *windowmenu; |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
507 } |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
508 -(BOOL)windowShouldClose:(id)sender; |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
509 -(void)setMenu:(NSMenu *)input; |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
510 -(void)windowDidBecomeMain:(id)sender; |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
511 -(void)menuHandler:(id)sender; |
723
37c8d2b4cec5
Initial key press event/signal handling... does not seem to trap on all controls...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
722
diff
changeset
|
512 -(void)keyDown:(NSEvent *)theEvent; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
513 @end |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
514 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
515 @implementation DWView |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
516 -(BOOL)windowShouldClose:(id)sender |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
517 { |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
518 if(_event_handler(self, nil, 6) == FALSE) |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
519 return NO; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
520 return YES; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
521 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
522 - (void)viewDidMoveToWindow |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
523 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
524 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(windowResized:) name:NSWindowDidResizeNotification object:[self window]]; |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
525 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(windowDidBecomeMain:) name:NSWindowDidBecomeMainNotification object:[self window]]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
526 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
527 - (void)dealloc |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
528 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
529 [[NSNotificationCenter defaultCenter] removeObserver:self]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
530 [super dealloc]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
531 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
532 - (void)windowResized:(NSNotification *)notification; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
533 { |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
534 NSSize size = [self frame].size; |
666
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
535 _do_resize(box, size.width, size.height); |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
536 _event_handler([self window], nil, 1); |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
537 } |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
538 -(void)windowDidBecomeMain:(id)sender |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
539 { |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
540 if(windowmenu) |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
541 { |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
542 [DWApp setMainMenu:windowmenu]; |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
543 } |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
544 else |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
545 { |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
546 [DWApp setMainMenu:DWMainMenu]; |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
547 } |
703
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
548 _event_handler(self, nil, 13); |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
549 } |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
550 -(void)setMenu:(NSMenu *)input { windowmenu = input; } |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
551 -(void)menuHandler:(id)sender { _event_handler(sender, nil, 8); } |
723
37c8d2b4cec5
Initial key press event/signal handling... does not seem to trap on all controls...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
722
diff
changeset
|
552 -(void)keyDown:(NSEvent *)theEvent { _event_handler(self, theEvent, 2); _event_handler([self window], theEvent, 2); } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
553 @end |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
554 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
555 /* Subclass for a button type */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
556 @interface DWButton : NSButton |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
557 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
558 void *userdata; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
559 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
560 -(void *)userdata; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
561 -(void)setUserdata:(void *)input; |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
562 -(void)buttonClicked:(id)sender; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
563 @end |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
564 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
565 @implementation DWButton |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
566 -(void *)userdata { return userdata; } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
567 -(void)setUserdata:(void *)input { userdata = input; } |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
568 -(void)buttonClicked:(id)sender { _event_handler(self, nil, 8); } |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
569 -(void)dealloc { UserData *root = userdata; _remove_userdata(&root, NULL, TRUE); [super dealloc]; } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
570 @end |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
571 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
572 /* Subclass for a progress type */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
573 @interface DWPercent : NSProgressIndicator |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
574 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
575 void *userdata; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
576 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
577 -(void *)userdata; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
578 -(void)setUserdata:(void *)input; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
579 @end |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
580 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
581 @implementation DWPercent |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
582 -(void *)userdata { return userdata; } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
583 -(void)setUserdata:(void *)input { userdata = input; } |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
584 -(void)dealloc { UserData *root = userdata; _remove_userdata(&root, NULL, TRUE); [super dealloc]; } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
585 @end |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
586 |
651
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
587 /* Subclass for a entryfield type */ |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
588 @interface DWEntryField : NSTextField |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
589 { |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
590 void *userdata; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
591 } |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
592 -(void *)userdata; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
593 -(void)setUserdata:(void *)input; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
594 @end |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
595 |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
596 @implementation DWEntryField |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
597 -(void *)userdata { return userdata; } |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
598 -(void)setUserdata:(void *)input { userdata = input; } |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
599 -(void)dealloc { UserData *root = userdata; _remove_userdata(&root, NULL, TRUE); [super dealloc]; } |
651
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
600 @end |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
601 |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
602 /* Subclass for a entryfield password type */ |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
603 @interface DWEntryFieldPassword : NSSecureTextField |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
604 { |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
605 void *userdata; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
606 } |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
607 -(void *)userdata; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
608 -(void)setUserdata:(void *)input; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
609 @end |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
610 |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
611 @implementation DWEntryFieldPassword |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
612 -(void *)userdata { return userdata; } |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
613 -(void)setUserdata:(void *)input { userdata = input; } |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
614 -(void)dealloc { UserData *root = userdata; _remove_userdata(&root, NULL, TRUE); [super dealloc]; } |
651
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
615 @end |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
616 |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
617 /* Subclass for a Notebook control type */ |
717
17923b931393
Fixes for building for MacOS 10.5 and PPC
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
715
diff
changeset
|
618 @interface DWNotebook : NSTabView |
719
d5e49ef8f541
Updated the #if for Snow Leopard/Leopard builds to handle them not being defined properly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
718
diff
changeset
|
619 #ifdef BUILDING_FOR_SNOW_LEOPARD |
717
17923b931393
Fixes for building for MacOS 10.5 and PPC
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
715
diff
changeset
|
620 <NSTabViewDelegate> |
17923b931393
Fixes for building for MacOS 10.5 and PPC
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
715
diff
changeset
|
621 #endif |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
622 { |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
623 void *userdata; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
624 int pageid; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
625 } |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
626 -(void *)userdata; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
627 -(void)setUserdata:(void *)input; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
628 -(int)pageid; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
629 -(void)setPageid:(int)input; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
630 -(void)tabView:(NSTabView *)notebook didSelectTabViewItem:(NSTabViewItem *)notepage; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
631 @end |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
632 |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
633 /* Subclass for a Notebook page type */ |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
634 @interface DWNotebookPage : NSTabViewItem |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
635 { |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
636 void *userdata; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
637 int pageid; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
638 } |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
639 -(void *)userdata; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
640 -(void)setUserdata:(void *)input; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
641 -(int)pageid; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
642 -(void)setPageid:(int)input; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
643 @end |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
644 |
703
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
645 @implementation DWNotebook |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
646 -(void *)userdata { return userdata; } |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
647 -(void)setUserdata:(void *)input { userdata = input; } |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
648 -(int)pageid { return pageid; } |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
649 -(void)setPageid:(int)input { pageid = input; } |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
650 -(void)tabView:(NSTabView *)notebook didSelectTabViewItem:(NSTabViewItem *)notepage |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
651 { |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
652 id object = [notepage view]; |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
653 DWNotebookPage *page = (DWNotebookPage *)notepage; |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
654 |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
655 if([object isMemberOfClass:[DWBox class]]) |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
656 { |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
657 DWBox *view = object; |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
658 Box *box = [view box]; |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
659 NSSize size = [view frame].size; |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
660 _do_resize(box, size.width, size.height); |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
661 } |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
662 _event_handler(self, (void *)[page pageid], 15); |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
663 } |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
664 -(void)dealloc { UserData *root = userdata; _remove_userdata(&root, NULL, TRUE); [super dealloc]; } |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
665 @end |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
666 |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
667 @implementation DWNotebookPage |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
668 -(void *)userdata { return userdata; } |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
669 -(void)setUserdata:(void *)input { userdata = input; } |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
670 -(int)pageid { return pageid; } |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
671 -(void)setPageid:(int)input { pageid = input; } |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
672 -(void)dealloc { UserData *root = userdata; _remove_userdata(&root, NULL, TRUE); [super dealloc]; } |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
673 @end |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
674 |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
675 /* Subclass for a color chooser type */ |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
676 @interface DWColorChoose : NSColorPanel |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
677 { |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
678 DWDialog *dialog; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
679 } |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
680 -(void)changeColor:(id)sender; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
681 -(void)setDialog:(DWDialog *)input; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
682 @end |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
683 |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
684 @implementation DWColorChoose |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
685 - (void)changeColor:(id)sender |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
686 { |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
687 dw_dialog_dismiss(dialog, [self color]); |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
688 } |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
689 -(void)setDialog:(DWDialog *)input { dialog = input; } |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
690 @end |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
691 |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
692 /* Subclass for a splitbar type */ |
717
17923b931393
Fixes for building for MacOS 10.5 and PPC
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
715
diff
changeset
|
693 @interface DWSplitBar : NSSplitView |
719
d5e49ef8f541
Updated the #if for Snow Leopard/Leopard builds to handle them not being defined properly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
718
diff
changeset
|
694 #ifdef BUILDING_FOR_SNOW_LEOPARD |
717
17923b931393
Fixes for building for MacOS 10.5 and PPC
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
715
diff
changeset
|
695 <NSSplitViewDelegate> |
17923b931393
Fixes for building for MacOS 10.5 and PPC
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
715
diff
changeset
|
696 #endif |
677
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
697 { |
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
698 void *userdata; |
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
699 float percent; |
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
700 } |
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
701 -(void)splitViewDidResizeSubviews:(NSNotification *)aNotification; |
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
702 -(void *)userdata; |
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
703 -(void)setUserdata:(void *)input; |
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
704 -(float)percent; |
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
705 -(void)setPercent:(float)input; |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
706 @end |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
707 |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
708 @implementation DWSplitBar |
677
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
709 -(void)splitViewDidResizeSubviews:(NSNotification *)aNotification |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
710 { |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
711 NSArray *views = [self subviews]; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
712 id object; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
713 |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
714 for(object in views) |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
715 { |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
716 if([object isMemberOfClass:[DWBox class]]) |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
717 { |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
718 DWBox *view = object; |
666
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
719 Box *box = [view box]; |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
720 NSSize size = [view frame].size; |
666
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
721 _do_resize(box, size.width, size.height); |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
722 } |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
723 } |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
724 } |
677
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
725 -(void *)userdata { return userdata; } |
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
726 -(void)setUserdata:(void *)input { userdata = input; } |
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
727 -(float)percent { return percent; } |
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
728 -(void)setPercent:(float)input { percent = input; } |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
729 -(void)dealloc { UserData *root = userdata; _remove_userdata(&root, NULL, TRUE); [super dealloc]; } |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
730 @end |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
731 |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
732 /* Subclass for a slider type */ |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
733 @interface DWSlider : NSSlider |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
734 { |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
735 void *userdata; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
736 } |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
737 -(void *)userdata; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
738 -(void)setUserdata:(void *)input; |
704
336800e9e648
Fixes to the slider control so events happen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
703
diff
changeset
|
739 -(void)sliderChanged:(id)sender; |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
740 @end |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
741 |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
742 @implementation DWSlider |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
743 -(void *)userdata { return userdata; } |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
744 -(void)setUserdata:(void *)input { userdata = input; } |
705
7087f3a294e5
Spinbuttons now respond to value changed. Fix for typing in spinbutton a value out of the range.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
704
diff
changeset
|
745 -(void)sliderChanged:(id)sender { _event_handler(self, (void *)[self integerValue], 14); } |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
746 -(void)dealloc { UserData *root = userdata; _remove_userdata(&root, NULL, TRUE); [super dealloc]; } |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
747 @end |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
748 |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
749 /* Subclass for a slider type */ |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
750 @interface DWScrollbar : NSScroller |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
751 { |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
752 void *userdata; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
753 float range; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
754 float visible; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
755 } |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
756 -(void *)userdata; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
757 -(void)setUserdata:(void *)input; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
758 -(float)range; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
759 -(float)visible; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
760 -(void)setRange:(float)input1 andVisible:(float)input2; |
705
7087f3a294e5
Spinbuttons now respond to value changed. Fix for typing in spinbutton a value out of the range.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
704
diff
changeset
|
761 -(void)scrollerChanged:(id)sender; |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
762 @end |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
763 |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
764 @implementation DWScrollbar |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
765 -(void *)userdata { return userdata; } |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
766 -(void)setUserdata:(void *)input { userdata = input; } |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
767 -(float)range { return range; } |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
768 -(float)visible { return visible; } |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
769 -(void)setRange:(float)input1 andVisible:(float)input2 { range = input1; visible = input2; } |
707
86d76fc09237
Added support for scrollbar line and page scrolling. Need to check the calculations...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
706
diff
changeset
|
770 -(void)scrollerChanged:(id)sender |
86d76fc09237
Added support for scrollbar line and page scrolling. Need to check the calculations...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
706
diff
changeset
|
771 { |
86d76fc09237
Added support for scrollbar line and page scrolling. Need to check the calculations...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
706
diff
changeset
|
772 double proportion = [self knobProportion]; |
712
01107d8e033e
Fixed the scrollbar maximum range to be correct. Also added some MLE code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
711
diff
changeset
|
773 int page = (int)(proportion * range); |
01107d8e033e
Fixed the scrollbar maximum range to be correct. Also added some MLE code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
711
diff
changeset
|
774 int max = (int)(range - page); |
01107d8e033e
Fixed the scrollbar maximum range to be correct. Also added some MLE code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
711
diff
changeset
|
775 int result = (int)([self doubleValue] * max); |
707
86d76fc09237
Added support for scrollbar line and page scrolling. Need to check the calculations...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
706
diff
changeset
|
776 int newpos = result; |
86d76fc09237
Added support for scrollbar line and page scrolling. Need to check the calculations...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
706
diff
changeset
|
777 |
86d76fc09237
Added support for scrollbar line and page scrolling. Need to check the calculations...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
706
diff
changeset
|
778 switch ([sender hitPart]) |
86d76fc09237
Added support for scrollbar line and page scrolling. Need to check the calculations...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
706
diff
changeset
|
779 { |
86d76fc09237
Added support for scrollbar line and page scrolling. Need to check the calculations...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
706
diff
changeset
|
780 |
86d76fc09237
Added support for scrollbar line and page scrolling. Need to check the calculations...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
706
diff
changeset
|
781 case NSScrollerDecrementLine: |
86d76fc09237
Added support for scrollbar line and page scrolling. Need to check the calculations...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
706
diff
changeset
|
782 if(newpos > 0) |
86d76fc09237
Added support for scrollbar line and page scrolling. Need to check the calculations...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
706
diff
changeset
|
783 { |
86d76fc09237
Added support for scrollbar line and page scrolling. Need to check the calculations...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
706
diff
changeset
|
784 newpos--; |
86d76fc09237
Added support for scrollbar line and page scrolling. Need to check the calculations...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
706
diff
changeset
|
785 } |
86d76fc09237
Added support for scrollbar line and page scrolling. Need to check the calculations...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
706
diff
changeset
|
786 break; |
86d76fc09237
Added support for scrollbar line and page scrolling. Need to check the calculations...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
706
diff
changeset
|
787 |
86d76fc09237
Added support for scrollbar line and page scrolling. Need to check the calculations...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
706
diff
changeset
|
788 case NSScrollerIncrementLine: |
712
01107d8e033e
Fixed the scrollbar maximum range to be correct. Also added some MLE code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
711
diff
changeset
|
789 if(newpos < max) |
707
86d76fc09237
Added support for scrollbar line and page scrolling. Need to check the calculations...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
706
diff
changeset
|
790 { |
86d76fc09237
Added support for scrollbar line and page scrolling. Need to check the calculations...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
706
diff
changeset
|
791 newpos++; |
86d76fc09237
Added support for scrollbar line and page scrolling. Need to check the calculations...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
706
diff
changeset
|
792 } |
86d76fc09237
Added support for scrollbar line and page scrolling. Need to check the calculations...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
706
diff
changeset
|
793 break; |
86d76fc09237
Added support for scrollbar line and page scrolling. Need to check the calculations...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
706
diff
changeset
|
794 |
86d76fc09237
Added support for scrollbar line and page scrolling. Need to check the calculations...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
706
diff
changeset
|
795 case NSScrollerDecrementPage: |
86d76fc09237
Added support for scrollbar line and page scrolling. Need to check the calculations...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
706
diff
changeset
|
796 newpos -= page; |
86d76fc09237
Added support for scrollbar line and page scrolling. Need to check the calculations...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
706
diff
changeset
|
797 if(newpos < 0) |
86d76fc09237
Added support for scrollbar line and page scrolling. Need to check the calculations...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
706
diff
changeset
|
798 { |
86d76fc09237
Added support for scrollbar line and page scrolling. Need to check the calculations...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
706
diff
changeset
|
799 newpos = 0; |
86d76fc09237
Added support for scrollbar line and page scrolling. Need to check the calculations...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
706
diff
changeset
|
800 } |
86d76fc09237
Added support for scrollbar line and page scrolling. Need to check the calculations...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
706
diff
changeset
|
801 break; |
86d76fc09237
Added support for scrollbar line and page scrolling. Need to check the calculations...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
706
diff
changeset
|
802 |
86d76fc09237
Added support for scrollbar line and page scrolling. Need to check the calculations...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
706
diff
changeset
|
803 case NSScrollerIncrementPage: |
86d76fc09237
Added support for scrollbar line and page scrolling. Need to check the calculations...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
706
diff
changeset
|
804 newpos += page; |
712
01107d8e033e
Fixed the scrollbar maximum range to be correct. Also added some MLE code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
711
diff
changeset
|
805 if(newpos > max) |
707
86d76fc09237
Added support for scrollbar line and page scrolling. Need to check the calculations...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
706
diff
changeset
|
806 { |
712
01107d8e033e
Fixed the scrollbar maximum range to be correct. Also added some MLE code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
711
diff
changeset
|
807 newpos = max; |
707
86d76fc09237
Added support for scrollbar line and page scrolling. Need to check the calculations...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
706
diff
changeset
|
808 } |
86d76fc09237
Added support for scrollbar line and page scrolling. Need to check the calculations...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
706
diff
changeset
|
809 break; |
86d76fc09237
Added support for scrollbar line and page scrolling. Need to check the calculations...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
706
diff
changeset
|
810 |
86d76fc09237
Added support for scrollbar line and page scrolling. Need to check the calculations...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
706
diff
changeset
|
811 default: |
86d76fc09237
Added support for scrollbar line and page scrolling. Need to check the calculations...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
706
diff
changeset
|
812 ; // do nothing |
86d76fc09237
Added support for scrollbar line and page scrolling. Need to check the calculations...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
706
diff
changeset
|
813 } |
86d76fc09237
Added support for scrollbar line and page scrolling. Need to check the calculations...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
706
diff
changeset
|
814 if(newpos != result) |
86d76fc09237
Added support for scrollbar line and page scrolling. Need to check the calculations...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
706
diff
changeset
|
815 { |
712
01107d8e033e
Fixed the scrollbar maximum range to be correct. Also added some MLE code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
711
diff
changeset
|
816 double newposd = (double)newpos/max; |
707
86d76fc09237
Added support for scrollbar line and page scrolling. Need to check the calculations...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
706
diff
changeset
|
817 [self setDoubleValue:newposd]; |
86d76fc09237
Added support for scrollbar line and page scrolling. Need to check the calculations...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
706
diff
changeset
|
818 } |
86d76fc09237
Added support for scrollbar line and page scrolling. Need to check the calculations...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
706
diff
changeset
|
819 _event_handler(self, (void *)newpos, 14); |
86d76fc09237
Added support for scrollbar line and page scrolling. Need to check the calculations...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
706
diff
changeset
|
820 } |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
821 -(void)dealloc { UserData *root = userdata; _remove_userdata(&root, NULL, TRUE); [super dealloc]; } |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
822 @end |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
823 |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
824 /* Subclass for a render area type */ |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
825 @interface DWRender : NSView |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
826 { |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
827 void *userdata; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
828 } |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
829 -(void *)userdata; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
830 -(void)setUserdata:(void *)input; |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
831 -(void)mouseDown:(NSEvent *)theEvent; |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
832 -(void)mouseUp:(NSEvent *)theEvent; |
701
c91a1b345f2e
Fix for button press and context menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
700
diff
changeset
|
833 -(NSMenu *)menuForEvent:(NSEvent *)theEvent; |
c91a1b345f2e
Fix for button press and context menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
700
diff
changeset
|
834 -(void)rightMouseUp:(NSEvent *)theEvent; |
c91a1b345f2e
Fix for button press and context menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
700
diff
changeset
|
835 -(void)otherMouseDown:(NSEvent *)theEvent; |
c91a1b345f2e
Fix for button press and context menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
700
diff
changeset
|
836 -(void)otherMouseUp:(NSEvent *)theEvent; |
c91a1b345f2e
Fix for button press and context menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
700
diff
changeset
|
837 -(void)drawRect:(NSRect)rect; |
723
37c8d2b4cec5
Initial key press event/signal handling... does not seem to trap on all controls...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
722
diff
changeset
|
838 -(void)keyDown:(NSEvent *)theEvent; |
664
ba3af8eb56f1
Fixed drawing of rects and points. Fonts now properly draw in color. Updated property list.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
662
diff
changeset
|
839 -(BOOL)isFlipped; |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
840 @end |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
841 |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
842 @implementation DWRender |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
843 -(void *)userdata { return userdata; } |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
844 -(void)setUserdata:(void *)input { userdata = input; } |
701
c91a1b345f2e
Fix for button press and context menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
700
diff
changeset
|
845 -(void)mouseDown:(NSEvent *)theEvent { _event_handler(self, (void *)1, 3); } |
c91a1b345f2e
Fix for button press and context menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
700
diff
changeset
|
846 -(void)mouseUp:(NSEvent *)theEvent { _event_handler(self, (void *)1, 4); } |
c91a1b345f2e
Fix for button press and context menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
700
diff
changeset
|
847 -(NSMenu *)menuForEvent:(NSEvent *)theEvent { _event_handler(self, (void *)2, 3); return nil; } |
c91a1b345f2e
Fix for button press and context menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
700
diff
changeset
|
848 -(void)rightMouseUp:(NSEvent *)theEvent { _event_handler(self, (void *)2, 4); } |
c91a1b345f2e
Fix for button press and context menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
700
diff
changeset
|
849 -(void)otherMouseDown:(NSEvent *)theEvent { _event_handler(self, (void *)3, 3); } |
c91a1b345f2e
Fix for button press and context menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
700
diff
changeset
|
850 -(void)otherMouseUp:(NSEvent *)theEvent { _event_handler(self, (void *)3, 4); } |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
851 -(void)drawRect:(NSRect)rect { _event_handler(self, nil, 7); } |
723
37c8d2b4cec5
Initial key press event/signal handling... does not seem to trap on all controls...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
722
diff
changeset
|
852 -(void)keyDown:(NSEvent *)theEvent { _event_handler(self, theEvent, 2); _event_handler([self window], theEvent, 2); } |
664
ba3af8eb56f1
Fixed drawing of rects and points. Fonts now properly draw in color. Updated property list.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
662
diff
changeset
|
853 -(BOOL)isFlipped { return NO; } |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
854 -(void)dealloc { UserData *root = userdata; _remove_userdata(&root, NULL, TRUE); [super dealloc]; } |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
855 @end |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
856 |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
857 /* Subclass for a MLE type */ |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
858 @interface DWMLE : NSTextView |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
859 { |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
860 void *userdata; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
861 } |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
862 -(void *)userdata; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
863 -(void)setUserdata:(void *)input; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
864 @end |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
865 |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
866 @implementation DWMLE |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
867 -(void *)userdata { return userdata; } |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
868 -(void)setUserdata:(void *)input { userdata = input; } |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
869 -(void)dealloc { UserData *root = userdata; _remove_userdata(&root, NULL, TRUE); [super dealloc]; } |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
870 @end |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
871 |
655
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
872 /* Subclass for a Container/List type */ |
717
17923b931393
Fixes for building for MacOS 10.5 and PPC
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
715
diff
changeset
|
873 @interface DWContainer : NSTableView |
719
d5e49ef8f541
Updated the #if for Snow Leopard/Leopard builds to handle them not being defined properly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
718
diff
changeset
|
874 #ifdef BUILDING_FOR_SNOW_LEOPARD |
717
17923b931393
Fixes for building for MacOS 10.5 and PPC
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
715
diff
changeset
|
875 <NSTableViewDataSource> |
17923b931393
Fixes for building for MacOS 10.5 and PPC
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
715
diff
changeset
|
876 #endif |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
877 { |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
878 void *userdata; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
879 NSMutableArray *tvcols; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
880 NSMutableArray *data; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
881 NSMutableArray *types; |
659
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
882 NSPointerArray *titles; |
675
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
883 int lastAddPoint, lastQueryPoint; |
668
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
884 id scrollview; |
658
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
885 } |
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
886 -(NSInteger)numberOfRowsInTableView:(NSTableView *)aTable; |
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
887 -(id)tableView:(NSTableView *)aTable objectValueForTableColumn:(NSTableColumn *)aCol row:(NSInteger)aRow; |
708
5fe2ca5ef88b
Fixes for container event handling. Also made container/listbox cells non-editable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
707
diff
changeset
|
888 -(BOOL)tableView:(NSTableView *)aTableView shouldEditTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex; |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
889 -(void *)userdata; |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
890 -(void)setUserdata:(void *)input; |
668
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
891 -(id)scrollview; |
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
892 -(void)setScrollview:(id)input; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
893 -(void)addColumn:(NSTableColumn *)input andType:(int)type; |
675
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
894 -(NSTableColumn *)getColumn:(int)col; |
658
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
895 -(int)addRow:(NSArray *)input; |
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
896 -(int)addRows:(int)number; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
897 -(void)editCell:(id)input at:(int)row and:(int)col; |
662
d7badd5606ca
Removed the Carbon source file, and changes to configure to build the Cocoa version.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
661
diff
changeset
|
898 -(void)removeRow:(int)row; |
659
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
899 -(void)setRow:(int)row title:(void *)input; |
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
900 -(void *)getRowTitle:(int)row; |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
901 -(id)getRow:(int)row and:(int)col; |
662
d7badd5606ca
Removed the Carbon source file, and changes to configure to build the Cocoa version.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
661
diff
changeset
|
902 -(int)cellType:(int)col; |
658
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
903 -(int)lastAddPoint; |
675
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
904 -(int)lastQueryPoint; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
905 -(void)setLastQueryPoint:(int)input; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
906 -(void)clear; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
907 -(void)setup; |
708
5fe2ca5ef88b
Fixes for container event handling. Also made container/listbox cells non-editable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
707
diff
changeset
|
908 -(void)doubleClicked:(id)sender; |
659
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
909 -(void)selectionChanged:(id)sender; |
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
910 -(NSMenu *)menuForEvent:(NSEvent *)event; |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
911 @end |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
912 |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
913 @implementation DWContainer |
658
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
914 -(NSInteger)numberOfRowsInTableView:(NSTableView *)aTable |
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
915 { |
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
916 if(tvcols && data) |
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
917 { |
665
e6bec2290f3f
Fixing warnings with Xcode 4 and switched to manual releasing in the draw functions to stop leaking.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
664
diff
changeset
|
918 int cols = (int)[tvcols count]; |
658
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
919 if(cols) |
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
920 { |
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
921 return [data count] / cols; |
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
922 } |
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
923 } |
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
924 return 0; |
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
925 } |
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
926 -(id)tableView:(NSTableView *)aTable objectValueForTableColumn:(NSTableColumn *)aCol row:(NSInteger)aRow |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
927 { |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
928 if(tvcols) |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
929 { |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
930 int z, col = -1; |
665
e6bec2290f3f
Fixing warnings with Xcode 4 and switched to manual releasing in the draw functions to stop leaking.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
664
diff
changeset
|
931 int count = (int)[tvcols count]; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
932 |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
933 for(z=0;z<count;z++) |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
934 { |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
935 if([tvcols objectAtIndex:z] == aCol) |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
936 { |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
937 col = z; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
938 break; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
939 } |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
940 } |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
941 if(col != -1) |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
942 { |
665
e6bec2290f3f
Fixing warnings with Xcode 4 and switched to manual releasing in the draw functions to stop leaking.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
664
diff
changeset
|
943 int index = (int)(aRow * count) + col; |
659
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
944 id this = [data objectAtIndex:index]; |
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
945 return ([this isKindOfClass:[NSNull class]]) ? nil : this; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
946 } |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
947 } |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
948 return nil; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
949 } |
708
5fe2ca5ef88b
Fixes for container event handling. Also made container/listbox cells non-editable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
707
diff
changeset
|
950 -(BOOL)tableView:(NSTableView *)aTableView shouldEditTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex { return NO; } |
658
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
951 -(void *)userdata { return userdata; } |
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
952 -(void)setUserdata:(void *)input { userdata = input; } |
717
17923b931393
Fixes for building for MacOS 10.5 and PPC
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
715
diff
changeset
|
953 -(id)scrollview { return scrollview; } |
17923b931393
Fixes for building for MacOS 10.5 and PPC
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
715
diff
changeset
|
954 -(void)setScrollview:(id)input { scrollview = input; } |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
955 -(void)addColumn:(NSTableColumn *)input andType:(int)type { if(tvcols) { [tvcols addObject:input]; [types addObject:[NSNumber numberWithInt:type]]; } } |
675
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
956 -(NSTableColumn *)getColumn:(int)col { if(tvcols) { return [tvcols objectAtIndex:col]; } return nil; } |
687
5dde8d34bc69
Implemented dw_listbox_insert for containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
686
diff
changeset
|
957 -(int)insertRow:(NSArray *)input at:(int)index |
5dde8d34bc69
Implemented dw_listbox_insert for containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
686
diff
changeset
|
958 { |
5dde8d34bc69
Implemented dw_listbox_insert for containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
686
diff
changeset
|
959 if(data) |
5dde8d34bc69
Implemented dw_listbox_insert for containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
686
diff
changeset
|
960 { |
5dde8d34bc69
Implemented dw_listbox_insert for containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
686
diff
changeset
|
961 unsigned long start = [tvcols count] * index; |
5dde8d34bc69
Implemented dw_listbox_insert for containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
686
diff
changeset
|
962 NSIndexSet *set = [[NSIndexSet alloc] initWithIndexesInRange:NSMakeRange(start, start + [tvcols count])]; |
5dde8d34bc69
Implemented dw_listbox_insert for containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
686
diff
changeset
|
963 if(index < lastAddPoint) |
5dde8d34bc69
Implemented dw_listbox_insert for containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
686
diff
changeset
|
964 { |
5dde8d34bc69
Implemented dw_listbox_insert for containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
686
diff
changeset
|
965 lastAddPoint++; |
5dde8d34bc69
Implemented dw_listbox_insert for containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
686
diff
changeset
|
966 } |
5dde8d34bc69
Implemented dw_listbox_insert for containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
686
diff
changeset
|
967 [data insertObjects:input atIndexes:set]; |
5dde8d34bc69
Implemented dw_listbox_insert for containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
686
diff
changeset
|
968 [titles insertPointer:NULL atIndex:index]; |
5dde8d34bc69
Implemented dw_listbox_insert for containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
686
diff
changeset
|
969 [set release]; |
5dde8d34bc69
Implemented dw_listbox_insert for containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
686
diff
changeset
|
970 return (int)[titles count]; |
5dde8d34bc69
Implemented dw_listbox_insert for containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
686
diff
changeset
|
971 } |
5dde8d34bc69
Implemented dw_listbox_insert for containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
686
diff
changeset
|
972 return 0; |
5dde8d34bc69
Implemented dw_listbox_insert for containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
686
diff
changeset
|
973 } |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
974 -(int)addRow:(NSArray *)input |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
975 { |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
976 if(data) |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
977 { |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
978 lastAddPoint = (int)[titles count]; |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
979 [data addObjectsFromArray:input]; |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
980 [titles addPointer:NULL]; |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
981 return (int)[titles count]; |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
982 } |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
983 return 0; |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
984 } |
658
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
985 -(int)addRows:(int)number |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
986 { |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
987 if(tvcols) |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
988 { |
675
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
989 int count = (int)(number * [tvcols count]); |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
990 int z; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
991 |
665
e6bec2290f3f
Fixing warnings with Xcode 4 and switched to manual releasing in the draw functions to stop leaking.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
664
diff
changeset
|
992 lastAddPoint = (int)[titles count]; |
658
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
993 |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
994 for(z=0;z<count;z++) |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
995 { |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
996 [data addObject:[NSNull null]]; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
997 } |
658
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
998 for(z=0;z<number;z++) |
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
999 { |
659
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
1000 [titles addPointer:NULL]; |
658
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
1001 } |
665
e6bec2290f3f
Fixing warnings with Xcode 4 and switched to manual releasing in the draw functions to stop leaking.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
664
diff
changeset
|
1002 return (int)[titles count]; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
1003 } |
658
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
1004 return 0; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
1005 } |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
1006 -(void)editCell:(id)input at:(int)row and:(int)col |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
1007 { |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
1008 if(tvcols && input) |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
1009 { |
665
e6bec2290f3f
Fixing warnings with Xcode 4 and switched to manual releasing in the draw functions to stop leaking.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
664
diff
changeset
|
1010 int index = (int)(row * [tvcols count]) + col; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
1011 [data replaceObjectAtIndex:index withObject:input]; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
1012 } |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
1013 } |
662
d7badd5606ca
Removed the Carbon source file, and changes to configure to build the Cocoa version.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
661
diff
changeset
|
1014 -(void)removeRow:(int)row |
d7badd5606ca
Removed the Carbon source file, and changes to configure to build the Cocoa version.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
661
diff
changeset
|
1015 { |
d7badd5606ca
Removed the Carbon source file, and changes to configure to build the Cocoa version.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
661
diff
changeset
|
1016 if(tvcols) |
d7badd5606ca
Removed the Carbon source file, and changes to configure to build the Cocoa version.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
661
diff
changeset
|
1017 { |
d7badd5606ca
Removed the Carbon source file, and changes to configure to build the Cocoa version.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
661
diff
changeset
|
1018 int z, start, end; |
665
e6bec2290f3f
Fixing warnings with Xcode 4 and switched to manual releasing in the draw functions to stop leaking.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
664
diff
changeset
|
1019 int count = (int)[tvcols count]; |
662
d7badd5606ca
Removed the Carbon source file, and changes to configure to build the Cocoa version.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
661
diff
changeset
|
1020 |
d7badd5606ca
Removed the Carbon source file, and changes to configure to build the Cocoa version.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
661
diff
changeset
|
1021 start = count * row; |
d7badd5606ca
Removed the Carbon source file, and changes to configure to build the Cocoa version.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
661
diff
changeset
|
1022 end = start + count; |
d7badd5606ca
Removed the Carbon source file, and changes to configure to build the Cocoa version.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
661
diff
changeset
|
1023 |
d7badd5606ca
Removed the Carbon source file, and changes to configure to build the Cocoa version.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
661
diff
changeset
|
1024 for(z=start;z<end;z++) |
d7badd5606ca
Removed the Carbon source file, and changes to configure to build the Cocoa version.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
661
diff
changeset
|
1025 { |
d7badd5606ca
Removed the Carbon source file, and changes to configure to build the Cocoa version.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
661
diff
changeset
|
1026 [data removeObjectAtIndex:z]; |
d7badd5606ca
Removed the Carbon source file, and changes to configure to build the Cocoa version.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
661
diff
changeset
|
1027 } |
d7badd5606ca
Removed the Carbon source file, and changes to configure to build the Cocoa version.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
661
diff
changeset
|
1028 [titles removePointerAtIndex:row]; |
d7badd5606ca
Removed the Carbon source file, and changes to configure to build the Cocoa version.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
661
diff
changeset
|
1029 if(lastAddPoint > 0 && lastAddPoint < row) |
d7badd5606ca
Removed the Carbon source file, and changes to configure to build the Cocoa version.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
661
diff
changeset
|
1030 { |
d7badd5606ca
Removed the Carbon source file, and changes to configure to build the Cocoa version.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
661
diff
changeset
|
1031 lastAddPoint--; |
d7badd5606ca
Removed the Carbon source file, and changes to configure to build the Cocoa version.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
661
diff
changeset
|
1032 } |
d7badd5606ca
Removed the Carbon source file, and changes to configure to build the Cocoa version.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
661
diff
changeset
|
1033 } |
d7badd5606ca
Removed the Carbon source file, and changes to configure to build the Cocoa version.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
661
diff
changeset
|
1034 } |
659
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
1035 -(void)setRow:(int)row title:(void *)input { if(titles && input) { [titles replacePointerAtIndex:row withPointer:input]; } } |
683
7385011c3327
Fixed a minor issue causing crashes when right clicking on an empty container.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
682
diff
changeset
|
1036 -(void *)getRowTitle:(int)row { if(titles && row > -1) { return [titles pointerAtIndex:row]; } return NULL; } |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
1037 -(id)getRow:(int)row and:(int)col { if(data) { int index = (int)(row * [tvcols count]) + col; return [data objectAtIndex:index]; } return nil; } |
662
d7badd5606ca
Removed the Carbon source file, and changes to configure to build the Cocoa version.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
661
diff
changeset
|
1038 -(int)cellType:(int)col { return [[types objectAtIndex:col] intValue]; } |
658
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
1039 -(int)lastAddPoint { return lastAddPoint; } |
675
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
1040 -(int)lastQueryPoint { return lastQueryPoint; } |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
1041 -(void)setLastQueryPoint:(int)input { lastQueryPoint = input; } |
659
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
1042 -(void)clear { if(data) { [data removeAllObjects]; while([titles count]) { [titles removePointerAtIndex:0]; } } lastAddPoint = 0; } |
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
1043 -(void)setup |
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
1044 { |
692
bd909322f40d
Added "retain"s to the DWTree/DWContainer/DWListBox classes memory allocation
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
691
diff
changeset
|
1045 tvcols = [[[NSMutableArray alloc] init] retain]; |
bd909322f40d
Added "retain"s to the DWTree/DWContainer/DWListBox classes memory allocation
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
691
diff
changeset
|
1046 data = [[[NSMutableArray alloc] init] retain]; |
bd909322f40d
Added "retain"s to the DWTree/DWContainer/DWListBox classes memory allocation
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
691
diff
changeset
|
1047 types = [[[NSMutableArray alloc] init] retain]; |
bd909322f40d
Added "retain"s to the DWTree/DWContainer/DWListBox classes memory allocation
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
691
diff
changeset
|
1048 titles = [[NSPointerArray pointerArrayWithWeakObjects] retain]; |
659
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
1049 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(selectionChanged:) name:NSTableViewSelectionDidChangeNotification object:[self window]]; |
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
1050 } |
708
5fe2ca5ef88b
Fixes for container event handling. Also made container/listbox cells non-editable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
707
diff
changeset
|
1051 -(void)doubleClicked:(id)sender |
5fe2ca5ef88b
Fixes for container event handling. Also made container/listbox cells non-editable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
707
diff
changeset
|
1052 { |
5fe2ca5ef88b
Fixes for container event handling. Also made container/listbox cells non-editable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
707
diff
changeset
|
1053 /* Handler for container class */ |
5fe2ca5ef88b
Fixes for container event handling. Also made container/listbox cells non-editable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
707
diff
changeset
|
1054 _event_handler(self, (NSEvent *)[self getRowTitle:(int)[self selectedRow]], 9); |
5fe2ca5ef88b
Fixes for container event handling. Also made container/listbox cells non-editable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
707
diff
changeset
|
1055 } |
659
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
1056 -(void)selectionChanged:(id)sender |
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
1057 { |
703
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
1058 /* Handler for container class */ |
708
5fe2ca5ef88b
Fixes for container event handling. Also made container/listbox cells non-editable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
707
diff
changeset
|
1059 _event_handler(self, (NSEvent *)[self getRowTitle:(int)[self selectedRow]], 12); |
703
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
1060 /* Handler for listbox class */ |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
1061 _event_handler(self, (NSEvent *)(int)[self selectedRow], 11); |
659
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
1062 } |
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
1063 -(NSMenu *)menuForEvent:(NSEvent *)event |
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
1064 { |
710
78460ff977c1
Finishing up tree event/signal handlers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
709
diff
changeset
|
1065 int row; |
78460ff977c1
Finishing up tree event/signal handlers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
709
diff
changeset
|
1066 NSPoint where = [self convertPoint:[event locationInWindow] fromView:nil]; |
78460ff977c1
Finishing up tree event/signal handlers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
709
diff
changeset
|
1067 row = (int)[self rowAtPoint:where]; |
78460ff977c1
Finishing up tree event/signal handlers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
709
diff
changeset
|
1068 _event_handler(self, (NSEvent *)[self getRowTitle:row], 10); |
78460ff977c1
Finishing up tree event/signal handlers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
709
diff
changeset
|
1069 return nil; |
659
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
1070 } |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1071 -(void)dealloc { UserData *root = userdata; _remove_userdata(&root, NULL, TRUE); [super dealloc]; } |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
1072 @end |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1073 |
682
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
1074 /* Dive into the tree showing all nodes */ |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
1075 void _free_tree_recurse(NSMutableArray *node, NSPointerArray *item) |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
1076 { |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
1077 if(node) |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
1078 { |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
1079 int count = (int)[node count]; |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
1080 int z; |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
1081 |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
1082 for(z=0;z<count;z++) |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
1083 { |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
1084 NSPointerArray *pnt = [node objectAtIndex:z]; |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
1085 NSMutableArray *children = (NSMutableArray *)[pnt pointerAtIndex:3]; |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
1086 |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
1087 if(children) |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
1088 { |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
1089 if(item == pnt) |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
1090 { |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
1091 _free_tree_recurse(children, NULL); |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
1092 } |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
1093 else |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
1094 { |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
1095 _free_tree_recurse(children, item); |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
1096 } |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
1097 } |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
1098 } |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
1099 } |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
1100 if(!item) |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
1101 { |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
1102 [node release]; |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
1103 } |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
1104 } |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
1105 |
680
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1106 /* Subclass for a Tree type */ |
717
17923b931393
Fixes for building for MacOS 10.5 and PPC
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
715
diff
changeset
|
1107 @interface DWTree : NSOutlineView |
719
d5e49ef8f541
Updated the #if for Snow Leopard/Leopard builds to handle them not being defined properly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
718
diff
changeset
|
1108 #ifdef BUILDING_FOR_SNOW_LEOPARD |
717
17923b931393
Fixes for building for MacOS 10.5 and PPC
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
715
diff
changeset
|
1109 <NSOutlineViewDataSource> |
17923b931393
Fixes for building for MacOS 10.5 and PPC
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
715
diff
changeset
|
1110 #endif |
680
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1111 { |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1112 void *userdata; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1113 NSTableColumn *imagecol; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1114 NSTableColumn *textcol; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1115 NSMutableArray *data; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1116 /* Each data item consists of a linked lists of tree item data. |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1117 * NSImage *, NSString *, Item Data *, NSMutableArray * of Children |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1118 */ |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1119 id scrollview; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1120 } |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1121 -(id)outlineView:(NSOutlineView *)outlineView child:(int)index ofItem:(id)item; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1122 -(BOOL)outlineView:(NSOutlineView *)outlineView isItemExpandable:(id)item; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1123 -(int)outlineView:(NSOutlineView *)outlineView numberOfChildrenOfItem:(id)item; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1124 -(id)outlineView:(NSOutlineView *)outlineView objectValueForTableColumn:(NSTableColumn *)tableColumn byItem:(id)item; |
710
78460ff977c1
Finishing up tree event/signal handlers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
709
diff
changeset
|
1125 -(BOOL)outlineView:(NSOutlineView *)outlineView shouldEditTableColumn:(NSTableColumn *)tableColumn item:(id)item; |
680
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1126 -(void)addTree:(NSPointerArray *)item and:(NSPointerArray *)parent; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1127 -(void *)userdata; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1128 -(void)setUserdata:(void *)input; |
709
5a268d5f1cfa
Fixes for tree event handling. Still more to come shortly...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
708
diff
changeset
|
1129 -(void)treeSelectionChanged:(id)sender; |
722
5a8d5161651d
Implemented tree expand event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
721
diff
changeset
|
1130 -(void)treeItemExpanded:(NSNotification *)notification; |
680
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1131 -(NSScrollView *)scrollview; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1132 -(void)setScrollview:(NSScrollView *)input; |
682
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
1133 -(void)deleteNode:(NSPointerArray *)item; |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
1134 -(void)clear; |
680
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1135 @end |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1136 |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1137 @implementation DWTree |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1138 -(id)init |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1139 { |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1140 self = [super init]; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1141 |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1142 if (self) |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1143 { |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1144 imagecol = [[NSTableColumn alloc] init]; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1145 NSImageCell *imagecell = [[[NSImageCell alloc] init] autorelease]; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1146 [imagecol setDataCell:imagecell]; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1147 [imagecol setResizingMask:NSTableColumnNoResizing]; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1148 [imagecol setWidth:20]; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1149 [self addTableColumn:imagecol]; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1150 textcol = [[NSTableColumn alloc] init]; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1151 [self addTableColumn:textcol]; |
682
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
1152 [self setOutlineTableColumn:textcol]; |
709
5a268d5f1cfa
Fixes for tree event handling. Still more to come shortly...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
708
diff
changeset
|
1153 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(treeSelectionChanged:) name:NSOutlineViewSelectionDidChangeNotification object:[self window]]; |
722
5a8d5161651d
Implemented tree expand event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
721
diff
changeset
|
1154 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(treeItemExpanded:) name:NSOutlineViewItemDidExpandNotification object:[self window]]; |
680
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1155 } |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1156 return self; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1157 } |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1158 -(id)outlineView:(NSOutlineView *)outlineView child:(int)index ofItem:(id)item |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1159 { |
682
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
1160 if(item) |
680
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1161 { |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1162 NSMutableArray *array = [item pointerAtIndex:3]; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1163 return array ? [array objectAtIndex:index] : nil; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1164 } |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1165 else |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1166 { |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1167 return [data objectAtIndex:index]; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1168 } |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1169 } |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1170 -(BOOL)outlineView:(NSOutlineView *)outlineView isItemExpandable:(id)item |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1171 { |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1172 return [self outlineView:outlineView numberOfChildrenOfItem:item] != 0; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1173 } |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1174 -(int)outlineView:(NSOutlineView *)outlineView numberOfChildrenOfItem:(id)item |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1175 { |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1176 if(item) |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1177 { |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1178 if([item isKindOfClass:[NSPointerArray class]]) |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1179 { |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1180 NSMutableArray *array = [item pointerAtIndex:3]; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1181 return array ? (int)[array count] : 0; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1182 } |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1183 else |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1184 { |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1185 return 0; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1186 } |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1187 } |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1188 else |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1189 { |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1190 return data ? (int)[data count] : 0; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1191 } |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1192 } |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1193 -(id)outlineView:(NSOutlineView *)outlineView objectValueForTableColumn:(NSTableColumn *)tableColumn byItem:(id)item |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1194 { |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1195 if(item) |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1196 { |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1197 if([item isKindOfClass:[NSPointerArray class]]) |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1198 { |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1199 NSPointerArray *this = (NSPointerArray *)item; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1200 if(tableColumn == imagecol) |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1201 { |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1202 return [this pointerAtIndex:0]; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1203 } |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1204 return [this pointerAtIndex:1]; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1205 } |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1206 else |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1207 { |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1208 return nil; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1209 } |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1210 } |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1211 return @"List Root"; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1212 } |
710
78460ff977c1
Finishing up tree event/signal handlers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
709
diff
changeset
|
1213 -(BOOL)outlineView:(NSOutlineView *)outlineView shouldEditTableColumn:(NSTableColumn *)tableColumn item:(id)item { return NO; } |
680
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1214 -(void)addTree:(NSPointerArray *)item and:(NSPointerArray *)parent; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1215 { |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1216 NSMutableArray *children = data; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1217 if(parent) |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1218 { |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1219 children = [parent pointerAtIndex:3]; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1220 if(!children) |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1221 { |
692
bd909322f40d
Added "retain"s to the DWTree/DWContainer/DWListBox classes memory allocation
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
691
diff
changeset
|
1222 children = [[[NSMutableArray alloc] init] retain]; |
680
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1223 [parent replacePointerAtIndex:3 withPointer:children]; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1224 } |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1225 } |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1226 else |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1227 { |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1228 if(!data) |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1229 { |
692
bd909322f40d
Added "retain"s to the DWTree/DWContainer/DWListBox classes memory allocation
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
691
diff
changeset
|
1230 children = data = [[[NSMutableArray alloc] init] retain]; |
680
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1231 } |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1232 } |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1233 [children addObject:item]; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1234 } |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1235 -(void *)userdata { return userdata; } |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1236 -(void)setUserdata:(void *)input { userdata = input; } |
709
5a268d5f1cfa
Fixes for tree event handling. Still more to come shortly...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
708
diff
changeset
|
1237 -(void)treeSelectionChanged:(id)sender |
5a268d5f1cfa
Fixes for tree event handling. Still more to come shortly...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
708
diff
changeset
|
1238 { |
710
78460ff977c1
Finishing up tree event/signal handlers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
709
diff
changeset
|
1239 /* Handler for tree class */ |
709
5a268d5f1cfa
Fixes for tree event handling. Still more to come shortly...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
708
diff
changeset
|
1240 id item = [self itemAtRow:[self selectedRow]]; |
5a268d5f1cfa
Fixes for tree event handling. Still more to come shortly...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
708
diff
changeset
|
1241 |
713
2c8fc0fd8c11
Don't send tree events with no selected item. Also don't strdup a NULL string.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
712
diff
changeset
|
1242 if(item) |
2c8fc0fd8c11
Don't send tree events with no selected item. Also don't strdup a NULL string.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
712
diff
changeset
|
1243 { |
2c8fc0fd8c11
Don't send tree events with no selected item. Also don't strdup a NULL string.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
712
diff
changeset
|
1244 _event_handler(self, (void *)item, 12); |
2c8fc0fd8c11
Don't send tree events with no selected item. Also don't strdup a NULL string.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
712
diff
changeset
|
1245 } |
710
78460ff977c1
Finishing up tree event/signal handlers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
709
diff
changeset
|
1246 } |
722
5a8d5161651d
Implemented tree expand event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
721
diff
changeset
|
1247 -(void)treeItemExpanded:(NSNotification *)notification |
5a8d5161651d
Implemented tree expand event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
721
diff
changeset
|
1248 { |
5a8d5161651d
Implemented tree expand event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
721
diff
changeset
|
1249 id item = [[notification userInfo ] objectForKey: @"NSObject"]; |
5a8d5161651d
Implemented tree expand event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
721
diff
changeset
|
1250 |
5a8d5161651d
Implemented tree expand event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
721
diff
changeset
|
1251 if(item) |
5a8d5161651d
Implemented tree expand event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
721
diff
changeset
|
1252 { |
5a8d5161651d
Implemented tree expand event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
721
diff
changeset
|
1253 _event_handler(self, (void *)item, 16); |
5a8d5161651d
Implemented tree expand event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
721
diff
changeset
|
1254 } |
5a8d5161651d
Implemented tree expand event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
721
diff
changeset
|
1255 } |
710
78460ff977c1
Finishing up tree event/signal handlers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
709
diff
changeset
|
1256 -(NSMenu *)menuForEvent:(NSEvent *)event |
78460ff977c1
Finishing up tree event/signal handlers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
709
diff
changeset
|
1257 { |
78460ff977c1
Finishing up tree event/signal handlers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
709
diff
changeset
|
1258 int row; |
78460ff977c1
Finishing up tree event/signal handlers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
709
diff
changeset
|
1259 NSPoint where = [self convertPoint:[event locationInWindow] fromView:nil]; |
78460ff977c1
Finishing up tree event/signal handlers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
709
diff
changeset
|
1260 row = (int)[self rowAtPoint:where]; |
78460ff977c1
Finishing up tree event/signal handlers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
709
diff
changeset
|
1261 id item = [self itemAtRow:row]; |
78460ff977c1
Finishing up tree event/signal handlers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
709
diff
changeset
|
1262 NSString *nstr = [item pointerAtIndex:1]; |
78460ff977c1
Finishing up tree event/signal handlers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
709
diff
changeset
|
1263 _event_handler(self, (NSEvent *)[nstr UTF8String], 10); |
78460ff977c1
Finishing up tree event/signal handlers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
709
diff
changeset
|
1264 return nil; |
709
5a268d5f1cfa
Fixes for tree event handling. Still more to come shortly...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
708
diff
changeset
|
1265 } |
680
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1266 -(NSScrollView *)scrollview { return scrollview; } |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1267 -(void)setScrollview:(NSScrollView *)input { scrollview = input; } |
682
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
1268 -(void)deleteNode:(NSPointerArray *)item { _free_tree_recurse(data, item); } |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
1269 -(void)clear { NSMutableArray *toclear = data; data = nil; _free_tree_recurse(toclear, NULL); [self reloadData]; } |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
1270 -(void)dealloc |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
1271 { |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
1272 UserData *root = userdata; |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
1273 _remove_userdata(&root, NULL, TRUE); |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
1274 _free_tree_recurse(data, NULL); |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
1275 [imagecol release]; |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
1276 [textcol release]; |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
1277 [super dealloc]; |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
1278 } |
680
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1279 @end |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1280 |
656
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
1281 /* Subclass for a Calendar type */ |
655
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
1282 @interface DWCalendar : NSDatePicker |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
1283 { |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
1284 void *userdata; |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
1285 } |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
1286 -(void *)userdata; |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
1287 -(void)setUserdata:(void *)input; |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
1288 @end |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
1289 |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
1290 @implementation DWCalendar |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
1291 -(void *)userdata { return userdata; } |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
1292 -(void)setUserdata:(void *)input { userdata = input; } |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1293 -(void)dealloc { UserData *root = userdata; _remove_userdata(&root, NULL, TRUE); [super dealloc]; } |
655
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
1294 @end |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
1295 |
656
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
1296 /* Subclass for a Combobox type */ |
717
17923b931393
Fixes for building for MacOS 10.5 and PPC
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
715
diff
changeset
|
1297 @interface DWComboBox : NSComboBox |
719
d5e49ef8f541
Updated the #if for Snow Leopard/Leopard builds to handle them not being defined properly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
718
diff
changeset
|
1298 #ifdef BUILDING_FOR_SNOW_LEOPARD |
717
17923b931393
Fixes for building for MacOS 10.5 and PPC
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
715
diff
changeset
|
1299 <NSComboBoxDelegate> |
17923b931393
Fixes for building for MacOS 10.5 and PPC
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
715
diff
changeset
|
1300 #endif |
656
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
1301 { |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
1302 void *userdata; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
1303 } |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
1304 -(void *)userdata; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
1305 -(void)setUserdata:(void *)input; |
703
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
1306 -(void)comboBoxSelectionDidChange:(NSNotification *)not; |
656
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
1307 @end |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
1308 |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
1309 @implementation DWComboBox |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
1310 -(void *)userdata { return userdata; } |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
1311 -(void)setUserdata:(void *)input { userdata = input; } |
703
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
1312 -(void)comboBoxSelectionDidChange:(NSNotification *)not { _event_handler(self, (void *)[self indexOfSelectedItem], 11); } |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1313 -(void)dealloc { UserData *root = userdata; _remove_userdata(&root, NULL, TRUE); [super dealloc]; } |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1314 @end |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1315 |
679
d2d7d1802af4
Implemented a rather hacky fix for the spinbutton issues. The stepper control is really poorly
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
678
diff
changeset
|
1316 /* Subclass for a stepper component of the spinbutton type */ |
d2d7d1802af4
Implemented a rather hacky fix for the spinbutton issues. The stepper control is really poorly
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
678
diff
changeset
|
1317 /* This is a bad way of doing this... but I can't get the other methods to work */ |
d2d7d1802af4
Implemented a rather hacky fix for the spinbutton issues. The stepper control is really poorly
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
678
diff
changeset
|
1318 @interface DWStepper : NSStepper |
d2d7d1802af4
Implemented a rather hacky fix for the spinbutton issues. The stepper control is really poorly
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
678
diff
changeset
|
1319 { |
d2d7d1802af4
Implemented a rather hacky fix for the spinbutton issues. The stepper control is really poorly
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
678
diff
changeset
|
1320 id textfield; |
705
7087f3a294e5
Spinbuttons now respond to value changed. Fix for typing in spinbutton a value out of the range.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
704
diff
changeset
|
1321 id parent; |
679
d2d7d1802af4
Implemented a rather hacky fix for the spinbutton issues. The stepper control is really poorly
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
678
diff
changeset
|
1322 } |
d2d7d1802af4
Implemented a rather hacky fix for the spinbutton issues. The stepper control is really poorly
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
678
diff
changeset
|
1323 -(void)setTextfield:(id)input; |
d2d7d1802af4
Implemented a rather hacky fix for the spinbutton issues. The stepper control is really poorly
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
678
diff
changeset
|
1324 -(id)textfield; |
705
7087f3a294e5
Spinbuttons now respond to value changed. Fix for typing in spinbutton a value out of the range.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
704
diff
changeset
|
1325 -(void)setParent:(id)input; |
7087f3a294e5
Spinbuttons now respond to value changed. Fix for typing in spinbutton a value out of the range.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
704
diff
changeset
|
1326 -(id)parent; |
679
d2d7d1802af4
Implemented a rather hacky fix for the spinbutton issues. The stepper control is really poorly
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
678
diff
changeset
|
1327 -(void)mouseDown:(NSEvent *)event; |
d2d7d1802af4
Implemented a rather hacky fix for the spinbutton issues. The stepper control is really poorly
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
678
diff
changeset
|
1328 -(void)mouseUp:(NSEvent *)event; |
d2d7d1802af4
Implemented a rather hacky fix for the spinbutton issues. The stepper control is really poorly
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
678
diff
changeset
|
1329 @end |
d2d7d1802af4
Implemented a rather hacky fix for the spinbutton issues. The stepper control is really poorly
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
678
diff
changeset
|
1330 |
d2d7d1802af4
Implemented a rather hacky fix for the spinbutton issues. The stepper control is really poorly
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
678
diff
changeset
|
1331 @implementation DWStepper |
d2d7d1802af4
Implemented a rather hacky fix for the spinbutton issues. The stepper control is really poorly
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
678
diff
changeset
|
1332 -(void)setTextfield:(id)input { textfield = input; } |
d2d7d1802af4
Implemented a rather hacky fix for the spinbutton issues. The stepper control is really poorly
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
678
diff
changeset
|
1333 -(id)textfield { return textfield; } |
705
7087f3a294e5
Spinbuttons now respond to value changed. Fix for typing in spinbutton a value out of the range.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
704
diff
changeset
|
1334 -(void)setParent:(id)input { parent = input; } |
7087f3a294e5
Spinbuttons now respond to value changed. Fix for typing in spinbutton a value out of the range.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
704
diff
changeset
|
1335 -(id)parent { return parent; } |
679
d2d7d1802af4
Implemented a rather hacky fix for the spinbutton issues. The stepper control is really poorly
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
678
diff
changeset
|
1336 -(void)mouseDown:(NSEvent *)event |
d2d7d1802af4
Implemented a rather hacky fix for the spinbutton issues. The stepper control is really poorly
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
678
diff
changeset
|
1337 { |
d2d7d1802af4
Implemented a rather hacky fix for the spinbutton issues. The stepper control is really poorly
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
678
diff
changeset
|
1338 [super mouseDown:event]; |
d2d7d1802af4
Implemented a rather hacky fix for the spinbutton issues. The stepper control is really poorly
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
678
diff
changeset
|
1339 if([[NSApp currentEvent] type] == NSLeftMouseUp) |
d2d7d1802af4
Implemented a rather hacky fix for the spinbutton issues. The stepper control is really poorly
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
678
diff
changeset
|
1340 { |
705
7087f3a294e5
Spinbuttons now respond to value changed. Fix for typing in spinbutton a value out of the range.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
704
diff
changeset
|
1341 [textfield takeIntValueFrom:self]; |
7087f3a294e5
Spinbuttons now respond to value changed. Fix for typing in spinbutton a value out of the range.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
704
diff
changeset
|
1342 _event_handler(parent, (void *)[self integerValue], 14); |
679
d2d7d1802af4
Implemented a rather hacky fix for the spinbutton issues. The stepper control is really poorly
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
678
diff
changeset
|
1343 } |
d2d7d1802af4
Implemented a rather hacky fix for the spinbutton issues. The stepper control is really poorly
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
678
diff
changeset
|
1344 } |
d2d7d1802af4
Implemented a rather hacky fix for the spinbutton issues. The stepper control is really poorly
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
678
diff
changeset
|
1345 -(void)mouseUp:(NSEvent *)event |
d2d7d1802af4
Implemented a rather hacky fix for the spinbutton issues. The stepper control is really poorly
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
678
diff
changeset
|
1346 { |
d2d7d1802af4
Implemented a rather hacky fix for the spinbutton issues. The stepper control is really poorly
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
678
diff
changeset
|
1347 [textfield takeIntValueFrom:self]; |
705
7087f3a294e5
Spinbuttons now respond to value changed. Fix for typing in spinbutton a value out of the range.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
704
diff
changeset
|
1348 _event_handler(parent, (void *)[self integerValue], 14); |
679
d2d7d1802af4
Implemented a rather hacky fix for the spinbutton issues. The stepper control is really poorly
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
678
diff
changeset
|
1349 } |
d2d7d1802af4
Implemented a rather hacky fix for the spinbutton issues. The stepper control is really poorly
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
678
diff
changeset
|
1350 @end |
d2d7d1802af4
Implemented a rather hacky fix for the spinbutton issues. The stepper control is really poorly
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
678
diff
changeset
|
1351 |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1352 /* Subclass for a Spinbutton type */ |
717
17923b931393
Fixes for building for MacOS 10.5 and PPC
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
715
diff
changeset
|
1353 @interface DWSpinButton : NSView |
719
d5e49ef8f541
Updated the #if for Snow Leopard/Leopard builds to handle them not being defined properly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
718
diff
changeset
|
1354 #ifdef BUILDING_FOR_SNOW_LEOPARD |
717
17923b931393
Fixes for building for MacOS 10.5 and PPC
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
715
diff
changeset
|
1355 <NSTextFieldDelegate> |
17923b931393
Fixes for building for MacOS 10.5 and PPC
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
715
diff
changeset
|
1356 #endif |
679
d2d7d1802af4
Implemented a rather hacky fix for the spinbutton issues. The stepper control is really poorly
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
678
diff
changeset
|
1357 { |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1358 void *userdata; |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1359 NSTextField *textfield; |
679
d2d7d1802af4
Implemented a rather hacky fix for the spinbutton issues. The stepper control is really poorly
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
678
diff
changeset
|
1360 DWStepper *stepper; |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1361 } |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1362 -(id)init; |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1363 -(void *)userdata; |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1364 -(void)setUserdata:(void *)input; |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1365 -(NSTextField *)textfield; |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1366 -(NSStepper *)stepper; |
679
d2d7d1802af4
Implemented a rather hacky fix for the spinbutton issues. The stepper control is really poorly
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
678
diff
changeset
|
1367 -(void)controlTextDidChange:(NSNotification *)aNotification; |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1368 @end |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1369 |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1370 @implementation DWSpinButton |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1371 -(id)init |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1372 { |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1373 self = [super init]; |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1374 |
679
d2d7d1802af4
Implemented a rather hacky fix for the spinbutton issues. The stepper control is really poorly
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
678
diff
changeset
|
1375 if(self) |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1376 { |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1377 textfield = [[NSTextField alloc] init]; |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1378 [self addSubview:textfield]; |
679
d2d7d1802af4
Implemented a rather hacky fix for the spinbutton issues. The stepper control is really poorly
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
678
diff
changeset
|
1379 stepper = [[DWStepper alloc] init]; |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1380 [self addSubview:stepper]; |
705
7087f3a294e5
Spinbuttons now respond to value changed. Fix for typing in spinbutton a value out of the range.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
704
diff
changeset
|
1381 [stepper setParent:self]; |
679
d2d7d1802af4
Implemented a rather hacky fix for the spinbutton issues. The stepper control is really poorly
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
678
diff
changeset
|
1382 [stepper setTextfield:textfield]; |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1383 [textfield takeIntValueFrom:stepper]; |
679
d2d7d1802af4
Implemented a rather hacky fix for the spinbutton issues. The stepper control is really poorly
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
678
diff
changeset
|
1384 [textfield setDelegate:self]; |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1385 } |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1386 return self; |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1387 } |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1388 -(void *)userdata { return userdata; } |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1389 -(void)setUserdata:(void *)input { userdata = input; } |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1390 -(NSTextField *)textfield { return textfield; } |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1391 -(NSStepper *)stepper { return stepper; } |
679
d2d7d1802af4
Implemented a rather hacky fix for the spinbutton issues. The stepper control is really poorly
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
678
diff
changeset
|
1392 -(void)controlTextDidChange:(NSNotification *)aNotification |
d2d7d1802af4
Implemented a rather hacky fix for the spinbutton issues. The stepper control is really poorly
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
678
diff
changeset
|
1393 { |
d2d7d1802af4
Implemented a rather hacky fix for the spinbutton issues. The stepper control is really poorly
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
678
diff
changeset
|
1394 [stepper takeIntValueFrom:textfield]; |
705
7087f3a294e5
Spinbuttons now respond to value changed. Fix for typing in spinbutton a value out of the range.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
704
diff
changeset
|
1395 [textfield takeIntValueFrom:stepper]; |
7087f3a294e5
Spinbuttons now respond to value changed. Fix for typing in spinbutton a value out of the range.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
704
diff
changeset
|
1396 _event_handler(self, (void *)[stepper integerValue], 14); |
679
d2d7d1802af4
Implemented a rather hacky fix for the spinbutton issues. The stepper control is really poorly
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
678
diff
changeset
|
1397 } |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1398 -(void)dealloc { UserData *root = userdata; _remove_userdata(&root, NULL, TRUE); [super dealloc]; } |
656
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
1399 @end |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
1400 |
684
014b02436c1f
Added MDI simulation code... the MDI "window" will just be a box for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
683
diff
changeset
|
1401 /* Subclass for a MDI type |
014b02436c1f
Added MDI simulation code... the MDI "window" will just be a box for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
683
diff
changeset
|
1402 * This is just a box for display purposes... but it is a |
014b02436c1f
Added MDI simulation code... the MDI "window" will just be a box for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
683
diff
changeset
|
1403 * unique class so it can be identified when creating windows. |
014b02436c1f
Added MDI simulation code... the MDI "window" will just be a box for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
683
diff
changeset
|
1404 */ |
014b02436c1f
Added MDI simulation code... the MDI "window" will just be a box for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
683
diff
changeset
|
1405 @interface DWMDI : DWBox {} |
014b02436c1f
Added MDI simulation code... the MDI "window" will just be a box for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
683
diff
changeset
|
1406 @end |
014b02436c1f
Added MDI simulation code... the MDI "window" will just be a box for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
683
diff
changeset
|
1407 |
014b02436c1f
Added MDI simulation code... the MDI "window" will just be a box for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
683
diff
changeset
|
1408 @implementation DWMDI |
014b02436c1f
Added MDI simulation code... the MDI "window" will just be a box for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
683
diff
changeset
|
1409 @end |
014b02436c1f
Added MDI simulation code... the MDI "window" will just be a box for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
683
diff
changeset
|
1410 |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1411 /* This function adds a signal handler callback into the linked list. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1412 */ |
688
b52f1d4a60dd
Fixes for timers not working properly. Includes commented out test container code for threadsafety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
687
diff
changeset
|
1413 void _new_signal(ULONG message, HWND window, int msgid, void *signalfunction, void *data) |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1414 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1415 SignalHandler *new = malloc(sizeof(SignalHandler)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1416 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1417 new->message = message; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1418 new->window = window; |
688
b52f1d4a60dd
Fixes for timers not working properly. Includes commented out test container code for threadsafety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
687
diff
changeset
|
1419 new->id = msgid; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1420 new->signalfunction = signalfunction; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1421 new->data = data; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1422 new->next = NULL; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1423 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1424 if (!Root) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1425 Root = new; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1426 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1427 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1428 SignalHandler *prev = NULL, *tmp = Root; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1429 while(tmp) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1430 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1431 if(tmp->message == message && |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1432 tmp->window == window && |
688
b52f1d4a60dd
Fixes for timers not working properly. Includes commented out test container code for threadsafety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
687
diff
changeset
|
1433 tmp->id == msgid && |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1434 tmp->signalfunction == signalfunction) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1435 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1436 tmp->data = data; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1437 free(new); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1438 return; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1439 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1440 prev = tmp; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1441 tmp = tmp->next; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1442 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1443 if(prev) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1444 prev->next = new; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1445 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1446 Root = new; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1447 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1448 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1449 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1450 /* Finds the message number for a given signal name */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1451 ULONG _findsigmessage(char *signame) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1452 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1453 int z; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1454 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1455 for(z=0;z<SIGNALMAX;z++) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1456 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1457 if(strcasecmp(signame, SignalTranslate[z].name) == 0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1458 return SignalTranslate[z].message; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1459 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1460 return 0L; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1461 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1462 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1463 unsigned long _foreground = 0xAAAAAA, _background = 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1464 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1465 /* This function calculates how much space the widgets and boxes require |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1466 * and does expansion as necessary. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1467 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1468 static int _resize_box(Box *thisbox, int *depth, int x, int y, int *usedx, int *usedy, |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1469 int pass, int *usedpadx, int *usedpady) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1470 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1471 int z, currentx = 0, currenty = 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1472 int uymax = 0, uxmax = 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1473 int upymax = 0, upxmax = 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1474 /* Used for the SIZEEXPAND */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1475 int nux = *usedx, nuy = *usedy; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1476 int nupx = *usedpadx, nupy = *usedpady; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1477 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1478 (*usedx) += (thisbox->pad * 2); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1479 (*usedy) += (thisbox->pad * 2); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1480 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1481 for(z=0;z<thisbox->count;z++) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1482 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1483 if(thisbox->items[z].type == TYPEBOX) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1484 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1485 int initialx, initialy; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1486 DWBox *box = thisbox->items[z].hwnd; |
666
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
1487 Box *tmp = [box box]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1488 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1489 initialx = x - (*usedx); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1490 initialy = y - (*usedy); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1491 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1492 if(tmp) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1493 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1494 int newx, newy; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1495 int nux = *usedx, nuy = *usedy; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1496 int upx = *usedpadx + (tmp->pad*2), upy = *usedpady + (tmp->pad*2); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1497 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1498 /* On the second pass we know how big the box needs to be and how |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1499 * much space we have, so we can calculate a ratio for the new box. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1500 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1501 if(pass == 2) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1502 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1503 int deep = *depth + 1; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1504 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1505 _resize_box(tmp, &deep, x, y, &nux, &nuy, 1, &upx, &upy); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1506 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1507 tmp->upx = upx - *usedpadx; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1508 tmp->upy = upy - *usedpady; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1509 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1510 newx = x - nux; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1511 newy = y - nuy; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1512 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1513 tmp->width = thisbox->items[z].width = initialx - newx; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1514 tmp->height = thisbox->items[z].height = initialy - newy; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1515 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1516 tmp->parentxratio = thisbox->xratio; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1517 tmp->parentyratio = thisbox->yratio; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1518 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1519 tmp->parentpad = tmp->pad; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1520 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1521 /* Just in case */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1522 tmp->xratio = thisbox->xratio; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1523 tmp->yratio = thisbox->yratio; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1524 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1525 if(thisbox->type == DW_VERT) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1526 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1527 if((thisbox->items[z].width-((thisbox->items[z].pad*2)+(tmp->pad*2)))!=0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1528 tmp->xratio = ((float)((thisbox->items[z].width * thisbox->xratio)-((thisbox->items[z].pad*2)+(tmp->pad*2))))/((float)(thisbox->items[z].width-((thisbox->items[z].pad*2)+(tmp->pad*2)))); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1529 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1530 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1531 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1532 if((thisbox->items[z].width-tmp->upx)!=0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1533 tmp->xratio = ((float)((thisbox->items[z].width * thisbox->xratio)-tmp->upx))/((float)(thisbox->items[z].width-tmp->upx)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1534 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1535 if(thisbox->type == DW_HORZ) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1536 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1537 if((thisbox->items[z].height-((thisbox->items[z].pad*2)+(tmp->pad*2)))!=0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1538 tmp->yratio = ((float)((thisbox->items[z].height * thisbox->yratio)-((thisbox->items[z].pad*2)+(tmp->pad*2))))/((float)(thisbox->items[z].height-((thisbox->items[z].pad*2)+(tmp->pad*2)))); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1539 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1540 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1541 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1542 if((thisbox->items[z].height-tmp->upy)!=0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1543 tmp->yratio = ((float)((thisbox->items[z].height * thisbox->yratio)-tmp->upy))/((float)(thisbox->items[z].height-tmp->upy)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1544 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1545 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1546 nux = *usedx; nuy = *usedy; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1547 upx = *usedpadx + (tmp->pad*2); upy = *usedpady + (tmp->pad*2); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1548 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1549 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1550 (*depth)++; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1551 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1552 _resize_box(tmp, depth, x, y, &nux, &nuy, pass, &upx, &upy); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1553 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1554 (*depth)--; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1555 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1556 newx = x - nux; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1557 newy = y - nuy; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1558 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1559 tmp->minwidth = thisbox->items[z].width = initialx - newx; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1560 tmp->minheight = thisbox->items[z].height = initialy - newy; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1561 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1562 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1563 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1564 if(pass > 1 && *depth > 0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1565 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1566 if(thisbox->type == DW_VERT) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1567 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1568 if((thisbox->minwidth-((thisbox->items[z].pad*2)+(thisbox->parentpad*2))) == 0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1569 thisbox->items[z].xratio = 1.0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1570 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1571 thisbox->items[z].xratio = ((float)((thisbox->width * thisbox->parentxratio)-((thisbox->items[z].pad*2)+(thisbox->parentpad*2))))/((float)(thisbox->minwidth-((thisbox->items[z].pad*2)+(thisbox->parentpad*2)))); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1572 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1573 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1574 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1575 if(thisbox->minwidth-thisbox->upx == 0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1576 thisbox->items[z].xratio = 1.0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1577 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1578 thisbox->items[z].xratio = ((float)((thisbox->width * thisbox->parentxratio)-thisbox->upx))/((float)(thisbox->minwidth-thisbox->upx)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1579 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1580 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1581 if(thisbox->type == DW_HORZ) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1582 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1583 if((thisbox->minheight-((thisbox->items[z].pad*2)+(thisbox->parentpad*2))) == 0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1584 thisbox->items[z].yratio = 1.0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1585 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1586 thisbox->items[z].yratio = ((float)((thisbox->height * thisbox->parentyratio)-((thisbox->items[z].pad*2)+(thisbox->parentpad*2))))/((float)(thisbox->minheight-((thisbox->items[z].pad*2)+(thisbox->parentpad*2)))); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1587 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1588 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1589 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1590 if(thisbox->minheight-thisbox->upy == 0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1591 thisbox->items[z].yratio = 1.0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1592 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1593 thisbox->items[z].yratio = ((float)((thisbox->height * thisbox->parentyratio)-thisbox->upy))/((float)(thisbox->minheight-thisbox->upy)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1594 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1595 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1596 if(thisbox->items[z].type == TYPEBOX) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1597 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1598 DWBox *box = thisbox->items[z].hwnd; |
666
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
1599 Box *tmp = [box box]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1600 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1601 if(tmp) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1602 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1603 tmp->parentxratio = thisbox->items[z].xratio; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1604 tmp->parentyratio = thisbox->items[z].yratio; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1605 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1606 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1607 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1608 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1609 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1610 thisbox->items[z].xratio = thisbox->xratio; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1611 thisbox->items[z].yratio = thisbox->yratio; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1612 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1613 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1614 if(thisbox->type == DW_VERT) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1615 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1616 if((thisbox->items[z].width + (thisbox->items[z].pad*2)) > uxmax) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1617 uxmax = (thisbox->items[z].width + (thisbox->items[z].pad*2)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1618 if(thisbox->items[z].hsize != SIZEEXPAND) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1619 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1620 if(((thisbox->items[z].pad*2) + thisbox->items[z].width) > upxmax) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1621 upxmax = (thisbox->items[z].pad*2) + thisbox->items[z].width; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1622 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1623 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1624 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1625 if(thisbox->items[z].pad*2 > upxmax) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1626 upxmax = thisbox->items[z].pad*2; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1627 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1628 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1629 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1630 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1631 if(thisbox->items[z].width == -1) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1632 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1633 /* figure out how much space this item requires */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1634 /* thisbox->items[z].width = */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1635 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1636 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1637 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1638 (*usedx) += thisbox->items[z].width + (thisbox->items[z].pad*2); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1639 if(thisbox->items[z].hsize != SIZEEXPAND) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1640 (*usedpadx) += (thisbox->items[z].pad*2) + thisbox->items[z].width; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1641 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1642 (*usedpadx) += thisbox->items[z].pad*2; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1643 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1644 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1645 if(thisbox->type == DW_HORZ) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1646 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1647 if((thisbox->items[z].height + (thisbox->items[z].pad*2)) > uymax) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1648 uymax = (thisbox->items[z].height + (thisbox->items[z].pad*2)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1649 if(thisbox->items[z].vsize != SIZEEXPAND) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1650 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1651 if(((thisbox->items[z].pad*2) + thisbox->items[z].height) > upymax) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1652 upymax = (thisbox->items[z].pad*2) + thisbox->items[z].height; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1653 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1654 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1655 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1656 if(thisbox->items[z].pad*2 > upymax) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1657 upymax = thisbox->items[z].pad*2; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1658 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1659 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1660 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1661 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1662 if(thisbox->items[z].height == -1) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1663 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1664 /* figure out how much space this item requires */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1665 /* thisbox->items[z].height = */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1666 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1667 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1668 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1669 (*usedy) += thisbox->items[z].height + (thisbox->items[z].pad*2); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1670 if(thisbox->items[z].vsize != SIZEEXPAND) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1671 (*usedpady) += (thisbox->items[z].pad*2) + thisbox->items[z].height; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1672 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1673 (*usedpady) += thisbox->items[z].pad*2; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1674 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1675 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1676 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1677 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1678 (*usedx) += uxmax; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1679 (*usedy) += uymax; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1680 (*usedpadx) += upxmax; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1681 (*usedpady) += upymax; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1682 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1683 currentx += thisbox->pad; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1684 currenty += thisbox->pad; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1685 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1686 /* The second pass is for expansion and actual placement. */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1687 if(pass > 1) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1688 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1689 /* Any SIZEEXPAND items should be set to uxmax/uymax */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1690 for(z=0;z<thisbox->count;z++) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1691 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1692 if(thisbox->items[z].hsize == SIZEEXPAND && thisbox->type == DW_VERT) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1693 thisbox->items[z].width = uxmax-(thisbox->items[z].pad*2); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1694 if(thisbox->items[z].vsize == SIZEEXPAND && thisbox->type == DW_HORZ) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1695 thisbox->items[z].height = uymax-(thisbox->items[z].pad*2); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1696 /* Run this code segment again to finalize the sized after setting uxmax/uymax values. */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1697 if(thisbox->items[z].type == TYPEBOX) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1698 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1699 DWBox *box = thisbox->items[z].hwnd; |
666
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
1700 Box *tmp = [box box]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1701 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1702 if(tmp) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1703 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1704 if(*depth > 0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1705 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1706 float calcval; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1707 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1708 if(thisbox->type == DW_VERT) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1709 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1710 calcval = (float)(tmp->minwidth-((thisbox->items[z].pad*2)+(thisbox->pad*2))); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1711 if(calcval == 0.0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1712 tmp->xratio = thisbox->xratio; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1713 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1714 tmp->xratio = ((float)((thisbox->items[z].width * thisbox->xratio)-((thisbox->items[z].pad*2)+(thisbox->pad*2))))/calcval; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1715 tmp->width = thisbox->items[z].width; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1716 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1717 if(thisbox->type == DW_HORZ) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1718 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1719 calcval = (float)(tmp->minheight-((thisbox->items[z].pad*2)+(thisbox->pad*2))); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1720 if(calcval == 0.0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1721 tmp->yratio = thisbox->yratio; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1722 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1723 tmp->yratio = ((float)((thisbox->items[z].height * thisbox->yratio)-((thisbox->items[z].pad*2)+(thisbox->pad*2))))/calcval; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1724 tmp->height = thisbox->items[z].height; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1725 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1726 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1727 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1728 (*depth)++; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1729 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1730 _resize_box(tmp, depth, x, y, &nux, &nuy, 3, &nupx, &nupy); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1731 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1732 (*depth)--; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1733 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1734 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1735 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1736 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1737 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1738 for(z=0;z<(thisbox->count);z++) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1739 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1740 int height = thisbox->items[z].height; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1741 int width = thisbox->items[z].width; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1742 int pad = thisbox->items[z].pad; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1743 NSView *handle = thisbox->items[z].hwnd; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1744 NSPoint point; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1745 NSSize size; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1746 int vectorx, vectory; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1747 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1748 /* When upxmax != pad*2 then ratios are incorrect. */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1749 vectorx = (int)((width*thisbox->items[z].xratio)-width); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1750 vectory = (int)((height*thisbox->items[z].yratio)-height); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1751 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1752 if(width > 0 && height > 0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1753 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1754 /* This is a hack to fix rounding of the sizing */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1755 if(*depth == 0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1756 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1757 vectorx++; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1758 vectory++; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1759 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1760 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1761 /* If this item isn't going to expand... reset the vectors to 0 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1762 if(thisbox->items[z].vsize != SIZEEXPAND) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1763 vectory = 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1764 if(thisbox->items[z].hsize != SIZEEXPAND) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1765 vectorx = 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1766 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1767 point.x = currentx + pad; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1768 point.y = currenty + pad; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1769 size.width = width + vectorx; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1770 size.height = height + vectory; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1771 [handle setFrameOrigin:point]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1772 [handle setFrameSize:size]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1773 |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
1774 /* Special handling for notebook controls */ |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
1775 if([handle isMemberOfClass:[DWNotebook class]]) |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
1776 { |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
1777 DWNotebook *notebook = (DWNotebook *)handle; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
1778 DWNotebookPage *notepage = (DWNotebookPage *)[notebook selectedTabViewItem]; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
1779 DWBox *view = [notepage view]; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
1780 |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
1781 if(view != nil) |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
1782 { |
666
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
1783 Box *box = [view box]; |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
1784 NSSize size = [view frame].size; |
666
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
1785 _do_resize(box, size.width, size.height); |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
1786 } |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
1787 } |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1788 /* Special handling for spinbutton controls */ |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1789 else if([handle isMemberOfClass:[DWSpinButton class]]) |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1790 { |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1791 DWSpinButton *spinbutton = (DWSpinButton *)handle; |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1792 NSTextField *textfield = [spinbutton textfield]; |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1793 NSStepper *stepper = [spinbutton stepper]; |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1794 [textfield setFrameOrigin:NSMakePoint(0,0)]; |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1795 [textfield setFrameSize:NSMakeSize(size.width-20,size.height)]; |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1796 [stepper setFrameOrigin:NSMakePoint(size.width-20,0)]; |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1797 [stepper setFrameSize:NSMakeSize(20,size.height)]; |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1798 } |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
1799 else if([handle isMemberOfClass:[DWRender class]]) |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
1800 { |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
1801 _event_handler(handle, nil, 1); |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
1802 } |
677
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
1803 else if([handle isMemberOfClass:[DWSplitBar class]] && size.width > 20 && size.height > 20) |
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
1804 { |
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
1805 DWSplitBar *split = (DWSplitBar *)handle; |
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
1806 float percent = [split percent]; |
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
1807 |
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
1808 if(percent > 0) |
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
1809 { |
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
1810 dw_splitbar_set(handle, percent); |
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
1811 [split setPercent:0]; |
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
1812 } |
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
1813 } |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
1814 |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
1815 if(thisbox->type == DW_HORZ) |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1816 currentx += width + vectorx + (pad * 2); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1817 if(thisbox->type == DW_VERT) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1818 currenty += height + vectory + (pad * 2); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1819 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1820 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1821 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1822 return 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1823 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1824 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1825 static void _do_resize(Box *thisbox, int x, int y) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1826 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1827 if(x != 0 && y != 0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1828 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1829 if(thisbox) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1830 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1831 int usedx = 0, usedy = 0, usedpadx = 0, usedpady = 0, depth = 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1832 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1833 _resize_box(thisbox, &depth, x, y, &usedx, &usedy, 1, &usedpadx, &usedpady); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1834 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1835 if(usedx-usedpadx == 0 || usedy-usedpady == 0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1836 return; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1837 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1838 thisbox->xratio = ((float)(x-usedpadx))/((float)(usedx-usedpadx)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1839 thisbox->yratio = ((float)(y-usedpady))/((float)(usedy-usedpady)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1840 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1841 usedx = usedy = usedpadx = usedpady = depth = 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1842 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1843 _resize_box(thisbox, &depth, x, y, &usedx, &usedy, 2, &usedpadx, &usedpady); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1844 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1845 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1846 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1847 |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
1848 NSMenu *_generate_main_menu() |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
1849 { |
717
17923b931393
Fixes for building for MacOS 10.5 and PPC
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
715
diff
changeset
|
1850 NSString *applicationName = nil; |
17923b931393
Fixes for building for MacOS 10.5 and PPC
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
715
diff
changeset
|
1851 |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1852 /* This only works on 10.6 so we have a backup method */ |
719
d5e49ef8f541
Updated the #if for Snow Leopard/Leopard builds to handle them not being defined properly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
718
diff
changeset
|
1853 #ifdef BUILDING_FOR_SNOW_LEOPARD |
717
17923b931393
Fixes for building for MacOS 10.5 and PPC
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
715
diff
changeset
|
1854 applicationName = [[NSRunningApplication currentApplication] localizedName]; |
17923b931393
Fixes for building for MacOS 10.5 and PPC
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
715
diff
changeset
|
1855 #endif |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1856 if(applicationName == nil) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1857 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1858 applicationName = [[NSProcessInfo processInfo] processName]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1859 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1860 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1861 /* Create the main menu */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1862 NSMenu * mainMenu = [[[NSMenu alloc] initWithTitle:@"MainMenu"] autorelease]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1863 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1864 NSMenuItem * mitem = [mainMenu addItemWithTitle:@"Apple" action:NULL keyEquivalent:@""]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1865 NSMenu * menu = [[[NSMenu alloc] initWithTitle:@"Apple"] autorelease]; |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
1866 |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1867 [DWApp performSelector:@selector(setAppleMenu:) withObject:menu]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1868 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1869 /* Setup the Application menu */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1870 NSMenuItem * item = [menu addItemWithTitle:[NSString stringWithFormat:@"%@ %@", NSLocalizedString(@"About", nil), applicationName] |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
1871 action:@selector(orderFrontStandardAboutPanel:) |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
1872 keyEquivalent:@""]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1873 [item setTarget:DWApp]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1874 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1875 [menu addItem:[NSMenuItem separatorItem]]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1876 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1877 item = [menu addItemWithTitle:NSLocalizedString(@"Services", nil) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1878 action:NULL |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1879 keyEquivalent:@""]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1880 NSMenu * servicesMenu = [[[NSMenu alloc] initWithTitle:@"Services"] autorelease]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1881 [menu setSubmenu:servicesMenu forItem:item]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1882 [DWApp setServicesMenu:servicesMenu]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1883 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1884 [menu addItem:[NSMenuItem separatorItem]]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1885 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1886 item = [menu addItemWithTitle:[NSString stringWithFormat:@"%@ %@", NSLocalizedString(@"Hide", nil), applicationName] |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1887 action:@selector(hide:) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1888 keyEquivalent:@"h"]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1889 [item setTarget:DWApp]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1890 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1891 item = [menu addItemWithTitle:NSLocalizedString(@"Hide Others", nil) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1892 action:@selector(hideOtherApplications:) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1893 keyEquivalent:@"h"]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1894 [item setKeyEquivalentModifierMask:NSCommandKeyMask | NSAlternateKeyMask]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1895 [item setTarget:DWApp]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1896 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1897 item = [menu addItemWithTitle:NSLocalizedString(@"Show All", nil) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1898 action:@selector(unhideAllApplications:) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1899 keyEquivalent:@""]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1900 [item setTarget:DWApp]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1901 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1902 [menu addItem:[NSMenuItem separatorItem]]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1903 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1904 item = [menu addItemWithTitle:[NSString stringWithFormat:@"%@ %@", NSLocalizedString(@"Quit", nil), applicationName] |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1905 action:@selector(terminate:) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1906 keyEquivalent:@"q"]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1907 [item setTarget:DWApp]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1908 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1909 [mainMenu setSubmenu:menu forItem:mitem]; |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
1910 |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
1911 return mainMenu; |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
1912 } |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
1913 |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
1914 /* |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1915 * Runs a message loop for Dynamic Windows. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1916 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1917 void API dw_main(void) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1918 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
1919 dw_mutex_lock(DWRunMutex); |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
1920 DWThread = dw_thread_id(); |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1921 [DWApp run]; |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
1922 DWThread = (DWTID)-1; |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
1923 dw_mutex_unlock(DWRunMutex); |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1924 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1925 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1926 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1927 * Runs a message loop for Dynamic Windows, for a period of milliseconds. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1928 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1929 * milliseconds: Number of milliseconds to run the loop for. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1930 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1931 void API dw_main_sleep(int milliseconds) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1932 { |
694
130ca42c4ae3
Reimplementation of dw_main_iteration and dw_main_sleep that actually work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
693
diff
changeset
|
1933 DWTID curr = pthread_self(); |
130ca42c4ae3
Reimplementation of dw_main_iteration and dw_main_sleep that actually work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
693
diff
changeset
|
1934 |
130ca42c4ae3
Reimplementation of dw_main_iteration and dw_main_sleep that actually work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
693
diff
changeset
|
1935 if(DWThread == (DWTID)-1 || DWThread == curr) |
130ca42c4ae3
Reimplementation of dw_main_iteration and dw_main_sleep that actually work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
693
diff
changeset
|
1936 { |
130ca42c4ae3
Reimplementation of dw_main_iteration and dw_main_sleep that actually work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
693
diff
changeset
|
1937 DWTID orig = DWThread; |
725
4e09c92363df
Experimental changes to dw_main_sleep() and dw_main_iteration() to hopefully solve some issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
724
diff
changeset
|
1938 NSDate *until = [NSDate dateWithTimeIntervalSinceNow:(milliseconds/1000.0)]; |
694
130ca42c4ae3
Reimplementation of dw_main_iteration and dw_main_sleep that actually work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
693
diff
changeset
|
1939 |
695
3b17111499bf
Minor updates to the last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
694
diff
changeset
|
1940 if(orig == (DWTID)-1) |
3b17111499bf
Minor updates to the last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
694
diff
changeset
|
1941 { |
728
55f22b39ab57
Changes to correctly set the main thread and lock the run mutex when not running a loop and when called from a callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
727
diff
changeset
|
1942 dw_mutex_lock(DWRunMutex); |
695
3b17111499bf
Minor updates to the last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
694
diff
changeset
|
1943 DWThread = curr; |
3b17111499bf
Minor updates to the last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
694
diff
changeset
|
1944 } |
725
4e09c92363df
Experimental changes to dw_main_sleep() and dw_main_iteration() to hopefully solve some issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
724
diff
changeset
|
1945 /* Process any pending events */ |
4e09c92363df
Experimental changes to dw_main_sleep() and dw_main_iteration() to hopefully solve some issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
724
diff
changeset
|
1946 while(_dw_main_iteration(until)) |
694
130ca42c4ae3
Reimplementation of dw_main_iteration and dw_main_sleep that actually work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
693
diff
changeset
|
1947 { |
725
4e09c92363df
Experimental changes to dw_main_sleep() and dw_main_iteration() to hopefully solve some issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
724
diff
changeset
|
1948 /* Just loop */ |
695
3b17111499bf
Minor updates to the last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
694
diff
changeset
|
1949 } |
3b17111499bf
Minor updates to the last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
694
diff
changeset
|
1950 if(orig == (DWTID)-1) |
3b17111499bf
Minor updates to the last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
694
diff
changeset
|
1951 { |
3b17111499bf
Minor updates to the last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
694
diff
changeset
|
1952 DWThread = orig; |
728
55f22b39ab57
Changes to correctly set the main thread and lock the run mutex when not running a loop and when called from a callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
727
diff
changeset
|
1953 dw_mutex_unlock(DWRunMutex); |
694
130ca42c4ae3
Reimplementation of dw_main_iteration and dw_main_sleep that actually work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
693
diff
changeset
|
1954 } |
130ca42c4ae3
Reimplementation of dw_main_iteration and dw_main_sleep that actually work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
693
diff
changeset
|
1955 } |
130ca42c4ae3
Reimplementation of dw_main_iteration and dw_main_sleep that actually work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
693
diff
changeset
|
1956 else |
725
4e09c92363df
Experimental changes to dw_main_sleep() and dw_main_iteration() to hopefully solve some issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
724
diff
changeset
|
1957 { |
694
130ca42c4ae3
Reimplementation of dw_main_iteration and dw_main_sleep that actually work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
693
diff
changeset
|
1958 usleep(milliseconds * 1000); |
725
4e09c92363df
Experimental changes to dw_main_sleep() and dw_main_iteration() to hopefully solve some issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
724
diff
changeset
|
1959 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1960 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1961 |
700
7953f0471e4d
Some cleanups for the run loop iteration and thread system.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
699
diff
changeset
|
1962 /* Internal version that doesn't lock the run mutex */ |
725
4e09c92363df
Experimental changes to dw_main_sleep() and dw_main_iteration() to hopefully solve some issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
724
diff
changeset
|
1963 int _dw_main_iteration(NSDate *date) |
4e09c92363df
Experimental changes to dw_main_sleep() and dw_main_iteration() to hopefully solve some issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
724
diff
changeset
|
1964 { |
694
130ca42c4ae3
Reimplementation of dw_main_iteration and dw_main_sleep that actually work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
693
diff
changeset
|
1965 NSEvent *event = [DWApp nextEventMatchingMask:NSAnyEventMask |
725
4e09c92363df
Experimental changes to dw_main_sleep() and dw_main_iteration() to hopefully solve some issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
724
diff
changeset
|
1966 untilDate:date |
694
130ca42c4ae3
Reimplementation of dw_main_iteration and dw_main_sleep that actually work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
693
diff
changeset
|
1967 inMode:NSDefaultRunLoopMode |
130ca42c4ae3
Reimplementation of dw_main_iteration and dw_main_sleep that actually work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
693
diff
changeset
|
1968 dequeue:YES]; |
130ca42c4ae3
Reimplementation of dw_main_iteration and dw_main_sleep that actually work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
693
diff
changeset
|
1969 if(event) |
130ca42c4ae3
Reimplementation of dw_main_iteration and dw_main_sleep that actually work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
693
diff
changeset
|
1970 { |
130ca42c4ae3
Reimplementation of dw_main_iteration and dw_main_sleep that actually work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
693
diff
changeset
|
1971 [DWApp sendEvent:event]; |
725
4e09c92363df
Experimental changes to dw_main_sleep() and dw_main_iteration() to hopefully solve some issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
724
diff
changeset
|
1972 [DWApp updateWindows]; |
4e09c92363df
Experimental changes to dw_main_sleep() and dw_main_iteration() to hopefully solve some issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
724
diff
changeset
|
1973 return 1; |
694
130ca42c4ae3
Reimplementation of dw_main_iteration and dw_main_sleep that actually work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
693
diff
changeset
|
1974 } |
725
4e09c92363df
Experimental changes to dw_main_sleep() and dw_main_iteration() to hopefully solve some issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
724
diff
changeset
|
1975 return 0; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1976 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1977 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1978 /* |
700
7953f0471e4d
Some cleanups for the run loop iteration and thread system.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
699
diff
changeset
|
1979 * Processes a single message iteration and returns. |
7953f0471e4d
Some cleanups for the run loop iteration and thread system.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
699
diff
changeset
|
1980 */ |
7953f0471e4d
Some cleanups for the run loop iteration and thread system.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
699
diff
changeset
|
1981 void API dw_main_iteration(void) |
7953f0471e4d
Some cleanups for the run loop iteration and thread system.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
699
diff
changeset
|
1982 { |
728
55f22b39ab57
Changes to correctly set the main thread and lock the run mutex when not running a loop and when called from a callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
727
diff
changeset
|
1983 DWTID curr = pthread_self(); |
55f22b39ab57
Changes to correctly set the main thread and lock the run mutex when not running a loop and when called from a callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
727
diff
changeset
|
1984 |
55f22b39ab57
Changes to correctly set the main thread and lock the run mutex when not running a loop and when called from a callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
727
diff
changeset
|
1985 if(DWThread == (DWTID)-1) |
55f22b39ab57
Changes to correctly set the main thread and lock the run mutex when not running a loop and when called from a callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
727
diff
changeset
|
1986 { |
55f22b39ab57
Changes to correctly set the main thread and lock the run mutex when not running a loop and when called from a callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
727
diff
changeset
|
1987 dw_mutex_lock(DWRunMutex); |
55f22b39ab57
Changes to correctly set the main thread and lock the run mutex when not running a loop and when called from a callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
727
diff
changeset
|
1988 DWThread = curr; |
55f22b39ab57
Changes to correctly set the main thread and lock the run mutex when not running a loop and when called from a callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
727
diff
changeset
|
1989 _dw_main_iteration([NSDate distantPast]); |
55f22b39ab57
Changes to correctly set the main thread and lock the run mutex when not running a loop and when called from a callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
727
diff
changeset
|
1990 DWThread = (DWTID)-1; |
55f22b39ab57
Changes to correctly set the main thread and lock the run mutex when not running a loop and when called from a callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
727
diff
changeset
|
1991 dw_mutex_unlock(DWRunMutex); |
55f22b39ab57
Changes to correctly set the main thread and lock the run mutex when not running a loop and when called from a callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
727
diff
changeset
|
1992 } |
55f22b39ab57
Changes to correctly set the main thread and lock the run mutex when not running a loop and when called from a callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
727
diff
changeset
|
1993 else if(DWThread == curr) |
55f22b39ab57
Changes to correctly set the main thread and lock the run mutex when not running a loop and when called from a callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
727
diff
changeset
|
1994 { |
55f22b39ab57
Changes to correctly set the main thread and lock the run mutex when not running a loop and when called from a callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
727
diff
changeset
|
1995 _dw_main_iteration([NSDate distantPast]); |
55f22b39ab57
Changes to correctly set the main thread and lock the run mutex when not running a loop and when called from a callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
727
diff
changeset
|
1996 } |
700
7953f0471e4d
Some cleanups for the run loop iteration and thread system.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
699
diff
changeset
|
1997 } |
7953f0471e4d
Some cleanups for the run loop iteration and thread system.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
699
diff
changeset
|
1998 |
7953f0471e4d
Some cleanups for the run loop iteration and thread system.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
699
diff
changeset
|
1999 /* |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2000 * Cleanly terminates a DW session, should be signal handler safe. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2001 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2002 * exitcode: Exit code reported to the operating system. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2003 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2004 void API dw_exit(int exitcode) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2005 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2006 exit(exitcode); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2007 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2008 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2009 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2010 * Free's memory allocated by dynamic windows. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2011 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2012 * ptr: Pointer to dynamic windows allocated |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2013 * memory to be free()'d. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2014 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2015 void API dw_free(void *ptr) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2016 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2017 free(ptr); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2018 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2019 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2020 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2021 * Returns a pointer to a static buffer which containes the |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2022 * current user directory. Or the root directory (C:\ on |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2023 * OS/2 and Windows). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2024 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2025 char *dw_user_dir(void) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2026 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2027 static char _user_dir[1024] = ""; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2028 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2029 if(!_user_dir[0]) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2030 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2031 char *home = getenv("HOME"); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2032 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2033 if(home) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2034 strcpy(_user_dir, home); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2035 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2036 strcpy(_user_dir, "/"); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2037 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2038 return _user_dir; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2039 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2040 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2041 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2042 * Displays a Message Box with given text and title.. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2043 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2044 * title: The title of the message box. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2045 * flags: flags to indicate buttons and icon |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2046 * format: printf style format string. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2047 * ...: Additional variables for use in the format. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2048 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2049 int API dw_messagebox(char *title, int flags, char *format, ...) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2050 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2051 int iResponse; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2052 NSString *button1 = @"OK"; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2053 NSString *button2 = nil; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2054 NSString *button3 = nil; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2055 va_list args; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2056 char outbuf[1000]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2057 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2058 va_start(args, format); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2059 vsprintf(outbuf, format, args); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2060 va_end(args); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2061 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2062 if(flags & DW_MB_OKCANCEL) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2063 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2064 button2 = @"Cancel"; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2065 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2066 else if(flags & DW_MB_YESNO) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2067 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2068 button1 = @"Yes"; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2069 button2 = @"No"; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2070 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2071 else if(flags & DW_MB_YESNOCANCEL) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2072 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2073 button1 = @"Yes"; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2074 button2 = @"No"; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2075 button3 = @"Cancel"; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2076 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2077 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2078 if(flags & DW_MB_ERROR) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2079 { |
665
e6bec2290f3f
Fixing warnings with Xcode 4 and switched to manual releasing in the draw functions to stop leaking.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
664
diff
changeset
|
2080 iResponse = (int) |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2081 NSRunCriticalAlertPanel([ NSString stringWithUTF8String:title ], |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2082 [ NSString stringWithUTF8String:outbuf ], |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2083 button1, button2, button3); } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2084 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2085 { |
665
e6bec2290f3f
Fixing warnings with Xcode 4 and switched to manual releasing in the draw functions to stop leaking.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
664
diff
changeset
|
2086 iResponse = (int) |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2087 NSRunAlertPanel([ NSString stringWithUTF8String:title ], |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2088 [ NSString stringWithUTF8String:outbuf ], |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2089 button1, button2, button3); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2090 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2091 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2092 switch(iResponse) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2093 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2094 case NSAlertDefaultReturn: /* user pressed OK */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2095 if(flags & DW_MB_YESNO || flags & DW_MB_YESNOCANCEL) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2096 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2097 return DW_MB_RETURN_YES; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2098 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2099 return DW_MB_RETURN_OK; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2100 case NSAlertAlternateReturn: /* user pressed Cancel */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2101 if(flags & DW_MB_OKCANCEL) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2102 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2103 return DW_MB_RETURN_CANCEL; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2104 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2105 return DW_MB_RETURN_NO; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2106 case NSAlertOtherReturn: /* user pressed the third button */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2107 return DW_MB_RETURN_CANCEL; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2108 case NSAlertErrorReturn: /* an error occurred */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2109 break; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2110 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2111 return 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2112 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2113 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2114 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2115 * Opens a file dialog and queries user selection. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2116 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2117 * title: Title bar text for dialog. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2118 * defpath: The default path of the open dialog. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2119 * ext: Default file extention. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2120 * flags: DW_FILE_OPEN or DW_FILE_SAVE. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2121 * Returns: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2122 * NULL on error. A malloced buffer containing |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2123 * the file path on success. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2124 * |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2125 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2126 char * API dw_file_browse(char *title, char *defpath, char *ext, int flags) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2127 { |
651
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2128 if(flags == DW_FILE_OPEN) |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2129 { |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2130 /* Create the File Open Dialog class. */ |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2131 NSOpenPanel* openDlg = [NSOpenPanel openPanel]; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2132 |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2133 /* Enable the selection of files in the dialog. */ |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2134 [openDlg setCanChooseFiles:YES]; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2135 [openDlg setCanChooseDirectories:NO]; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2136 |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2137 /* Disable multiple selection */ |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2138 [openDlg setAllowsMultipleSelection:NO]; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2139 |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2140 /* Display the dialog. If the OK button was pressed, |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2141 * process the files. |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2142 */ |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2143 if([openDlg runModal] == NSOKButton) |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2144 { |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2145 /* Get an array containing the full filenames of all |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2146 * files and directories selected. |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2147 */ |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2148 NSArray* files = [openDlg filenames]; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2149 NSString* fileName = [files objectAtIndex:0]; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2150 return strdup([ fileName UTF8String ]); |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2151 } |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2152 } |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2153 else |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2154 { |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2155 /* Create the File Save Dialog class. */ |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2156 NSSavePanel* saveDlg = [NSSavePanel savePanel]; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2157 |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
2158 /* Enable the creation of directories in the dialog. */ |
651
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2159 [saveDlg setCanCreateDirectories:YES]; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2160 |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2161 /* Display the dialog. If the OK button was pressed, |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2162 * process the files. |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2163 */ |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2164 if([saveDlg runModal] == NSFileHandlingPanelOKButton) |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2165 { |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2166 /* Get an array containing the full filenames of all |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2167 * files and directories selected. |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2168 */ |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2169 NSString* fileName = [saveDlg filename]; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2170 return strdup([ fileName UTF8String ]); |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2171 } |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2172 } |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2173 |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2174 return NULL; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2175 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2176 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2177 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2178 * Gets the contents of the default clipboard as text. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2179 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2180 * None. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2181 * Returns: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2182 * Pointer to an allocated string of text or NULL if clipboard empty or contents could not |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2183 * be converted to text. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2184 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2185 char *dw_clipboard_get_text() |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2186 { |
651
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2187 NSPasteboard *pasteboard = [NSPasteboard generalPasteboard]; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2188 NSString *str = [pasteboard stringForType:NSStringPboardType]; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2189 if(str != nil) |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2190 { |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2191 return strdup([ str UTF8String ]); |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2192 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2193 return NULL; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2194 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2195 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2196 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2197 * Sets the contents of the default clipboard to the supplied text. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2198 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2199 * Text. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2200 */ |
651
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2201 void dw_clipboard_set_text( char *str, int len) |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2202 { |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2203 NSPasteboard *pasteboard = [NSPasteboard generalPasteboard]; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2204 |
719
d5e49ef8f541
Updated the #if for Snow Leopard/Leopard builds to handle them not being defined properly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
718
diff
changeset
|
2205 #ifdef BUILDING_FOR_SNOW_LEOPARD |
651
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2206 [pasteboard clearContents]; |
718
002f33d4439d
More 10.5 fixes... some selectors cause exceptions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
717
diff
changeset
|
2207 #endif |
651
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2208 |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2209 [pasteboard setString:[ NSString stringWithUTF8String:str ] forType:NSStringPboardType]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2210 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2211 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2212 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2213 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2214 * Allocates and initializes a dialog struct. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2215 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2216 * data: User defined data to be passed to functions. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2217 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2218 DWDialog * API dw_dialog_new(void *data) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2219 { |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
2220 DWDialog *tmp = malloc(sizeof(DWDialog)); |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
2221 |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
2222 if(tmp) |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
2223 { |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
2224 tmp->eve = dw_event_new(); |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
2225 dw_event_reset(tmp->eve); |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
2226 tmp->data = data; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
2227 tmp->done = FALSE; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
2228 tmp->result = NULL; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
2229 } |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
2230 return tmp; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2231 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2232 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2233 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2234 * Accepts a dialog struct and returns the given data to the |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2235 * initial called of dw_dialog_wait(). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2236 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2237 * dialog: Pointer to a dialog struct aquired by dw_dialog_new). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2238 * result: Data to be returned by dw_dialog_wait(). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2239 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2240 int API dw_dialog_dismiss(DWDialog *dialog, void *result) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2241 { |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
2242 dialog->result = result; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
2243 dw_event_post(dialog->eve); |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
2244 dialog->done = TRUE; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2245 return 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2246 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2247 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2248 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2249 * Accepts a dialog struct waits for dw_dialog_dismiss() to be |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2250 * called by a signal handler with the given dialog struct. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2251 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2252 * dialog: Pointer to a dialog struct aquired by dw_dialog_new). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2253 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2254 void * API dw_dialog_wait(DWDialog *dialog) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2255 { |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
2256 void *tmp; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
2257 |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
2258 while(!dialog->done) |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
2259 { |
725
4e09c92363df
Experimental changes to dw_main_sleep() and dw_main_iteration() to hopefully solve some issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
724
diff
changeset
|
2260 _dw_main_iteration([NSDate dateWithTimeIntervalSinceNow:0.01]); |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
2261 } |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
2262 dw_event_close(&dialog->eve); |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
2263 tmp = dialog->result; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
2264 free(dialog); |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
2265 return tmp; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2266 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2267 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2268 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2269 * Create a new Box to be packed. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2270 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2271 * type: Either DW_VERT (vertical) or DW_HORZ (horizontal). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2272 * pad: Number of pixels to pad around the box. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2273 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2274 HWND API dw_box_new(int type, int pad) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2275 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
2276 int _locked_by_me = FALSE; |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
2277 DW_MUTEX_LOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2278 DWBox *view = [[DWBox alloc] init]; |
666
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
2279 Box *newbox = [view box]; |
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
2280 memset(newbox, 0, sizeof(Box)); |
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
2281 newbox->pad = pad; |
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
2282 newbox->type = type; |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
2283 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2284 return view; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2285 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2286 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2287 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2288 * Create a new Group Box to be packed. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2289 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2290 * type: Either DW_VERT (vertical) or DW_HORZ (horizontal). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2291 * pad: Number of pixels to pad around the box. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2292 * title: Text to be displayined in the group outline. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2293 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2294 HWND API dw_groupbox_new(int type, int pad, char *title) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2295 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2296 DWBox *box = dw_box_new(type, pad); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2297 [box setFocusRingType:NSFocusRingTypeExterior]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2298 return box; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2299 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2300 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2301 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2302 * Pack windows (widgets) into a box from the end (or bottom). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2303 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2304 * box: Window handle of the box to be packed into. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2305 * item: Window handle of the item to be back. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2306 * width: Width in pixels of the item or -1 to be self determined. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2307 * height: Height in pixels of the item or -1 to be self determined. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2308 * hsize: TRUE if the window (widget) should expand horizontally to fill space given. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2309 * vsize: TRUE if the window (widget) should expand vertically to fill space given. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2310 * pad: Number of pixels of padding around the item. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2311 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2312 void API dw_box_pack_end(HWND box, HWND item, int width, int height, int hsize, int vsize, int pad) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2313 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
2314 int _locked_by_me = FALSE; |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
2315 DW_MUTEX_LOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2316 NSObject *object = box; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2317 DWBox *view = box; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2318 DWBox *this = item; |
666
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
2319 Box *thisbox; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2320 int z; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2321 Item *tmpitem, *thisitem; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2322 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2323 /* Query the objects */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2324 if([ object isKindOfClass:[ NSWindow class ] ]) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2325 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2326 NSWindow *window = box; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2327 view = [window contentView]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2328 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2329 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2330 thisbox = [view box]; |
666
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
2331 thisitem = thisbox->items; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2332 object = item; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2333 |
668
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
2334 /* Query the objects */ |
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
2335 if([ object isKindOfClass:[ DWContainer class ] ]) |
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
2336 { |
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
2337 DWContainer *cont = item; |
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
2338 this = item = [cont scrollview]; |
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
2339 } |
682
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
2340 else if([ object isKindOfClass:[ DWTree class ] ]) |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
2341 { |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
2342 DWTree *tree = item; |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
2343 this = item = [tree scrollview]; |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
2344 } |
668
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
2345 |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2346 /* Duplicate the existing data */ |
666
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
2347 tmpitem = malloc(sizeof(Item)*(thisbox->count+1)); |
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
2348 |
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
2349 for(z=0;z<thisbox->count;z++) |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2350 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2351 tmpitem[z+1] = thisitem[z]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2352 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2353 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2354 /* Sanity checks */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2355 if(vsize && !height) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2356 height = 1; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2357 if(hsize && !width) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2358 width = 1; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2359 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2360 /* Fill in the item data appropriately */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2361 if([ object isKindOfClass:[ DWBox class ] ]) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2362 tmpitem[0].type = TYPEBOX; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2363 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2364 tmpitem[0].type = TYPEITEM; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2365 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2366 tmpitem[0].hwnd = item; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2367 tmpitem[0].origwidth = tmpitem[0].width = width; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2368 tmpitem[0].origheight = tmpitem[0].height = height; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2369 tmpitem[0].pad = pad; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2370 if(hsize) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2371 tmpitem[0].hsize = SIZEEXPAND; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2372 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2373 tmpitem[0].hsize = SIZESTATIC; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2374 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2375 if(vsize) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2376 tmpitem[0].vsize = SIZEEXPAND; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2377 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2378 tmpitem[0].vsize = SIZESTATIC; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2379 |
666
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
2380 thisbox->items = tmpitem; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2381 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2382 /* Update the item count */ |
666
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
2383 thisbox->count++; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2384 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2385 /* Add the item to the box */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2386 [view addSubview:this]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2387 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2388 /* Free the old data */ |
666
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
2389 if(thisbox->count) |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2390 free(thisitem); |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
2391 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2392 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2393 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2394 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2395 * Pack windows (widgets) into a box from the start (or top). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2396 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2397 * box: Window handle of the box to be packed into. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2398 * item: Window handle of the item to be back. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2399 * width: Width in pixels of the item or -1 to be self determined. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2400 * height: Height in pixels of the item or -1 to be self determined. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2401 * hsize: TRUE if the window (widget) should expand horizontally to fill space given. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2402 * vsize: TRUE if the window (widget) should expand vertically to fill space given. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2403 * pad: Number of pixels of padding around the item. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2404 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2405 void API dw_box_pack_start(HWND box, HWND item, int width, int height, int hsize, int vsize, int pad) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2406 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
2407 int _locked_by_me = FALSE; |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
2408 DW_MUTEX_LOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2409 NSObject *object = box; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2410 DWBox *view = box; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2411 DWBox *this = item; |
666
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
2412 Box *thisbox; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2413 int z; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2414 Item *tmpitem, *thisitem; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2415 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2416 /* Query the objects */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2417 if([ object isKindOfClass:[ NSWindow class ] ]) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2418 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2419 NSWindow *window = box; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2420 view = [window contentView]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2421 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2422 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2423 thisbox = [view box]; |
666
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
2424 thisitem = thisbox->items; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2425 object = item; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2426 |
668
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
2427 /* Query the objects */ |
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
2428 if([ object isKindOfClass:[ DWContainer class ] ]) |
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
2429 { |
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
2430 DWContainer *cont = item; |
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
2431 this = item = [cont scrollview]; |
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
2432 } |
682
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
2433 else if([ object isKindOfClass:[ DWTree class ] ]) |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
2434 { |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
2435 DWTree *tree = item; |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
2436 this = item = [tree scrollview]; |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
2437 } |
668
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
2438 |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2439 /* Duplicate the existing data */ |
666
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
2440 tmpitem = malloc(sizeof(Item)*(thisbox->count+1)); |
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
2441 |
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
2442 for(z=0;z<thisbox->count;z++) |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2443 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2444 tmpitem[z] = thisitem[z]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2445 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2446 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2447 /* Sanity checks */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2448 if(vsize && !height) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2449 height = 1; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2450 if(hsize && !width) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2451 width = 1; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2452 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2453 /* Fill in the item data appropriately */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2454 if([ object isKindOfClass:[ DWBox class ] ]) |
666
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
2455 tmpitem[thisbox->count].type = TYPEBOX; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2456 else |
666
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
2457 tmpitem[thisbox->count].type = TYPEITEM; |
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
2458 |
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
2459 tmpitem[thisbox->count].hwnd = item; |
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
2460 tmpitem[thisbox->count].origwidth = tmpitem[thisbox->count].width = width; |
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
2461 tmpitem[thisbox->count].origheight = tmpitem[thisbox->count].height = height; |
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
2462 tmpitem[thisbox->count].pad = pad; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2463 if(hsize) |
666
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
2464 tmpitem[thisbox->count].hsize = SIZEEXPAND; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2465 else |
666
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
2466 tmpitem[thisbox->count].hsize = SIZESTATIC; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2467 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2468 if(vsize) |
666
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
2469 tmpitem[thisbox->count].vsize = SIZEEXPAND; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2470 else |
666
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
2471 tmpitem[thisbox->count].vsize = SIZESTATIC; |
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
2472 |
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
2473 thisbox->items = tmpitem; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2474 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2475 /* Update the item count */ |
666
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
2476 thisbox->count++; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2477 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2478 /* Add the item to the box */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2479 [view addSubview:this]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2480 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2481 /* Free the old data */ |
666
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
2482 if(thisbox->count) |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2483 free(thisitem); |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
2484 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2485 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2486 |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
2487 HWND _button_new(char *text, ULONG cid) |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2488 { |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2489 DWButton *button = [[DWButton alloc] init]; |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2490 if(text && *text) |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2491 { |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2492 [button setTitle:[ NSString stringWithUTF8String:text ]]; |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2493 } |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2494 [button setTarget:button]; |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2495 [button setAction:@selector(buttonClicked:)]; |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
2496 [button setTag:cid]; |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2497 [button setButtonType:NSMomentaryPushInButton]; |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2498 [button setBezelStyle:NSThickerSquareBezelStyle]; |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2499 return button; |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2500 } |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2501 |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2502 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2503 * Create a new button window (widget) to be packed. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2504 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2505 * text: The text to be display by the static text widget. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2506 * id: An ID to be used with dw_window_from_id() or 0L. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2507 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
2508 HWND API dw_button_new(char *text, ULONG cid) |
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
2509 { |
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
2510 DWButton *button = _button_new(text, cid); |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2511 [button setButtonType:NSMomentaryPushInButton]; |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2512 [button setBezelStyle:NSRoundedBezelStyle]; |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2513 [button setImagePosition:NSNoImage]; |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2514 [button setAlignment:NSCenterTextAlignment]; |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2515 [[button cell] setControlTint:NSBlueControlTint]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2516 return button; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2517 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2518 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2519 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2520 * Create a new Entryfield window (widget) to be packed. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2521 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2522 * text: The default text to be in the entryfield widget. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2523 * id: An ID to be used with dw_window_from_id() or 0L. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2524 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
2525 HWND API dw_entryfield_new(char *text, ULONG cid) |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2526 { |
651
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2527 DWEntryField *entry = [[DWEntryField alloc] init]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2528 [entry setStringValue:[ NSString stringWithUTF8String:text ]]; |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
2529 [entry setTag:cid]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2530 return entry; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2531 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2532 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2533 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2534 * Create a new Entryfield (password) window (widget) to be packed. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2535 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2536 * text: The default text to be in the entryfield widget. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2537 * id: An ID to be used with dw_window_from_id() or 0L. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2538 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
2539 HWND API dw_entryfield_password_new(char *text, ULONG cid) |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2540 { |
651
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2541 DWEntryFieldPassword *entry = [[DWEntryFieldPassword alloc] init]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2542 [entry setStringValue:[ NSString stringWithUTF8String:text ]]; |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
2543 [entry setTag:cid]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2544 return entry; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2545 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2546 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2547 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2548 * Sets the entryfield character limit. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2549 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2550 * handle: Handle to the spinbutton to be set. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2551 * limit: Number of characters the entryfield will take. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2552 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2553 void API dw_entryfield_set_limit(HWND handle, ULONG limit) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2554 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2555 NSLog(@"dw_entryfield_set_limit() unimplemented\n"); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2556 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2557 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2558 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2559 * Create a new bitmap button window (widget) to be packed. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2560 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2561 * text: Bubble help text to be displayed. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2562 * id: An ID of a bitmap in the resource file. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2563 */ |
670
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
2564 HWND API dw_bitmapbutton_new(char *text, ULONG resid) |
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
2565 { |
671
c60a4f6cfae8
Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
670
diff
changeset
|
2566 /* TODO: Implement tooltips */ |
670
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
2567 NSBundle *bundle = [NSBundle mainBundle]; |
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
2568 NSString *respath = [bundle resourcePath]; |
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
2569 NSString *filepath = [respath stringByAppendingFormat:@"/%u.png", resid]; |
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
2570 NSImage *image = [[NSImage alloc] initWithContentsOfFile:filepath]; |
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
2571 DWButton *button = _button_new("", resid); |
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
2572 [button setImage:image]; |
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
2573 //[button setBezelStyle:0]; |
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
2574 [button setButtonType:NSMomentaryLight]; |
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
2575 [button setBordered:NO]; |
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
2576 [image release]; |
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
2577 return button; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2578 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2579 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2580 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2581 * Create a new bitmap button window (widget) to be packed from a file. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2582 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2583 * text: Bubble help text to be displayed. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2584 * id: An ID to be used with dw_window_from_id() or 0L. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2585 * filename: Name of the file, omit extention to have |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2586 * DW pick the appropriate file extension. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2587 * (BMP on OS/2 or Windows, XPM on Unix) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2588 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
2589 HWND API dw_bitmapbutton_new_from_file(char *text, unsigned long cid, char *filename) |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2590 { |
674
78f9aa6d6d89
Fixes or fonts and loading images from files. Added Mac specific settings to dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
673
diff
changeset
|
2591 NSString *nstr = [ NSString stringWithUTF8String:filename ]; |
78f9aa6d6d89
Fixes or fonts and loading images from files. Added Mac specific settings to dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
673
diff
changeset
|
2592 NSImage *image = [[NSImage alloc] initWithContentsOfFile:nstr]; |
78f9aa6d6d89
Fixes or fonts and loading images from files. Added Mac specific settings to dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
673
diff
changeset
|
2593 if(!image) |
78f9aa6d6d89
Fixes or fonts and loading images from files. Added Mac specific settings to dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
673
diff
changeset
|
2594 { |
78f9aa6d6d89
Fixes or fonts and loading images from files. Added Mac specific settings to dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
673
diff
changeset
|
2595 nstr = [nstr stringByAppendingString:@".png"]; |
78f9aa6d6d89
Fixes or fonts and loading images from files. Added Mac specific settings to dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
673
diff
changeset
|
2596 image = [[NSImage alloc] initWithContentsOfFile:nstr]; |
78f9aa6d6d89
Fixes or fonts and loading images from files. Added Mac specific settings to dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
673
diff
changeset
|
2597 } |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
2598 DWButton *button = _button_new("", cid); |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
2599 [button setImage:image]; |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
2600 [image release]; |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
2601 return button; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2602 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2603 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2604 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2605 * Create a new bitmap button window (widget) to be packed from data. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2606 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2607 * text: Bubble help text to be displayed. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2608 * id: An ID to be used with dw_window_from_id() or 0L. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2609 * data: The contents of the image |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2610 * (BMP or ICO on OS/2 or Windows, XPM on Unix) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2611 * len: length of str |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2612 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
2613 HWND API dw_bitmapbutton_new_from_data(char *text, unsigned long cid, char *data, int len) |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2614 { |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
2615 NSData *thisdata = [[NSData alloc] dataWithBytes:data length:len]; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
2616 NSImage *image = [[NSImage alloc] initWithData:thisdata]; |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
2617 DWButton *button = _button_new("", cid); |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
2618 [button setImage:image]; |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
2619 [image release]; |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
2620 return button; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2621 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2622 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2623 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2624 * Create a new spinbutton window (widget) to be packed. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2625 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2626 * text: The text to be display by the static text widget. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2627 * id: An ID to be used with dw_window_from_id() or 0L. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2628 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
2629 HWND API dw_spinbutton_new(char *text, ULONG cid) |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2630 { |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
2631 DWSpinButton *spinbutton = [[DWSpinButton alloc] init]; |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
2632 NSStepper *stepper = [spinbutton stepper]; |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
2633 [stepper setIncrement:1]; |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
2634 [stepper setTag:cid]; |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
2635 return spinbutton; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2636 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2637 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2638 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2639 * Sets the spinbutton value. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2640 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2641 * handle: Handle to the spinbutton to be set. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2642 * position: Current value of the spinbutton. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2643 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2644 void API dw_spinbutton_set_pos(HWND handle, long position) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2645 { |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
2646 DWSpinButton *spinbutton = handle; |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
2647 NSStepper *stepper = [spinbutton stepper]; |
679
d2d7d1802af4
Implemented a rather hacky fix for the spinbutton issues. The stepper control is really poorly
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
678
diff
changeset
|
2648 NSTextField *textfield = [spinbutton textfield]; |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
2649 [stepper setIntValue:(int)position]; |
679
d2d7d1802af4
Implemented a rather hacky fix for the spinbutton issues. The stepper control is really poorly
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
678
diff
changeset
|
2650 [textfield takeIntValueFrom:stepper]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2651 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2652 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2653 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2654 * Sets the spinbutton limits. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2655 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2656 * handle: Handle to the spinbutton to be set. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2657 * upper: Upper limit. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2658 * lower: Lower limit. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2659 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2660 void API dw_spinbutton_set_limits(HWND handle, long upper, long lower) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2661 { |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
2662 DWSpinButton *spinbutton = handle; |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
2663 NSStepper *stepper = [spinbutton stepper]; |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
2664 [stepper setMinValue:(double)lower]; |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
2665 [stepper setMaxValue:(double)upper]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2666 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2667 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2668 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2669 * Returns the current value of the spinbutton. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2670 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2671 * handle: Handle to the spinbutton to be queried. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2672 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2673 long API dw_spinbutton_get_pos(HWND handle) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2674 { |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
2675 DWSpinButton *spinbutton = handle; |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
2676 NSStepper *stepper = [spinbutton stepper]; |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
2677 return (long)[stepper integerValue]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2678 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2679 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2680 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2681 * Create a new radiobutton window (widget) to be packed. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2682 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2683 * text: The text to be display by the static text widget. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2684 * id: An ID to be used with dw_window_from_id() or 0L. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2685 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
2686 HWND API dw_radiobutton_new(char *text, ULONG cid) |
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
2687 { |
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
2688 DWButton *button = _button_new(text, cid); |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2689 [button setButtonType:NSRadioButton]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2690 return button; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2691 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2692 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2693 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2694 * Create a new slider window (widget) to be packed. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2695 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2696 * vertical: TRUE or FALSE if slider is vertical. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2697 * increments: Number of increments available. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2698 * id: An ID to be used with dw_window_from_id() or 0L. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2699 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
2700 HWND API dw_slider_new(int vertical, int increments, ULONG cid) |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2701 { |
704
336800e9e648
Fixes to the slider control so events happen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
703
diff
changeset
|
2702 DWSlider *slider = [[DWSlider alloc] init]; |
336800e9e648
Fixes to the slider control so events happen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
703
diff
changeset
|
2703 [slider setMaxValue:(double)increments]; |
336800e9e648
Fixes to the slider control so events happen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
703
diff
changeset
|
2704 [slider setMinValue:0]; |
336800e9e648
Fixes to the slider control so events happen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
703
diff
changeset
|
2705 [slider setContinuous:YES]; |
336800e9e648
Fixes to the slider control so events happen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
703
diff
changeset
|
2706 [slider setTarget:slider]; |
336800e9e648
Fixes to the slider control so events happen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
703
diff
changeset
|
2707 [slider setAction:@selector(sliderChanged:)]; |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
2708 [slider setTag:cid]; |
704
336800e9e648
Fixes to the slider control so events happen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
703
diff
changeset
|
2709 return slider; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2710 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2711 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2712 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2713 * Returns the position of the slider. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2714 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2715 * handle: Handle to the slider to be queried. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2716 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2717 unsigned int API dw_slider_get_pos(HWND handle) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2718 { |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
2719 DWSlider *slider = handle; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
2720 double val = [slider doubleValue]; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
2721 return (int)val; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2722 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2723 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2724 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2725 * Sets the slider position. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2726 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2727 * handle: Handle to the slider to be set. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2728 * position: Position of the slider withing the range. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2729 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2730 void API dw_slider_set_pos(HWND handle, unsigned int position) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2731 { |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
2732 DWSlider *slider = handle; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
2733 [slider setDoubleValue:(double)position]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2734 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2735 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2736 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2737 * Create a new scrollbar window (widget) to be packed. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2738 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2739 * vertical: TRUE or FALSE if scrollbar is vertical. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2740 * increments: Number of increments available. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2741 * id: An ID to be used with dw_window_from_id() or 0L. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2742 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
2743 HWND API dw_scrollbar_new(int vertical, ULONG cid) |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2744 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
2745 DWScrollbar *scrollbar; |
689
4199730e9889
Fixed errors creating scrollbars.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
688
diff
changeset
|
2746 if(vertical) |
4199730e9889
Fixed errors creating scrollbars.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
688
diff
changeset
|
2747 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
2748 scrollbar = [[DWScrollbar alloc] init]; |
689
4199730e9889
Fixed errors creating scrollbars.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
688
diff
changeset
|
2749 } |
4199730e9889
Fixed errors creating scrollbars.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
688
diff
changeset
|
2750 else |
4199730e9889
Fixed errors creating scrollbars.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
688
diff
changeset
|
2751 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
2752 scrollbar = [[DWScrollbar alloc] initWithFrame:NSMakeRect(0,0,100,5)]; |
689
4199730e9889
Fixed errors creating scrollbars.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
688
diff
changeset
|
2753 } |
4199730e9889
Fixed errors creating scrollbars.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
688
diff
changeset
|
2754 [scrollbar setArrowsPosition:NSScrollerArrowsDefaultSetting]; |
4199730e9889
Fixed errors creating scrollbars.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
688
diff
changeset
|
2755 [scrollbar setTarget:scrollbar]; |
4199730e9889
Fixed errors creating scrollbars.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
688
diff
changeset
|
2756 [scrollbar setAction:@selector(changed:)]; |
4199730e9889
Fixed errors creating scrollbars.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
688
diff
changeset
|
2757 [scrollbar setRange:0.0 andVisible:0.0]; |
4199730e9889
Fixed errors creating scrollbars.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
688
diff
changeset
|
2758 [scrollbar setKnobProportion:1.0]; |
705
7087f3a294e5
Spinbuttons now respond to value changed. Fix for typing in spinbutton a value out of the range.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
704
diff
changeset
|
2759 [scrollbar setTarget:scrollbar]; |
7087f3a294e5
Spinbuttons now respond to value changed. Fix for typing in spinbutton a value out of the range.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
704
diff
changeset
|
2760 [scrollbar setAction:@selector(scrollerChanged:)]; |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
2761 [scrollbar setTag:cid]; |
689
4199730e9889
Fixed errors creating scrollbars.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
688
diff
changeset
|
2762 [scrollbar setEnabled:YES]; |
4199730e9889
Fixed errors creating scrollbars.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
688
diff
changeset
|
2763 return scrollbar; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2764 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2765 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2766 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2767 * Returns the position of the scrollbar. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2768 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2769 * handle: Handle to the scrollbar to be queried. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2770 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2771 unsigned int API dw_scrollbar_get_pos(HWND handle) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2772 { |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
2773 DWScrollbar *scrollbar = handle; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
2774 float range = [scrollbar range]; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
2775 float fresult = [scrollbar doubleValue] * range; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
2776 return (int)fresult; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2777 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2778 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2779 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2780 * Sets the scrollbar position. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2781 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2782 * handle: Handle to the scrollbar to be set. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2783 * position: Position of the scrollbar withing the range. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2784 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2785 void API dw_scrollbar_set_pos(HWND handle, unsigned int position) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2786 { |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
2787 DWScrollbar *scrollbar = handle; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
2788 double range = (double)[scrollbar range]; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
2789 double newpos = (double)position/range; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
2790 [scrollbar setDoubleValue:newpos]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2791 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2792 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2793 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2794 * Sets the scrollbar range. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2795 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2796 * handle: Handle to the scrollbar to be set. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2797 * range: Maximum range value. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2798 * visible: Visible area relative to the range. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2799 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2800 void API dw_scrollbar_set_range(HWND handle, unsigned int range, unsigned int visible) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2801 { |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
2802 DWScrollbar *scrollbar = handle; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
2803 float knob = (float)visible/(float)range; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
2804 [scrollbar setRange:(float)range andVisible:(float)visible]; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
2805 [scrollbar setKnobProportion:knob]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2806 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2807 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2808 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2809 * Create a new percent bar window (widget) to be packed. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2810 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2811 * id: An ID to be used with dw_window_from_id() or 0L. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2812 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
2813 HWND API dw_percent_new(ULONG cid) |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2814 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2815 DWPercent *percent = [[DWPercent alloc] init]; |
714
cf6246f86c04
Fixed the percent/progress indicators from always being indeterminate.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
713
diff
changeset
|
2816 [percent setStyle:NSProgressIndicatorBarStyle]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2817 [percent setBezeled:YES]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2818 [percent setMaxValue:100]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2819 [percent setMinValue:0]; |
714
cf6246f86c04
Fixed the percent/progress indicators from always being indeterminate.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
713
diff
changeset
|
2820 [percent incrementBy:1]; |
cf6246f86c04
Fixed the percent/progress indicators from always being indeterminate.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
713
diff
changeset
|
2821 [percent setIndeterminate:NO]; |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
2822 /*[percent setTag:cid]; Why doesn't this work? */ |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2823 return percent; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2824 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2825 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2826 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2827 * Sets the percent bar position. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2828 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2829 * handle: Handle to the percent bar to be set. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2830 * position: Position of the percent bar withing the range. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2831 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2832 void API dw_percent_set_pos(HWND handle, unsigned int position) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2833 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2834 DWPercent *percent = handle; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2835 [percent setDoubleValue:(double)position]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2836 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2837 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2838 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2839 * Create a new checkbox window (widget) to be packed. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2840 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2841 * text: The text to be display by the static text widget. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2842 * id: An ID to be used with dw_window_from_id() or 0L. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2843 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
2844 HWND API dw_checkbox_new(char *text, ULONG cid) |
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
2845 { |
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
2846 DWButton *button = _button_new(text, cid); |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2847 [button setButtonType:NSSwitchButton]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2848 [button setBezelStyle:NSRegularSquareBezelStyle]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2849 return button; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2850 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2851 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2852 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2853 * Returns the state of the checkbox. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2854 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2855 * handle: Handle to the checkbox to be queried. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2856 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2857 int API dw_checkbox_get(HWND handle) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2858 { |
656
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2859 DWButton *button = handle; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2860 if([button state]) |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2861 { |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2862 return TRUE; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2863 } |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2864 return FALSE; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2865 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2866 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2867 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2868 * Sets the state of the checkbox. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2869 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2870 * handle: Handle to the checkbox to be queried. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2871 * value: TRUE for checked, FALSE for unchecked. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2872 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2873 void API dw_checkbox_set(HWND handle, int value) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2874 { |
656
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2875 DWButton *button = handle; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2876 if(value) |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2877 { |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2878 [button setState:NSOnState]; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2879 } |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2880 else |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2881 { |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2882 [button setState:NSOffState]; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2883 } |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2884 |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2885 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2886 |
658
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
2887 /* Common code for containers and listboxes */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
2888 HWND _cont_new(ULONG cid, int multi) |
658
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
2889 { |
668
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
2890 NSScrollView *scrollview = [[NSScrollView alloc] init]; |
658
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
2891 DWContainer *cont = [[DWContainer alloc] init]; |
668
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
2892 |
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
2893 [cont setScrollview:scrollview]; |
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
2894 [scrollview setBorderType:NSBezelBorder]; |
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
2895 [scrollview setHasVerticalScroller:YES]; |
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
2896 [scrollview setAutohidesScrollers:YES]; |
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
2897 |
658
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
2898 if(multi) |
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
2899 { |
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
2900 [cont setAllowsMultipleSelection:YES]; |
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
2901 } |
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
2902 else |
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
2903 { |
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
2904 [cont setAllowsMultipleSelection:NO]; |
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
2905 } |
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
2906 [cont setDataSource:cont]; |
668
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
2907 [scrollview setDocumentView:cont]; |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
2908 [cont setTag:cid]; |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
2909 [scrollview release]; |
658
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
2910 return cont; |
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
2911 } |
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
2912 |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2913 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2914 * Create a new listbox window (widget) to be packed. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2915 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2916 * id: An ID to be used with dw_window_from_id() or 0L. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2917 * multi: Multiple select TRUE or FALSE. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2918 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
2919 HWND API dw_listbox_new(ULONG cid, int multi) |
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
2920 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
2921 int _locked_by_me = FALSE; |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
2922 DW_MUTEX_LOCK; |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
2923 DWContainer *cont = _cont_new(cid, multi); |
668
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
2924 [cont setHeaderView:nil]; |
658
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
2925 int type = DW_CFA_STRING; |
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
2926 [cont setup]; |
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
2927 NSTableColumn *column = [[NSTableColumn alloc] init]; |
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
2928 [cont addTableColumn:column]; |
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
2929 [cont addColumn:column andType:type]; |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
2930 [column release]; |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
2931 DW_MUTEX_UNLOCK; |
658
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
2932 return cont; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2933 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2934 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2935 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2936 * Appends the specified text to the listbox's (or combobox) entry list. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2937 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2938 * handle: Handle to the listbox to be appended to. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2939 * text: Text to append into listbox. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2940 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2941 void API dw_listbox_append(HWND handle, char *text) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2942 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
2943 int _locked_by_me = FALSE; |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
2944 DW_MUTEX_LOCK; |
656
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2945 id object = handle; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2946 |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2947 if([object isMemberOfClass:[DWComboBox class]]) |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2948 { |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2949 DWComboBox *combo = handle; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2950 |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2951 [combo addItemWithObjectValue:[ NSString stringWithUTF8String:text ]]; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2952 } |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2953 else if([object isMemberOfClass:[DWContainer class]]) |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2954 { |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2955 DWContainer *cont = handle; |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2956 NSString *nstr = [ NSString stringWithUTF8String:text ]; |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2957 NSArray *newrow = [NSArray arrayWithObject:nstr]; |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2958 |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2959 [cont addRow:newrow]; |
688
b52f1d4a60dd
Fixes for timers not working properly. Includes commented out test container code for threadsafety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
687
diff
changeset
|
2960 /*[cont performSelectorOnMainThread:@selector(addRow:) |
b52f1d4a60dd
Fixes for timers not working properly. Includes commented out test container code for threadsafety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
687
diff
changeset
|
2961 withObject:newrow |
b52f1d4a60dd
Fixes for timers not working properly. Includes commented out test container code for threadsafety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
687
diff
changeset
|
2962 waitUntilDone:YES];*/ |
670
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
2963 [cont reloadData]; |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2964 } |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
2965 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2966 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2967 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2968 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2969 * Inserts the specified text into the listbox's (or combobox) entry list. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2970 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2971 * handle: Handle to the listbox to be inserted into. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2972 * text: Text to insert into listbox. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2973 * pos: 0-based position to insert text |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2974 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2975 void API dw_listbox_insert(HWND handle, char *text, int pos) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2976 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
2977 int _locked_by_me = FALSE; |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
2978 DW_MUTEX_LOCK; |
656
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2979 id object = handle; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2980 |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2981 if([object isMemberOfClass:[DWComboBox class]]) |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2982 { |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2983 DWComboBox *combo = handle; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2984 |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2985 [combo insertItemWithObjectValue:[ NSString stringWithUTF8String:text ] atIndex:pos]; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2986 } |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2987 else if([object isMemberOfClass:[DWContainer class]]) |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2988 { |
687
5dde8d34bc69
Implemented dw_listbox_insert for containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
686
diff
changeset
|
2989 DWContainer *cont = handle; |
5dde8d34bc69
Implemented dw_listbox_insert for containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
686
diff
changeset
|
2990 NSString *nstr = [ NSString stringWithUTF8String:text ]; |
5dde8d34bc69
Implemented dw_listbox_insert for containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
686
diff
changeset
|
2991 NSArray *newrow = [NSArray arrayWithObject:nstr]; |
5dde8d34bc69
Implemented dw_listbox_insert for containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
686
diff
changeset
|
2992 |
5dde8d34bc69
Implemented dw_listbox_insert for containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
686
diff
changeset
|
2993 [cont insertRow:newrow at:pos]; |
5dde8d34bc69
Implemented dw_listbox_insert for containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
686
diff
changeset
|
2994 [cont reloadData]; |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2995 } |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
2996 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2997 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2998 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2999 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3000 * Appends the specified text items to the listbox's (or combobox) entry list. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3001 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3002 * handle: Handle to the listbox to be appended to. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3003 * text: Text strings to append into listbox. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3004 * count: Number of text strings to append |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3005 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3006 void API dw_listbox_list_append(HWND handle, char **text, int count) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3007 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3008 int _locked_by_me = FALSE; |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3009 DW_MUTEX_LOCK; |
656
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3010 id object = handle; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3011 |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3012 if([object isMemberOfClass:[DWComboBox class]]) |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3013 { |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3014 DWComboBox *combo = handle; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3015 int z; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3016 |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3017 for(z=0;z<count;z++) |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3018 { |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3019 [combo addItemWithObjectValue:[ NSString stringWithUTF8String:text[z] ]]; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3020 } |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3021 } |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3022 else if([object isMemberOfClass:[DWContainer class]]) |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3023 { |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3024 DWContainer *cont = handle; |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3025 int z; |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3026 |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3027 for(z=0;z<count;z++) |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3028 { |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3029 NSString *nstr = [ NSString stringWithUTF8String:text[z] ]; |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3030 NSArray *newrow = [[NSArray alloc] arrayWithObject:nstr]; |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3031 |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3032 [cont addRow:newrow]; |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3033 } |
670
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
3034 [cont reloadData]; |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3035 } |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3036 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3037 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3038 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3039 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3040 * Clears the listbox's (or combobox) list of all entries. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3041 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3042 * handle: Handle to the listbox to be cleared. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3043 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3044 void API dw_listbox_clear(HWND handle) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3045 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3046 int _locked_by_me = FALSE; |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3047 DW_MUTEX_LOCK; |
656
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3048 id object = handle; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3049 |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3050 if([object isMemberOfClass:[DWComboBox class]]) |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3051 { |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3052 DWComboBox *combo = handle; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3053 |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3054 [combo removeAllItems]; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3055 } |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3056 else if([object isMemberOfClass:[DWContainer class]]) |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3057 { |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3058 DWContainer *cont = handle; |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3059 |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3060 [cont clear]; |
670
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
3061 [cont reloadData]; |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3062 } |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3063 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3064 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3065 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3066 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3067 * Returns the listbox's item count. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3068 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3069 * handle: Handle to the listbox to be cleared. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3070 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3071 int API dw_listbox_count(HWND handle) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3072 { |
656
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3073 id object = handle; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3074 |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3075 if([object isMemberOfClass:[DWComboBox class]]) |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3076 { |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3077 DWComboBox *combo = handle; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3078 |
665
e6bec2290f3f
Fixing warnings with Xcode 4 and switched to manual releasing in the draw functions to stop leaking.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
664
diff
changeset
|
3079 return (int)[combo numberOfItems]; |
656
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3080 } |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3081 else if([object isMemberOfClass:[DWContainer class]]) |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3082 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3083 int _locked_by_me = FALSE; |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3084 DW_MUTEX_LOCK; |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3085 DWContainer *cont = handle; |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3086 int result = (int)[cont numberOfRowsInTableView:cont]; |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3087 DW_MUTEX_UNLOCK; |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3088 return result; |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3089 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3090 return 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3091 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3092 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3093 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3094 * Sets the topmost item in the viewport. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3095 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3096 * handle: Handle to the listbox to be cleared. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3097 * top: Index to the top item. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3098 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3099 void API dw_listbox_set_top(HWND handle, int top) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3100 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3101 int _locked_by_me = FALSE; |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3102 DW_MUTEX_LOCK; |
656
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3103 id object = handle; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3104 |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3105 if([object isMemberOfClass:[DWComboBox class]]) |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3106 { |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3107 DWComboBox *combo = handle; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3108 |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3109 [combo scrollItemAtIndexToTop:top]; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3110 } |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3111 else if([object isMemberOfClass:[DWContainer class]]) |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3112 { |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3113 DWContainer *cont = handle; |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3114 |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3115 [cont scrollRowToVisible:top]; |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3116 } |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3117 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3118 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3119 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3120 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3121 * Copies the given index item's text into buffer. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3122 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3123 * handle: Handle to the listbox to be queried. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3124 * index: Index into the list to be queried. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3125 * buffer: Buffer where text will be copied. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3126 * length: Length of the buffer (including NULL). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3127 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3128 void API dw_listbox_get_text(HWND handle, unsigned int index, char *buffer, unsigned int length) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3129 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3130 int _locked_by_me = FALSE; |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3131 DW_MUTEX_LOCK; |
656
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3132 id object = handle; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3133 |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3134 if([object isMemberOfClass:[DWComboBox class]]) |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3135 { |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3136 DWComboBox *combo = handle; |
720
357b59e57a31
Some fixes for out of range parameters passed to dw_listbox_g/set_text().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
719
diff
changeset
|
3137 int count = (int)[combo numberOfItems]; |
357b59e57a31
Some fixes for out of range parameters passed to dw_listbox_g/set_text().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
719
diff
changeset
|
3138 |
357b59e57a31
Some fixes for out of range parameters passed to dw_listbox_g/set_text().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
719
diff
changeset
|
3139 if(index > count) |
357b59e57a31
Some fixes for out of range parameters passed to dw_listbox_g/set_text().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
719
diff
changeset
|
3140 { |
357b59e57a31
Some fixes for out of range parameters passed to dw_listbox_g/set_text().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
719
diff
changeset
|
3141 *buffer = '\0'; |
357b59e57a31
Some fixes for out of range parameters passed to dw_listbox_g/set_text().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
719
diff
changeset
|
3142 } |
357b59e57a31
Some fixes for out of range parameters passed to dw_listbox_g/set_text().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
719
diff
changeset
|
3143 else |
357b59e57a31
Some fixes for out of range parameters passed to dw_listbox_g/set_text().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
719
diff
changeset
|
3144 { |
357b59e57a31
Some fixes for out of range parameters passed to dw_listbox_g/set_text().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
719
diff
changeset
|
3145 NSString *nstr = [combo itemObjectValueAtIndex:index]; |
357b59e57a31
Some fixes for out of range parameters passed to dw_listbox_g/set_text().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
719
diff
changeset
|
3146 strncpy(buffer, [ nstr UTF8String ], length - 1); |
357b59e57a31
Some fixes for out of range parameters passed to dw_listbox_g/set_text().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
719
diff
changeset
|
3147 } |
656
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3148 } |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3149 else if([object isMemberOfClass:[DWContainer class]]) |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3150 { |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3151 DWContainer *cont = handle; |
720
357b59e57a31
Some fixes for out of range parameters passed to dw_listbox_g/set_text().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
719
diff
changeset
|
3152 int count = (int)[cont numberOfRowsInTableView:cont]; |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3153 |
720
357b59e57a31
Some fixes for out of range parameters passed to dw_listbox_g/set_text().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
719
diff
changeset
|
3154 if(index > count) |
357b59e57a31
Some fixes for out of range parameters passed to dw_listbox_g/set_text().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
719
diff
changeset
|
3155 { |
357b59e57a31
Some fixes for out of range parameters passed to dw_listbox_g/set_text().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
719
diff
changeset
|
3156 *buffer = '\0'; |
357b59e57a31
Some fixes for out of range parameters passed to dw_listbox_g/set_text().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
719
diff
changeset
|
3157 } |
357b59e57a31
Some fixes for out of range parameters passed to dw_listbox_g/set_text().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
719
diff
changeset
|
3158 else |
357b59e57a31
Some fixes for out of range parameters passed to dw_listbox_g/set_text().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
719
diff
changeset
|
3159 { |
357b59e57a31
Some fixes for out of range parameters passed to dw_listbox_g/set_text().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
719
diff
changeset
|
3160 NSString *nstr = [cont getRow:index and:0]; |
357b59e57a31
Some fixes for out of range parameters passed to dw_listbox_g/set_text().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
719
diff
changeset
|
3161 |
357b59e57a31
Some fixes for out of range parameters passed to dw_listbox_g/set_text().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
719
diff
changeset
|
3162 strncpy(buffer, [ nstr UTF8String ], length - 1); |
357b59e57a31
Some fixes for out of range parameters passed to dw_listbox_g/set_text().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
719
diff
changeset
|
3163 } |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3164 } |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3165 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3166 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3167 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3168 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3169 * Sets the text of a given listbox entry. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3170 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3171 * handle: Handle to the listbox to be queried. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3172 * index: Index into the list to be queried. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3173 * buffer: Buffer where text will be copied. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3174 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3175 void API dw_listbox_set_text(HWND handle, unsigned int index, char *buffer) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3176 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3177 int _locked_by_me = FALSE; |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3178 DW_MUTEX_LOCK; |
656
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3179 id object = handle; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3180 |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3181 if([object isMemberOfClass:[DWComboBox class]]) |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3182 { |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3183 DWComboBox *combo = handle; |
720
357b59e57a31
Some fixes for out of range parameters passed to dw_listbox_g/set_text().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
719
diff
changeset
|
3184 int count = (int)[combo numberOfItems]; |
656
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3185 |
720
357b59e57a31
Some fixes for out of range parameters passed to dw_listbox_g/set_text().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
719
diff
changeset
|
3186 if(index <= count) |
357b59e57a31
Some fixes for out of range parameters passed to dw_listbox_g/set_text().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
719
diff
changeset
|
3187 { |
357b59e57a31
Some fixes for out of range parameters passed to dw_listbox_g/set_text().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
719
diff
changeset
|
3188 [combo removeItemAtIndex:index]; |
357b59e57a31
Some fixes for out of range parameters passed to dw_listbox_g/set_text().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
719
diff
changeset
|
3189 [combo insertItemWithObjectValue:[ NSString stringWithUTF8String:buffer ] atIndex:index]; |
357b59e57a31
Some fixes for out of range parameters passed to dw_listbox_g/set_text().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
719
diff
changeset
|
3190 } |
656
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3191 } |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3192 else if([object isMemberOfClass:[DWContainer class]]) |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3193 { |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3194 DWContainer *cont = handle; |
720
357b59e57a31
Some fixes for out of range parameters passed to dw_listbox_g/set_text().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
719
diff
changeset
|
3195 int count = (int)[cont numberOfRowsInTableView:cont]; |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3196 |
720
357b59e57a31
Some fixes for out of range parameters passed to dw_listbox_g/set_text().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
719
diff
changeset
|
3197 if(index <= count) |
357b59e57a31
Some fixes for out of range parameters passed to dw_listbox_g/set_text().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
719
diff
changeset
|
3198 { |
357b59e57a31
Some fixes for out of range parameters passed to dw_listbox_g/set_text().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
719
diff
changeset
|
3199 NSString *nstr = [ NSString stringWithUTF8String:buffer ]; |
357b59e57a31
Some fixes for out of range parameters passed to dw_listbox_g/set_text().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
719
diff
changeset
|
3200 |
357b59e57a31
Some fixes for out of range parameters passed to dw_listbox_g/set_text().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
719
diff
changeset
|
3201 [cont editCell:nstr at:index and:0]; |
357b59e57a31
Some fixes for out of range parameters passed to dw_listbox_g/set_text().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
719
diff
changeset
|
3202 [cont reloadData]; |
357b59e57a31
Some fixes for out of range parameters passed to dw_listbox_g/set_text().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
719
diff
changeset
|
3203 } |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3204 } |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3205 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3206 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3207 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3208 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3209 * Returns the index to the item in the list currently selected. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3210 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3211 * handle: Handle to the listbox to be queried. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3212 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3213 unsigned int API dw_listbox_selected(HWND handle) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3214 { |
656
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3215 id object = handle; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3216 |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3217 if([object isMemberOfClass:[DWComboBox class]]) |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3218 { |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3219 DWComboBox *combo = handle; |
665
e6bec2290f3f
Fixing warnings with Xcode 4 and switched to manual releasing in the draw functions to stop leaking.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
664
diff
changeset
|
3220 return (int)[combo indexOfSelectedItem]; |
656
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3221 } |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3222 else if([object isMemberOfClass:[DWContainer class]]) |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3223 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3224 int _locked_by_me = FALSE; |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3225 DW_MUTEX_LOCK; |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3226 DWContainer *cont = handle; |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3227 int result = (int)[cont selectedRow]; |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3228 DW_MUTEX_UNLOCK; |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3229 return result; |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3230 } |
656
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3231 return -1; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3232 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3233 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3234 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3235 * Returns the index to the current selected item or -1 when done. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3236 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3237 * handle: Handle to the listbox to be queried. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3238 * where: Either the previous return or -1 to restart. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3239 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3240 int API dw_listbox_selected_multi(HWND handle, int where) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3241 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3242 int _locked_by_me = FALSE; |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3243 DW_MUTEX_LOCK; |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3244 id object = handle; |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3245 int retval = -1; |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3246 |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3247 if([object isMemberOfClass:[DWContainer class]]) |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3248 { |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3249 DWContainer *cont = handle; |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3250 NSIndexSet *selected = [cont selectedRowIndexes]; |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3251 NSUInteger result = [selected indexGreaterThanIndex:where]; |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3252 |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3253 if(result != NSNotFound) |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3254 { |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3255 retval = (int)result; |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3256 } |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3257 } |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3258 DW_MUTEX_UNLOCK; |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3259 return retval; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3260 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3261 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3262 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3263 * Sets the selection state of a given index. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3264 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3265 * handle: Handle to the listbox to be set. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3266 * index: Item index. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3267 * state: TRUE if selected FALSE if unselected. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3268 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3269 void API dw_listbox_select(HWND handle, int index, int state) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3270 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3271 int _locked_by_me = FALSE; |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3272 DW_MUTEX_LOCK; |
656
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3273 id object = handle; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3274 |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3275 if([object isMemberOfClass:[DWComboBox class]]) |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3276 { |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3277 DWComboBox *combo = handle; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3278 if(state) |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3279 [combo selectItemAtIndex:index]; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3280 else |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3281 [combo deselectItemAtIndex:index]; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3282 } |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3283 else if([object isMemberOfClass:[DWContainer class]]) |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3284 { |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3285 DWContainer *cont = handle; |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3286 NSIndexSet *selected = [[NSIndexSet alloc] initWithIndex:(NSUInteger)index]; |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3287 |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3288 [cont selectRowIndexes:selected byExtendingSelection:YES]; |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3289 [selected release]; |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3290 } |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3291 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3292 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3293 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3294 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3295 * Deletes the item with given index from the list. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3296 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3297 * handle: Handle to the listbox to be set. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3298 * index: Item index. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3299 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3300 void API dw_listbox_delete(HWND handle, int index) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3301 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3302 int _locked_by_me = FALSE; |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3303 DW_MUTEX_LOCK; |
656
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3304 id object = handle; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3305 |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3306 if([object isMemberOfClass:[DWComboBox class]]) |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3307 { |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3308 DWComboBox *combo = handle; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3309 |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3310 [combo removeItemAtIndex:index]; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3311 } |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3312 else if([object isMemberOfClass:[DWContainer class]]) |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3313 { |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3314 DWContainer *cont = handle; |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3315 |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3316 [cont removeRow:index]; |
670
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
3317 [cont reloadData]; |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3318 } |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3319 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3320 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3321 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3322 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3323 * Create a new Combobox window (widget) to be packed. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3324 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3325 * text: The default text to be in the combpbox widget. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3326 * id: An ID to be used with dw_window_from_id() or 0L. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3327 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
3328 HWND API dw_combobox_new(char *text, ULONG cid) |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3329 { |
656
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3330 DWComboBox *combo = [[DWComboBox alloc] init]; |
703
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
3331 [combo setDelegate:combo]; |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
3332 [combo setTag:cid]; |
656
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3333 return combo; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3334 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3335 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3336 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3337 * Create a new Multiline Editbox window (widget) to be packed. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3338 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3339 * id: An ID to be used with dw_window_from_id() or 0L. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3340 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
3341 HWND API dw_mle_new(ULONG cid) |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3342 { |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
3343 DWMLE *mle = [[DWMLE alloc] init]; |
676
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
3344 NSScrollView *scrollview = [[NSScrollView alloc] init]; |
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
3345 |
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
3346 //[mle setScrollview:scrollview]; |
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
3347 [scrollview setBorderType:NSBezelBorder]; |
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
3348 [scrollview setHasVerticalScroller:YES]; |
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
3349 [scrollview setAutohidesScrollers:YES]; |
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
3350 [scrollview setAutoresizingMask:NSViewWidthSizable|NSViewHeightSizable]; |
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
3351 [scrollview setDocumentView:mle]; |
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
3352 [mle setAutoresizingMask:NSViewWidthSizable]; |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
3353 /* [mle setTag:cid]; Why doesn't this work? */ |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3354 [mle release]; |
676
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
3355 return scrollview; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3356 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3357 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3358 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3359 * Adds text to an MLE box and returns the current point. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3360 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3361 * handle: Handle to the MLE to be queried. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3362 * buffer: Text buffer to be imported. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3363 * startpoint: Point to start entering text. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3364 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3365 unsigned int API dw_mle_import(HWND handle, char *buffer, int startpoint) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3366 { |
676
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
3367 NSScrollView *sv = handle; |
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
3368 DWMLE *mle = [sv documentView]; |
675
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
3369 NSTextStorage *ts = [mle textStorage]; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
3370 NSString *nstr = [NSString stringWithUTF8String:buffer]; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
3371 NSMutableString *ms = [ts mutableString]; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
3372 [ms insertString:nstr atIndex:(startpoint+1)]; |
665
e6bec2290f3f
Fixing warnings with Xcode 4 and switched to manual releasing in the draw functions to stop leaking.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
664
diff
changeset
|
3373 return (unsigned int)strlen(buffer) + startpoint; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3374 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3375 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3376 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3377 * Grabs text from an MLE box. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3378 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3379 * handle: Handle to the MLE to be queried. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3380 * buffer: Text buffer to be exported. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3381 * startpoint: Point to start grabbing text. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3382 * length: Amount of text to be grabbed. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3383 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3384 void API dw_mle_export(HWND handle, char *buffer, int startpoint, int length) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3385 { |
676
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
3386 NSScrollView *sv = handle; |
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
3387 DWMLE *mle = [sv documentView]; |
675
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
3388 NSTextStorage *ts = [mle textStorage]; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
3389 NSMutableString *ms = [ts mutableString]; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
3390 strncpy(buffer, [ms UTF8String], length); |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3391 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3392 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3393 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3394 * Obtains information about an MLE box. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3395 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3396 * handle: Handle to the MLE to be queried. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3397 * bytes: A pointer to a variable to return the total bytes. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3398 * lines: A pointer to a variable to return the number of lines. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3399 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3400 void API dw_mle_get_size(HWND handle, unsigned long *bytes, unsigned long *lines) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3401 { |
676
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
3402 NSScrollView *sv = handle; |
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
3403 DWMLE *mle = [sv documentView]; |
675
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
3404 NSTextStorage *ts = [mle textStorage]; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
3405 NSMutableString *ms = [ts mutableString]; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
3406 |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
3407 *bytes = [ms length]; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
3408 *lines = 0; /* TODO: Line count */ |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3409 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3410 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3411 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3412 * Deletes text from an MLE box. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3413 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3414 * handle: Handle to the MLE to be deleted from. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3415 * startpoint: Point to start deleting text. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3416 * length: Amount of text to be deleted. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3417 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3418 void API dw_mle_delete(HWND handle, int startpoint, int length) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3419 { |
676
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
3420 NSScrollView *sv = handle; |
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
3421 DWMLE *mle = [sv documentView]; |
675
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
3422 NSTextStorage *ts = [mle textStorage]; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
3423 NSMutableString *ms = [ts mutableString]; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
3424 [ms deleteCharactersInRange:NSMakeRange(startpoint+1, length)]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3425 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3426 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3427 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3428 * Clears all text from an MLE box. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3429 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3430 * handle: Handle to the MLE to be cleared. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3431 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3432 void API dw_mle_clear(HWND handle) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3433 { |
676
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
3434 NSScrollView *sv = handle; |
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
3435 DWMLE *mle = [sv documentView]; |
675
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
3436 NSTextStorage *ts = [mle textStorage]; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
3437 NSMutableString *ms = [ts mutableString]; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
3438 NSUInteger length = [ms length]; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
3439 [ms deleteCharactersInRange:NSMakeRange(0, length)]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3440 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3441 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3442 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3443 * Sets the visible line of an MLE box. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3444 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3445 * handle: Handle to the MLE to be positioned. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3446 * line: Line to be visible. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3447 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3448 void API dw_mle_set_visible(HWND handle, int line) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3449 { |
712
01107d8e033e
Fixed the scrollbar maximum range to be correct. Also added some MLE code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
711
diff
changeset
|
3450 /*NSScrollView *sv = handle; |
01107d8e033e
Fixed the scrollbar maximum range to be correct. Also added some MLE code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
711
diff
changeset
|
3451 DWMLE *mle = [sv documentView]; |
01107d8e033e
Fixed the scrollbar maximum range to be correct. Also added some MLE code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
711
diff
changeset
|
3452 [mle scrollrangeToVisible:NSMakeRange(0,13)];*/ |
675
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
3453 NSLog(@"dw_mle_set_visible() unimplemented\n"); |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3454 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3455 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3456 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3457 * Sets the editablity of an MLE box. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3458 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3459 * handle: Handle to the MLE. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3460 * state: TRUE if it can be edited, FALSE for readonly. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3461 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3462 void API dw_mle_set_editable(HWND handle, int state) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3463 { |
676
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
3464 NSScrollView *sv = handle; |
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
3465 DWMLE *mle = [sv documentView]; |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
3466 if(state) |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
3467 { |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
3468 [mle setEditable:YES]; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
3469 } |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
3470 else |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
3471 { |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
3472 [mle setEditable:NO]; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
3473 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3474 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3475 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3476 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3477 * Sets the word wrap state of an MLE box. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3478 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3479 * handle: Handle to the MLE. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3480 * state: TRUE if it wraps, FALSE if it doesn't. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3481 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3482 void API dw_mle_set_word_wrap(HWND handle, int state) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3483 { |
676
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
3484 NSScrollView *sv = handle; |
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
3485 DWMLE *mle = [sv documentView]; |
675
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
3486 if(state) |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
3487 { |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
3488 [mle setHorizontallyResizable:NO]; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
3489 } |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
3490 else |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
3491 { |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
3492 [mle setHorizontallyResizable:YES]; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
3493 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3494 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3495 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3496 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3497 * Sets the current cursor position of an MLE box. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3498 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3499 * handle: Handle to the MLE to be positioned. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3500 * point: Point to position cursor. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3501 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3502 void API dw_mle_set_cursor(HWND handle, int point) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3503 { |
712
01107d8e033e
Fixed the scrollbar maximum range to be correct. Also added some MLE code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
711
diff
changeset
|
3504 NSScrollView *sv = handle; |
01107d8e033e
Fixed the scrollbar maximum range to be correct. Also added some MLE code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
711
diff
changeset
|
3505 DWMLE *mle = [sv documentView]; |
01107d8e033e
Fixed the scrollbar maximum range to be correct. Also added some MLE code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
711
diff
changeset
|
3506 [mle setSelectedRange: NSMakeRange(point,point)]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3507 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3508 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3509 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3510 * Finds text in an MLE box. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3511 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3512 * handle: Handle to the MLE to be cleared. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3513 * text: Text to search for. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3514 * point: Start point of search. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3515 * flags: Search specific flags. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3516 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3517 int API dw_mle_search(HWND handle, char *text, int point, unsigned long flags) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3518 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3519 NSLog(@"dw_mle_search() unimplemented\n"); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3520 return 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3521 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3522 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3523 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3524 * Stops redrawing of an MLE box. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3525 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3526 * handle: Handle to the MLE to freeze. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3527 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3528 void API dw_mle_freeze(HWND handle) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3529 { |
675
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
3530 /* Don't think this is necessary */ |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3531 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3532 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3533 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3534 * Resumes redrawing of an MLE box. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3535 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3536 * handle: Handle to the MLE to thaw. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3537 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3538 void API dw_mle_thaw(HWND handle) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3539 { |
675
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
3540 /* Don't think this is necessary */ |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3541 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3542 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3543 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3544 * Create a new status text window (widget) to be packed. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3545 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3546 * text: The text to be display by the static text widget. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3547 * id: An ID to be used with dw_window_from_id() or 0L. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3548 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
3549 HWND API dw_status_text_new(char *text, ULONG cid) |
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
3550 { |
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
3551 NSTextField *textfield = dw_text_new(text, cid); |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
3552 [textfield setBordered:YES]; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
3553 [textfield setBezeled:YES]; |
673
6d0f0dc7ff7c
Some minor font fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
672
diff
changeset
|
3554 [textfield setBezelStyle:NSTextFieldSquareBezel]; |
6d0f0dc7ff7c
Some minor font fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
672
diff
changeset
|
3555 [textfield setBackgroundColor:[NSColor colorWithDeviceRed:1 green:1 blue:1 alpha: 0]]; |
6d0f0dc7ff7c
Some minor font fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
672
diff
changeset
|
3556 [textfield setDrawsBackground:NO]; |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
3557 return textfield; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3558 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3559 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3560 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3561 * Create a new static text window (widget) to be packed. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3562 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3563 * text: The text to be display by the static text widget. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3564 * id: An ID to be used with dw_window_from_id() or 0L. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3565 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
3566 HWND API dw_text_new(char *text, ULONG cid) |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3567 { |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
3568 NSTextField *textfield = [[NSTextField alloc] init]; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
3569 [textfield setEditable:NO]; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
3570 [textfield setSelectable:NO]; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
3571 [textfield setBordered:NO]; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
3572 [textfield setDrawsBackground:NO]; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
3573 [textfield setStringValue:[ NSString stringWithUTF8String:text ]]; |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
3574 [textfield setTag:cid]; |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
3575 return textfield; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3576 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3577 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3578 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3579 * Creates a rendering context widget (window) to be packed. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3580 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3581 * id: An id to be used with dw_window_from_id. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3582 * Returns: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3583 * A handle to the widget or NULL on failure. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3584 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
3585 HWND API dw_render_new(unsigned long cid) |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3586 { |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
3587 DWRender *render = [[DWRender alloc] init]; |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
3588 /* [render setTag:cid]; Why doesn't this work? */ |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
3589 return render; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3590 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3591 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3592 /* Sets the current foreground drawing color. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3593 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3594 * red: red value. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3595 * green: green value. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3596 * blue: blue value. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3597 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3598 void API dw_color_foreground_set(unsigned long value) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3599 { |
671
c60a4f6cfae8
Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
670
diff
changeset
|
3600 /* This may need to be thread specific */ |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3601 _foreground = _get_color(value); |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3602 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3603 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3604 /* Sets the current background drawing color. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3605 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3606 * red: red value. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3607 * green: green value. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3608 * blue: blue value. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3609 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3610 void API dw_color_background_set(unsigned long value) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3611 { |
671
c60a4f6cfae8
Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
670
diff
changeset
|
3612 /* This may need to be thread specific */ |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3613 _background = _get_color(value); |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3614 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3615 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3616 /* Allows the user to choose a color using the system's color chooser dialog. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3617 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3618 * value: current color |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3619 * Returns: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3620 * The selected color or the current color if cancelled. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3621 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3622 unsigned long API dw_color_choose(unsigned long value) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3623 { |
690
b93f5cdab37d
Fixes to the color picker... it actually shows the picker now but it still needs more work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
689
diff
changeset
|
3624 /* Create the File Save Dialog class. */ |
b93f5cdab37d
Fixes to the color picker... it actually shows the picker now but it still needs more work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
689
diff
changeset
|
3625 DWColorChoose *colorDlg = (DWColorChoose *)[DWColorChoose sharedColorPanel]; |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3626 NSColor *color = [NSColor colorWithDeviceRed: DW_RED_VALUE(_foreground)/255.0 green: DW_GREEN_VALUE(_foreground)/255.0 blue: DW_BLUE_VALUE(_foreground)/255.0 alpha: 1]; |
690
b93f5cdab37d
Fixes to the color picker... it actually shows the picker now but it still needs more work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
689
diff
changeset
|
3627 DWDialog *dialog = dw_dialog_new(colorDlg); |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
3628 |
690
b93f5cdab37d
Fixes to the color picker... it actually shows the picker now but it still needs more work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
689
diff
changeset
|
3629 /* Set defaults for the dialog. */ |
b93f5cdab37d
Fixes to the color picker... it actually shows the picker now but it still needs more work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
689
diff
changeset
|
3630 [colorDlg setColor:color]; |
b93f5cdab37d
Fixes to the color picker... it actually shows the picker now but it still needs more work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
689
diff
changeset
|
3631 [colorDlg setDialog:dialog]; |
b93f5cdab37d
Fixes to the color picker... it actually shows the picker now but it still needs more work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
689
diff
changeset
|
3632 [colorDlg setContinuous:YES]; |
b93f5cdab37d
Fixes to the color picker... it actually shows the picker now but it still needs more work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
689
diff
changeset
|
3633 [colorDlg setTarget:colorDlg]; |
b93f5cdab37d
Fixes to the color picker... it actually shows the picker now but it still needs more work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
689
diff
changeset
|
3634 [colorDlg setAction:@selector(changeColor:)]; |
b93f5cdab37d
Fixes to the color picker... it actually shows the picker now but it still needs more work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
689
diff
changeset
|
3635 [colorDlg makeKeyAndOrderFront:nil]; |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
3636 |
690
b93f5cdab37d
Fixes to the color picker... it actually shows the picker now but it still needs more work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
689
diff
changeset
|
3637 color = (NSColor *)dw_dialog_wait(dialog); |
b93f5cdab37d
Fixes to the color picker... it actually shows the picker now but it still needs more work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
689
diff
changeset
|
3638 [color release]; |
b93f5cdab37d
Fixes to the color picker... it actually shows the picker now but it still needs more work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
689
diff
changeset
|
3639 return _foreground; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3640 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3641 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3642 /* Draw a point on a window (preferably a render window). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3643 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3644 * handle: Handle to the window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3645 * pixmap: Handle to the pixmap. (choose only one of these) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3646 * x: X coordinate. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3647 * y: Y coordinate. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3648 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3649 void API dw_draw_point(HWND handle, HPIXMAP pixmap, int x, int y) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3650 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3651 int _locked_by_me = FALSE; |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3652 DW_MUTEX_LOCK; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3653 id image = handle; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3654 if(pixmap) |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3655 { |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
3656 image = (id)pixmap->handle; |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
3657 [image lockFocus]; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3658 } |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
3659 else |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
3660 { |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
3661 [image lockFocusIfCanDraw]; |
661
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
3662 _DWLastDrawable = handle; |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
3663 } |
664
ba3af8eb56f1
Fixed drawing of rects and points. Fonts now properly draw in color. Updated property list.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
662
diff
changeset
|
3664 NSBezierPath* aPath = [NSBezierPath bezierPath]; |
ba3af8eb56f1
Fixed drawing of rects and points. Fonts now properly draw in color. Updated property list.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
662
diff
changeset
|
3665 [aPath setLineWidth: 0.5]; |
665
e6bec2290f3f
Fixing warnings with Xcode 4 and switched to manual releasing in the draw functions to stop leaking.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
664
diff
changeset
|
3666 NSColor *color = [NSColor colorWithDeviceRed: DW_RED_VALUE(_foreground)/255.0 green: DW_GREEN_VALUE(_foreground)/255.0 blue: DW_BLUE_VALUE(_foreground)/255.0 alpha: 1]; |
e6bec2290f3f
Fixing warnings with Xcode 4 and switched to manual releasing in the draw functions to stop leaking.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
664
diff
changeset
|
3667 [color set]; |
664
ba3af8eb56f1
Fixed drawing of rects and points. Fonts now properly draw in color. Updated property list.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
662
diff
changeset
|
3668 |
ba3af8eb56f1
Fixed drawing of rects and points. Fonts now properly draw in color. Updated property list.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
662
diff
changeset
|
3669 [aPath moveToPoint:NSMakePoint(x, y)]; |
ba3af8eb56f1
Fixed drawing of rects and points. Fonts now properly draw in color. Updated property list.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
662
diff
changeset
|
3670 [aPath stroke]; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3671 [image unlockFocus]; |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3672 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3673 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3674 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3675 /* Draw a line on a window (preferably a render window). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3676 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3677 * handle: Handle to the window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3678 * pixmap: Handle to the pixmap. (choose only one of these) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3679 * x1: First X coordinate. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3680 * y1: First Y coordinate. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3681 * x2: Second X coordinate. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3682 * y2: Second Y coordinate. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3683 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3684 void API dw_draw_line(HWND handle, HPIXMAP pixmap, int x1, int y1, int x2, int y2) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3685 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3686 int _locked_by_me = FALSE; |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3687 DW_MUTEX_LOCK; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3688 id image = handle; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3689 if(pixmap) |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3690 { |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
3691 image = (id)pixmap->handle; |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
3692 [image lockFocus]; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3693 } |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
3694 else |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
3695 { |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
3696 [image lockFocusIfCanDraw]; |
661
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
3697 _DWLastDrawable = handle; |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
3698 } |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3699 NSBezierPath* aPath = [NSBezierPath bezierPath]; |
661
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
3700 [aPath setLineWidth: 0.5]; |
665
e6bec2290f3f
Fixing warnings with Xcode 4 and switched to manual releasing in the draw functions to stop leaking.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
664
diff
changeset
|
3701 NSColor *color = [NSColor colorWithDeviceRed: DW_RED_VALUE(_foreground)/255.0 green: DW_GREEN_VALUE(_foreground)/255.0 blue: DW_BLUE_VALUE(_foreground)/255.0 alpha: 1]; |
e6bec2290f3f
Fixing warnings with Xcode 4 and switched to manual releasing in the draw functions to stop leaking.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
664
diff
changeset
|
3702 [color set]; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3703 |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3704 [aPath moveToPoint:NSMakePoint(x1, y1)]; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3705 [aPath lineToPoint:NSMakePoint(x2, y2)]; |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
3706 [aPath stroke]; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3707 |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3708 [image unlockFocus]; |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3709 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3710 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3711 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3712 /* Draw text on a window (preferably a render window). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3713 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3714 * handle: Handle to the window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3715 * pixmap: Handle to the pixmap. (choose only one of these) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3716 * x: X coordinate. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3717 * y: Y coordinate. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3718 * text: Text to be displayed. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3719 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3720 void API dw_draw_text(HWND handle, HPIXMAP pixmap, int x, int y, char *text) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3721 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3722 int _locked_by_me = FALSE; |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3723 DW_MUTEX_LOCK; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3724 id image = handle; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3725 NSString *nstr = [ NSString stringWithUTF8String:text ]; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3726 if(image) |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3727 { |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3728 if([image isMemberOfClass:[NSView class]]) |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3729 { |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
3730 [image lockFocusIfCanDraw]; |
665
e6bec2290f3f
Fixing warnings with Xcode 4 and switched to manual releasing in the draw functions to stop leaking.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
664
diff
changeset
|
3731 NSColor *color = [NSColor colorWithDeviceRed: DW_RED_VALUE(_foreground)/255.0 green: DW_GREEN_VALUE(_foreground)/255.0 blue: DW_BLUE_VALUE(_foreground)/255.0 alpha: 1]; |
e6bec2290f3f
Fixing warnings with Xcode 4 and switched to manual releasing in the draw functions to stop leaking.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
664
diff
changeset
|
3732 NSDictionary *dict = [[NSDictionary alloc] initWithObjectsAndKeys: |
e6bec2290f3f
Fixing warnings with Xcode 4 and switched to manual releasing in the draw functions to stop leaking.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
664
diff
changeset
|
3733 /*[NSFont fontWithName:@"Helvetica" size:26], NSFontAttributeName,*/ |
e6bec2290f3f
Fixing warnings with Xcode 4 and switched to manual releasing in the draw functions to stop leaking.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
664
diff
changeset
|
3734 color, NSForegroundColorAttributeName, nil]; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3735 [nstr drawAtPoint:NSMakePoint(x, y) withAttributes:dict]; |
665
e6bec2290f3f
Fixing warnings with Xcode 4 and switched to manual releasing in the draw functions to stop leaking.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
664
diff
changeset
|
3736 [dict release]; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3737 [image unlockFocus]; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3738 } |
661
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
3739 _DWLastDrawable = handle; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3740 } |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3741 if(pixmap) |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3742 { |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
3743 image = (id)pixmap->handle; |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
3744 [image lockFocus]; |
664
ba3af8eb56f1
Fixed drawing of rects and points. Fonts now properly draw in color. Updated property list.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
662
diff
changeset
|
3745 NSColor *color = [NSColor colorWithDeviceRed: DW_RED_VALUE(_foreground)/255.0 green: DW_GREEN_VALUE(_foreground)/255.0 blue: DW_BLUE_VALUE(_foreground)/255.0 alpha: 1]; |
ba3af8eb56f1
Fixed drawing of rects and points. Fonts now properly draw in color. Updated property list.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
662
diff
changeset
|
3746 NSDictionary *dict = [[NSDictionary alloc] initWithObjectsAndKeys: |
ba3af8eb56f1
Fixed drawing of rects and points. Fonts now properly draw in color. Updated property list.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
662
diff
changeset
|
3747 /*[NSFont fontWithName:@"Helvetica" size:26], NSFontAttributeName,*/ |
ba3af8eb56f1
Fixed drawing of rects and points. Fonts now properly draw in color. Updated property list.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
662
diff
changeset
|
3748 color, NSForegroundColorAttributeName, nil]; |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
3749 [nstr drawAtPoint:NSMakePoint(x, y) withAttributes:dict]; |
665
e6bec2290f3f
Fixing warnings with Xcode 4 and switched to manual releasing in the draw functions to stop leaking.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
664
diff
changeset
|
3750 [dict release]; |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
3751 [image unlockFocus]; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3752 } |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3753 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3754 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3755 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3756 /* Query the width and height of a text string. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3757 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3758 * handle: Handle to the window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3759 * pixmap: Handle to the pixmap. (choose only one of these) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3760 * text: Text to be queried. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3761 * width: Pointer to a variable to be filled in with the width. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3762 * height Pointer to a variable to be filled in with the height. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3763 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3764 void API dw_font_text_extents_get(HWND handle, HPIXMAP pixmap, char *text, int *width, int *height) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3765 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3766 int _locked_by_me = FALSE; |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3767 DW_MUTEX_LOCK; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3768 id image = handle; |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3769 NSString *nstr = [NSString stringWithUTF8String:text]; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3770 if(pixmap) |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3771 { |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
3772 image = (id)pixmap->handle; |
661
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
3773 [image lockFocus]; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3774 } |
661
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
3775 else |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
3776 { |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
3777 [image lockFocusIfCanDraw]; |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
3778 } |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
3779 NSDictionary *dict = [[NSDictionary alloc] init]; |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
3780 NSSize size = [nstr sizeWithAttributes:dict]; |
665
e6bec2290f3f
Fixing warnings with Xcode 4 and switched to manual releasing in the draw functions to stop leaking.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
664
diff
changeset
|
3781 [dict release]; |
661
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
3782 if(width) |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
3783 { |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
3784 *width = size.width; |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
3785 } |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
3786 if(height) |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
3787 { |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
3788 *height = size.height; |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
3789 } |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
3790 [image unlockFocus]; |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3791 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3792 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3793 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3794 /* Draw a polygon on a window (preferably a render window). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3795 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3796 * handle: Handle to the window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3797 * pixmap: Handle to the pixmap. (choose only one of these) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3798 * fill: Fill box TRUE or FALSE. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3799 * x: X coordinate. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3800 * y: Y coordinate. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3801 * width: Width of rectangle. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3802 * height: Height of rectangle. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3803 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3804 void API dw_draw_polygon( HWND handle, HPIXMAP pixmap, int fill, int npoints, int *x, int *y ) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3805 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3806 int _locked_by_me = FALSE; |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3807 DW_MUTEX_LOCK; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3808 id image = handle; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3809 int z; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3810 if(pixmap) |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3811 { |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
3812 image = (id)pixmap->handle; |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
3813 [image lockFocus]; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3814 } |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
3815 else |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
3816 { |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
3817 [image lockFocusIfCanDraw]; |
661
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
3818 _DWLastDrawable = handle; |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
3819 } |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3820 NSBezierPath* aPath = [NSBezierPath bezierPath]; |
661
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
3821 [aPath setLineWidth: 0.5]; |
665
e6bec2290f3f
Fixing warnings with Xcode 4 and switched to manual releasing in the draw functions to stop leaking.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
664
diff
changeset
|
3822 NSColor *color = [NSColor colorWithDeviceRed: DW_RED_VALUE(_foreground)/255.0 green: DW_GREEN_VALUE(_foreground)/255.0 blue: DW_BLUE_VALUE(_foreground)/255.0 alpha: 1]; |
e6bec2290f3f
Fixing warnings with Xcode 4 and switched to manual releasing in the draw functions to stop leaking.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
664
diff
changeset
|
3823 [color set]; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3824 |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3825 [aPath moveToPoint:NSMakePoint(*x, *y)]; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3826 for(z=1;z<npoints;z++) |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3827 { |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3828 [aPath lineToPoint:NSMakePoint(x[z], y[z])]; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3829 } |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3830 [aPath closePath]; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3831 if(fill) |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3832 { |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3833 [aPath fill]; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3834 } |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
3835 [aPath stroke]; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3836 [image unlockFocus]; |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3837 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3838 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3839 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3840 /* Draw a rectangle on a window (preferably a render window). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3841 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3842 * handle: Handle to the window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3843 * pixmap: Handle to the pixmap. (choose only one of these) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3844 * fill: Fill box TRUE or FALSE. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3845 * x: X coordinate. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3846 * y: Y coordinate. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3847 * width: Width of rectangle. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3848 * height: Height of rectangle. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3849 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3850 void API dw_draw_rect(HWND handle, HPIXMAP pixmap, int fill, int x, int y, int width, int height) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3851 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3852 int _locked_by_me = FALSE; |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3853 DW_MUTEX_LOCK; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3854 id image = handle; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3855 if(pixmap) |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3856 { |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
3857 image = (id)pixmap->handle; |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
3858 [image lockFocus]; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3859 } |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
3860 else |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
3861 { |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
3862 [image lockFocusIfCanDraw]; |
661
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
3863 _DWLastDrawable = handle; |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
3864 } |
664
ba3af8eb56f1
Fixed drawing of rects and points. Fonts now properly draw in color. Updated property list.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
662
diff
changeset
|
3865 NSBezierPath* aPath = [NSBezierPath bezierPath]; |
ba3af8eb56f1
Fixed drawing of rects and points. Fonts now properly draw in color. Updated property list.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
662
diff
changeset
|
3866 [aPath setLineWidth: 0.5]; |
665
e6bec2290f3f
Fixing warnings with Xcode 4 and switched to manual releasing in the draw functions to stop leaking.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
664
diff
changeset
|
3867 NSColor *color = [NSColor colorWithDeviceRed: DW_RED_VALUE(_foreground)/255.0 green: DW_GREEN_VALUE(_foreground)/255.0 blue: DW_BLUE_VALUE(_foreground)/255.0 alpha: 1]; |
e6bec2290f3f
Fixing warnings with Xcode 4 and switched to manual releasing in the draw functions to stop leaking.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
664
diff
changeset
|
3868 [color set]; |
664
ba3af8eb56f1
Fixed drawing of rects and points. Fonts now properly draw in color. Updated property list.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
662
diff
changeset
|
3869 |
ba3af8eb56f1
Fixed drawing of rects and points. Fonts now properly draw in color. Updated property list.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
662
diff
changeset
|
3870 [aPath moveToPoint:NSMakePoint(x, y)]; |
ba3af8eb56f1
Fixed drawing of rects and points. Fonts now properly draw in color. Updated property list.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
662
diff
changeset
|
3871 [aPath lineToPoint:NSMakePoint(x, y + height)]; |
ba3af8eb56f1
Fixed drawing of rects and points. Fonts now properly draw in color. Updated property list.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
662
diff
changeset
|
3872 [aPath lineToPoint:NSMakePoint(x + width, y + height)]; |
ba3af8eb56f1
Fixed drawing of rects and points. Fonts now properly draw in color. Updated property list.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
662
diff
changeset
|
3873 [aPath lineToPoint:NSMakePoint(x + width, y)]; |
ba3af8eb56f1
Fixed drawing of rects and points. Fonts now properly draw in color. Updated property list.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
662
diff
changeset
|
3874 [aPath closePath]; |
ba3af8eb56f1
Fixed drawing of rects and points. Fonts now properly draw in color. Updated property list.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
662
diff
changeset
|
3875 [aPath fill]; |
ba3af8eb56f1
Fixed drawing of rects and points. Fonts now properly draw in color. Updated property list.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
662
diff
changeset
|
3876 [aPath stroke]; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3877 [image unlockFocus]; |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3878 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3879 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3880 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3881 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3882 * Create a tree object to be packed. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3883 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3884 * id: An ID to be used for getting the resource from the |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3885 * resource file. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3886 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
3887 HWND API dw_tree_new(ULONG cid) |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3888 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3889 int _locked_by_me = FALSE; |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3890 DW_MUTEX_LOCK; |
680
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
3891 NSScrollView *scrollview = [[NSScrollView alloc] init]; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
3892 DWTree *tree = [[DWTree alloc] init]; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
3893 |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
3894 [tree setScrollview:scrollview]; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
3895 [scrollview setBorderType:NSBezelBorder]; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
3896 [scrollview setHasVerticalScroller:YES]; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
3897 [scrollview setAutohidesScrollers:YES]; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
3898 |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
3899 [tree setAllowsMultipleSelection:NO]; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
3900 [tree setDataSource:tree]; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
3901 [scrollview setDocumentView:tree]; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
3902 [tree setHeaderView:nil]; |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
3903 [tree setTag:cid]; |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3904 [scrollview release]; |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3905 DW_MUTEX_UNLOCK; |
680
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
3906 return tree; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3907 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3908 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3909 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3910 * Inserts an item into a tree window (widget) after another item. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3911 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3912 * handle: Handle to the tree to be inserted. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3913 * item: Handle to the item to be positioned after. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3914 * title: The text title of the entry. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3915 * icon: Handle to coresponding icon. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3916 * parent: Parent handle or 0 if root. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3917 * itemdata: Item specific data. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3918 */ |
671
c60a4f6cfae8
Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
670
diff
changeset
|
3919 HTREEITEM API dw_tree_insert_after(HWND handle, HTREEITEM item, char *title, HICN icon, HTREEITEM parent, void *itemdata) |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3920 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3921 int _locked_by_me = FALSE; |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3922 DW_MUTEX_LOCK; |
680
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
3923 DWTree *tree = handle; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
3924 NSString *nstr = [NSString stringWithUTF8String:title]; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
3925 NSPointerArray *treenode = [NSPointerArray pointerArrayWithWeakObjects]; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
3926 [treenode addPointer:icon]; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
3927 [treenode addPointer:nstr]; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
3928 [treenode addPointer:itemdata]; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
3929 [treenode addPointer:NULL]; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
3930 [tree addTree:treenode and:parent]; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
3931 [tree reloadData]; |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3932 DW_MUTEX_UNLOCK; |
680
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
3933 return treenode; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3934 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3935 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3936 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3937 * Inserts an item into a tree window (widget). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3938 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3939 * handle: Handle to the tree to be inserted. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3940 * title: The text title of the entry. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3941 * icon: Handle to coresponding icon. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3942 * parent: Parent handle or 0 if root. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3943 * itemdata: Item specific data. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3944 */ |
671
c60a4f6cfae8
Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
670
diff
changeset
|
3945 HTREEITEM API dw_tree_insert(HWND handle, char *title, HICN icon, HTREEITEM parent, void *itemdata) |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3946 { |
680
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
3947 return dw_tree_insert_after(handle, NULL, title, icon, parent, itemdata); |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3948 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3949 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3950 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3951 * Gets the text an item in a tree window (widget). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3952 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3953 * handle: Handle to the tree containing the item. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3954 * item: Handle of the item to be modified. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3955 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3956 char * API dw_tree_get_title(HWND handle, HTREEITEM item) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3957 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3958 int _locked_by_me = FALSE; |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3959 DW_MUTEX_LOCK; |
680
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
3960 NSPointerArray *array = (NSPointerArray *)item; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
3961 NSString *nstr = (NSString *)[array pointerAtIndex:1]; |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3962 DW_MUTEX_UNLOCK; |
680
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
3963 return strdup([nstr UTF8String]); |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3964 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3965 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3966 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3967 * Gets the text an item in a tree window (widget). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3968 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3969 * handle: Handle to the tree containing the item. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3970 * item: Handle of the item to be modified. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3971 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3972 HTREEITEM API dw_tree_get_parent(HWND handle, HTREEITEM item) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3973 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3974 NSLog(@"dw_tree_get_parent() unimplemented\n"); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3975 return HWND_DESKTOP; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3976 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3977 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3978 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3979 * Sets the text and icon of an item in a tree window (widget). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3980 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3981 * handle: Handle to the tree containing the item. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3982 * item: Handle of the item to be modified. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3983 * title: The text title of the entry. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3984 * icon: Handle to coresponding icon. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3985 */ |
671
c60a4f6cfae8
Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
670
diff
changeset
|
3986 void API dw_tree_item_change(HWND handle, HTREEITEM item, char *title, HICN icon) |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3987 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3988 int _locked_by_me = FALSE; |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3989 DW_MUTEX_LOCK; |
682
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
3990 DWTree *tree = handle; |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
3991 NSPointerArray *array = (NSPointerArray *)item; |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
3992 if(title) |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
3993 { |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
3994 NSString *nstr = [NSString stringWithUTF8String:title]; |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
3995 [array replacePointerAtIndex:1 withPointer:nstr]; |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
3996 } |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
3997 if(icon) |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
3998 { |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
3999 [array replacePointerAtIndex:0 withPointer:icon]; |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
4000 } |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
4001 [tree reloadData]; |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4002 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4003 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4004 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4005 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4006 * Sets the item data of a tree item. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4007 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4008 * handle: Handle to the tree containing the item. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4009 * item: Handle of the item to be modified. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4010 * itemdata: User defined data to be associated with item. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4011 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4012 void API dw_tree_item_set_data(HWND handle, HTREEITEM item, void *itemdata) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4013 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4014 int _locked_by_me = FALSE; |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4015 DW_MUTEX_LOCK; |
682
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
4016 NSPointerArray *array = (NSPointerArray *)item; |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
4017 [array replacePointerAtIndex:2 withPointer:itemdata]; |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4018 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4019 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4020 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4021 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4022 * Gets the item data of a tree item. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4023 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4024 * handle: Handle to the tree containing the item. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4025 * item: Handle of the item to be modified. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4026 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4027 void * API dw_tree_item_get_data(HWND handle, HTREEITEM item) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4028 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4029 int _locked_by_me = FALSE; |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4030 DW_MUTEX_LOCK; |
682
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
4031 NSPointerArray *array = (NSPointerArray *)item; |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4032 void *result = [array pointerAtIndex:2]; |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4033 DW_MUTEX_UNLOCK; |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4034 return result; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4035 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4036 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4037 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4038 * Sets this item as the active selection. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4039 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4040 * handle: Handle to the tree window (widget) to be selected. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4041 * item: Handle to the item to be selected. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4042 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4043 void API dw_tree_item_select(HWND handle, HTREEITEM item) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4044 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4045 int _locked_by_me = FALSE; |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4046 DW_MUTEX_LOCK; |
682
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
4047 DWTree *tree = handle; |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
4048 NSInteger itemIndex = [tree rowForItem:item]; |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
4049 if(itemIndex > -1) |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
4050 { |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
4051 [tree selectRowIndexes:[NSIndexSet indexSetWithIndex:itemIndex] byExtendingSelection:NO]; |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
4052 } |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4053 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4054 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4055 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4056 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4057 * Removes all nodes from a tree. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4058 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4059 * handle: Handle to the window (widget) to be cleared. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4060 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4061 void API dw_tree_clear(HWND handle) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4062 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4063 int _locked_by_me = FALSE; |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4064 DW_MUTEX_LOCK; |
682
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
4065 DWTree *tree = handle; |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
4066 [tree clear]; |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4067 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4068 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4069 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4070 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4071 * Expands a node on a tree. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4072 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4073 * handle: Handle to the tree window (widget). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4074 * item: Handle to node to be expanded. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4075 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4076 void API dw_tree_item_expand(HWND handle, HTREEITEM item) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4077 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4078 int _locked_by_me = FALSE; |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4079 DW_MUTEX_LOCK; |
682
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
4080 DWTree *tree = handle; |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
4081 [tree expandItem:item]; |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4082 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4083 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4084 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4085 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4086 * Collapses a node on a tree. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4087 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4088 * handle: Handle to the tree window (widget). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4089 * item: Handle to node to be collapsed. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4090 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4091 void API dw_tree_item_collapse(HWND handle, HTREEITEM item) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4092 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4093 int _locked_by_me = FALSE; |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4094 DW_MUTEX_LOCK; |
682
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
4095 DWTree *tree = handle; |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
4096 [tree collapseItem:item]; |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4097 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4098 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4099 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4100 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4101 * Removes a node from a tree. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4102 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4103 * handle: Handle to the window (widget) to be cleared. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4104 * item: Handle to node to be deleted. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4105 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4106 void API dw_tree_item_delete(HWND handle, HTREEITEM item) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4107 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4108 int _locked_by_me = FALSE; |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4109 DW_MUTEX_LOCK; |
682
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
4110 DWTree *tree = handle; |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
4111 [tree deleteNode:item]; |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
4112 [tree reloadData]; |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4113 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4114 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4115 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4116 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4117 * Create a container object to be packed. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4118 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4119 * id: An ID to be used for getting the resource from the |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4120 * resource file. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4121 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
4122 HWND API dw_container_new(ULONG cid, int multi) |
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
4123 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4124 int _locked_by_me = FALSE; |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4125 DW_MUTEX_LOCK; |
708
5fe2ca5ef88b
Fixes for container event handling. Also made container/listbox cells non-editable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
707
diff
changeset
|
4126 DWContainer *cont = _cont_new(cid, multi); |
668
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
4127 NSScrollView *scrollview = [cont scrollview]; |
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
4128 [scrollview setHasHorizontalScroller:YES]; |
708
5fe2ca5ef88b
Fixes for container event handling. Also made container/listbox cells non-editable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
707
diff
changeset
|
4129 NSTableHeaderView *header = [[NSTableHeaderView alloc] init]; |
5fe2ca5ef88b
Fixes for container event handling. Also made container/listbox cells non-editable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
707
diff
changeset
|
4130 [cont setHeaderView:header]; |
5fe2ca5ef88b
Fixes for container event handling. Also made container/listbox cells non-editable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
707
diff
changeset
|
4131 [cont setTarget:cont]; |
5fe2ca5ef88b
Fixes for container event handling. Also made container/listbox cells non-editable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
707
diff
changeset
|
4132 [cont setDoubleAction:@selector(doubleClicked:)]; |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4133 [header release]; |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4134 DW_MUTEX_UNLOCK; |
708
5fe2ca5ef88b
Fixes for container event handling. Also made container/listbox cells non-editable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
707
diff
changeset
|
4135 return cont; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4136 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4137 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4138 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4139 * Sets up the container columns. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4140 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4141 * handle: Handle to the container to be configured. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4142 * flags: An array of unsigned longs with column flags. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4143 * titles: An array of strings with column text titles. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4144 * count: The number of columns (this should match the arrays). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4145 * separator: The column number that contains the main separator. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4146 * (this item may only be used in OS/2) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4147 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4148 int API dw_container_setup(HWND handle, unsigned long *flags, char **titles, int count, int separator) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4149 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4150 int _locked_by_me = FALSE; |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4151 DW_MUTEX_LOCK; |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
4152 int z; |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
4153 DWContainer *cont = handle; |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
4154 |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4155 [cont setup]; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4156 |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
4157 for(z=0;z<count;z++) |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
4158 { |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
4159 NSTableColumn *column = [[NSTableColumn alloc] init]; |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
4160 [[column headerCell] setStringValue:[ NSString stringWithUTF8String:titles[z] ]]; |
671
c60a4f6cfae8
Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
670
diff
changeset
|
4161 if(flags[z] & DW_CFA_BITMAPORICON) |
c60a4f6cfae8
Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
670
diff
changeset
|
4162 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4163 NSImageCell *imagecell = [[NSImageCell alloc] init]; |
671
c60a4f6cfae8
Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
670
diff
changeset
|
4164 [column setDataCell:imagecell]; |
675
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4165 if(z == 0 && titles[z] && strcmp(titles[z], "Icon") == 0) |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4166 { |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4167 [column setResizingMask:NSTableColumnNoResizing]; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4168 [column setWidth:20]; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4169 } |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4170 [imagecell release]; |
671
c60a4f6cfae8
Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
670
diff
changeset
|
4171 } |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
4172 [cont addTableColumn:column]; |
665
e6bec2290f3f
Fixing warnings with Xcode 4 and switched to manual releasing in the draw functions to stop leaking.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
664
diff
changeset
|
4173 [cont addColumn:column andType:(int)flags[z]]; |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4174 [column release]; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4175 } |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4176 DW_MUTEX_UNLOCK; |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
4177 return TRUE; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4178 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4179 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4180 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4181 * Sets up the filesystem columns, note: filesystem always has an icon/filename field. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4182 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4183 * handle: Handle to the container to be configured. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4184 * flags: An array of unsigned longs with column flags. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4185 * titles: An array of strings with column text titles. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4186 * count: The number of columns (this should match the arrays). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4187 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4188 int API dw_filesystem_setup(HWND handle, unsigned long *flags, char **titles, int count) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4189 { |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4190 char **newtitles = malloc(sizeof(char *) * (count + 2)); |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4191 unsigned long *newflags = malloc(sizeof(unsigned long) * (count + 2)); |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
4192 |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4193 newtitles[0] = "Icon"; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4194 newtitles[1] = "Filename"; |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
4195 |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4196 newflags[0] = DW_CFA_BITMAPORICON | DW_CFA_LEFT | DW_CFA_HORZSEPARATOR; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4197 newflags[1] = DW_CFA_STRING | DW_CFA_LEFT | DW_CFA_HORZSEPARATOR; |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
4198 |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4199 memcpy(&newtitles[2], titles, sizeof(char *) * count); |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4200 memcpy(&newflags[2], flags, sizeof(unsigned long) * count); |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
4201 |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4202 dw_container_setup(handle, newflags, newtitles, count + 2, 0); |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
4203 |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
4204 free(newtitles); |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
4205 free(newflags); |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
4206 return TRUE; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4207 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4208 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4209 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4210 * Allocates memory used to populate a container. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4211 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4212 * handle: Handle to the container window (widget). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4213 * rowcount: The number of items to be populated. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4214 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4215 void * API dw_container_alloc(HWND handle, int rowcount) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4216 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4217 int _locked_by_me = FALSE; |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4218 DW_MUTEX_LOCK; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4219 DWContainer *cont = handle; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4220 [cont addRows:rowcount]; |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4221 DW_MUTEX_UNLOCK; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4222 return cont; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4223 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4224 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4225 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4226 * Sets an item in specified row and column to the given data. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4227 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4228 * handle: Handle to the container window (widget). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4229 * pointer: Pointer to the allocated memory in dw_container_alloc(). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4230 * column: Zero based column of data being set. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4231 * row: Zero based row of data being set. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4232 * data: Pointer to the data to be added. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4233 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4234 void API dw_container_set_item(HWND handle, void *pointer, int column, int row, void *data) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4235 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4236 int _locked_by_me = FALSE; |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4237 DW_MUTEX_LOCK; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4238 DWContainer *cont = handle; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4239 id object = nil; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4240 int type = [cont cellType:column]; |
658
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
4241 int lastadd = [cont lastAddPoint]; |
671
c60a4f6cfae8
Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
670
diff
changeset
|
4242 |
c60a4f6cfae8
Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
670
diff
changeset
|
4243 if(!data) |
c60a4f6cfae8
Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
670
diff
changeset
|
4244 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4245 DW_MUTEX_UNLOCK; |
671
c60a4f6cfae8
Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
670
diff
changeset
|
4246 return; |
c60a4f6cfae8
Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
670
diff
changeset
|
4247 } |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4248 if(type & DW_CFA_BITMAPORICON) |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4249 { |
671
c60a4f6cfae8
Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
670
diff
changeset
|
4250 object = *((NSImage **)data); |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4251 } |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4252 else if(type & DW_CFA_STRING) |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4253 { |
726
ecf47778caff
Possible fix for container string columns not showing correctly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
725
diff
changeset
|
4254 char *str = *((char **)data); |
ecf47778caff
Possible fix for container string columns not showing correctly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
725
diff
changeset
|
4255 object = [ NSString stringWithUTF8String:str ]; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4256 } |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4257 else |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4258 { |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4259 char textbuffer[100]; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4260 |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4261 if(type & DW_CFA_ULONG) |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4262 { |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4263 ULONG tmp = *((ULONG *)data); |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4264 |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4265 sprintf(textbuffer, "%lu", tmp); |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4266 } |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4267 else if(type & DW_CFA_DATE) |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4268 { |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4269 struct tm curtm; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4270 CDATE cdate = *((CDATE *)data); |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4271 |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4272 memset( &curtm, 0, sizeof(curtm) ); |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4273 curtm.tm_mday = cdate.day; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4274 curtm.tm_mon = cdate.month - 1; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4275 curtm.tm_year = cdate.year - 1900; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4276 |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4277 strftime(textbuffer, 100, "%x", &curtm); |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4278 } |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4279 else if(type & DW_CFA_TIME) |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4280 { |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4281 struct tm curtm; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4282 CTIME ctime = *((CTIME *)data); |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4283 |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4284 memset( &curtm, 0, sizeof(curtm) ); |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4285 curtm.tm_hour = ctime.hours; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4286 curtm.tm_min = ctime.minutes; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4287 curtm.tm_sec = ctime.seconds; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4288 |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4289 strftime(textbuffer, 100, "%X", &curtm); |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4290 } |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4291 else |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4292 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4293 DW_MUTEX_UNLOCK; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4294 return; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4295 } |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4296 object = [ NSString stringWithUTF8String:textbuffer ]; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4297 } |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4298 |
658
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
4299 [cont editCell:object at:(row+lastadd) and:column]; |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4300 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4301 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4302 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4303 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4304 * Changes an existing item in specified row and column to the given data. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4305 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4306 * handle: Handle to the container window (widget). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4307 * column: Zero based column of data being set. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4308 * row: Zero based row of data being set. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4309 * data: Pointer to the data to be added. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4310 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4311 void API dw_container_change_item(HWND handle, int column, int row, void *data) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4312 { |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4313 dw_container_set_item(handle, NULL, column, row, data); |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4314 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4315 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4316 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4317 * Changes an existing item in specified row and column to the given data. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4318 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4319 * handle: Handle to the container window (widget). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4320 * column: Zero based column of data being set. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4321 * row: Zero based row of data being set. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4322 * data: Pointer to the data to be added. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4323 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4324 void API dw_filesystem_change_item(HWND handle, int column, int row, void *data) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4325 { |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4326 dw_container_change_item(handle, column+2, row, data); |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4327 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4328 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4329 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4330 * Changes an item in specified row and column to the given data. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4331 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4332 * handle: Handle to the container window (widget). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4333 * pointer: Pointer to the allocated memory in dw_container_alloc(). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4334 * column: Zero based column of data being set. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4335 * row: Zero based row of data being set. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4336 * data: Pointer to the data to be added. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4337 */ |
671
c60a4f6cfae8
Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
670
diff
changeset
|
4338 void API dw_filesystem_change_file(HWND handle, int row, char *filename, HICN icon) |
c60a4f6cfae8
Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
670
diff
changeset
|
4339 { |
c60a4f6cfae8
Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
670
diff
changeset
|
4340 dw_container_change_item(handle, 0, row, &icon); |
726
ecf47778caff
Possible fix for container string columns not showing correctly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
725
diff
changeset
|
4341 dw_container_change_item(handle, 1, row, &filename); |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4342 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4343 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4344 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4345 * Sets an item in specified row and column to the given data. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4346 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4347 * handle: Handle to the container window (widget). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4348 * pointer: Pointer to the allocated memory in dw_container_alloc(). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4349 * column: Zero based column of data being set. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4350 * row: Zero based row of data being set. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4351 * data: Pointer to the data to be added. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4352 */ |
671
c60a4f6cfae8
Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
670
diff
changeset
|
4353 void API dw_filesystem_set_file(HWND handle, void *pointer, int row, char *filename, HICN icon) |
c60a4f6cfae8
Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
670
diff
changeset
|
4354 { |
c60a4f6cfae8
Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
670
diff
changeset
|
4355 dw_container_set_item(handle, pointer, 0, row, &icon); |
726
ecf47778caff
Possible fix for container string columns not showing correctly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
725
diff
changeset
|
4356 dw_container_set_item(handle, pointer, 1, row, &filename); |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4357 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4358 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4359 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4360 * Sets an item in specified row and column to the given data. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4361 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4362 * handle: Handle to the container window (widget). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4363 * pointer: Pointer to the allocated memory in dw_container_alloc(). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4364 * column: Zero based column of data being set. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4365 * row: Zero based row of data being set. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4366 * data: Pointer to the data to be added. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4367 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4368 void API dw_filesystem_set_item(HWND handle, void *pointer, int column, int row, void *data) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4369 { |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4370 dw_container_set_item(handle, pointer, column+2, row, data); |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4371 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4372 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4373 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4374 * Gets column type for a container column |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4375 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4376 * handle: Handle to the container window (widget). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4377 * column: Zero based column. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4378 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4379 int API dw_container_get_column_type(HWND handle, int column) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4380 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4381 int _locked_by_me = FALSE; |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4382 DW_MUTEX_LOCK; |
721
56053f1af9ee
Fixes for dw_container/filessystem_get_column_type from Mark Hessling... adding him to the copyright section.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
720
diff
changeset
|
4383 DWContainer *cont = handle; |
56053f1af9ee
Fixes for dw_container/filessystem_get_column_type from Mark Hessling... adding him to the copyright section.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
720
diff
changeset
|
4384 int rc; |
56053f1af9ee
Fixes for dw_container/filessystem_get_column_type from Mark Hessling... adding him to the copyright section.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
720
diff
changeset
|
4385 int flag = [cont cellType:column]; |
56053f1af9ee
Fixes for dw_container/filessystem_get_column_type from Mark Hessling... adding him to the copyright section.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
720
diff
changeset
|
4386 if(flag & DW_CFA_BITMAPORICON) |
56053f1af9ee
Fixes for dw_container/filessystem_get_column_type from Mark Hessling... adding him to the copyright section.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
720
diff
changeset
|
4387 rc = DW_CFA_BITMAPORICON; |
56053f1af9ee
Fixes for dw_container/filessystem_get_column_type from Mark Hessling... adding him to the copyright section.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
720
diff
changeset
|
4388 else if(flag & DW_CFA_STRING) |
56053f1af9ee
Fixes for dw_container/filessystem_get_column_type from Mark Hessling... adding him to the copyright section.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
720
diff
changeset
|
4389 rc = DW_CFA_STRING; |
56053f1af9ee
Fixes for dw_container/filessystem_get_column_type from Mark Hessling... adding him to the copyright section.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
720
diff
changeset
|
4390 else if(flag & DW_CFA_ULONG) |
56053f1af9ee
Fixes for dw_container/filessystem_get_column_type from Mark Hessling... adding him to the copyright section.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
720
diff
changeset
|
4391 rc = DW_CFA_ULONG; |
56053f1af9ee
Fixes for dw_container/filessystem_get_column_type from Mark Hessling... adding him to the copyright section.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
720
diff
changeset
|
4392 else if(flag & DW_CFA_DATE) |
56053f1af9ee
Fixes for dw_container/filessystem_get_column_type from Mark Hessling... adding him to the copyright section.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
720
diff
changeset
|
4393 rc = DW_CFA_DATE; |
56053f1af9ee
Fixes for dw_container/filessystem_get_column_type from Mark Hessling... adding him to the copyright section.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
720
diff
changeset
|
4394 else if(flag & DW_CFA_TIME) |
56053f1af9ee
Fixes for dw_container/filessystem_get_column_type from Mark Hessling... adding him to the copyright section.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
720
diff
changeset
|
4395 rc = DW_CFA_TIME; |
56053f1af9ee
Fixes for dw_container/filessystem_get_column_type from Mark Hessling... adding him to the copyright section.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
720
diff
changeset
|
4396 else |
56053f1af9ee
Fixes for dw_container/filessystem_get_column_type from Mark Hessling... adding him to the copyright section.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
720
diff
changeset
|
4397 rc = 0; |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4398 DW_MUTEX_UNLOCK; |
721
56053f1af9ee
Fixes for dw_container/filessystem_get_column_type from Mark Hessling... adding him to the copyright section.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
720
diff
changeset
|
4399 return rc; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4400 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4401 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4402 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4403 * Gets column type for a filesystem container column |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4404 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4405 * handle: Handle to the container window (widget). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4406 * column: Zero based column. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4407 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4408 int API dw_filesystem_get_column_type(HWND handle, int column) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4409 { |
721
56053f1af9ee
Fixes for dw_container/filessystem_get_column_type from Mark Hessling... adding him to the copyright section.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
720
diff
changeset
|
4410 return dw_container_get_column_type(handle, column+2); |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4411 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4412 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4413 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4414 * Sets the width of a column in the container. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4415 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4416 * handle: Handle to window (widget) of container. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4417 * column: Zero based column of width being set. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4418 * width: Width of column in pixels. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4419 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4420 void API dw_container_set_column_width(HWND handle, int column, int width) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4421 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4422 int _locked_by_me = FALSE; |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4423 DW_MUTEX_LOCK; |
675
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4424 DWContainer *cont = handle; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4425 NSTableColumn *col = [cont getColumn:column]; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4426 |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4427 [col setWidth:width]; |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4428 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4429 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4430 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4431 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4432 * Sets the title of a row in the container. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4433 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4434 * pointer: Pointer to the allocated memory in dw_container_alloc(). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4435 * row: Zero based row of data being set. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4436 * title: String title of the item. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4437 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4438 void API dw_container_set_row_title(void *pointer, int row, char *title) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4439 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4440 int _locked_by_me = FALSE; |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4441 DW_MUTEX_LOCK; |
659
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
4442 DWContainer *cont = pointer; |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4443 [cont setRow:row title:title]; |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4444 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4445 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4446 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4447 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4448 * Sets the title of a row in the container. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4449 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4450 * handle: Handle to the container window (widget). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4451 * pointer: Pointer to the allocated memory in dw_container_alloc(). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4452 * rowcount: The number of rows to be inserted. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4453 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4454 void API dw_container_insert(HWND handle, void *pointer, int rowcount) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4455 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4456 int _locked_by_me = FALSE; |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4457 DW_MUTEX_LOCK; |
658
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
4458 DWContainer *cont = handle; |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4459 [cont reloadData]; |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4460 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4461 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4462 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4463 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4464 * Removes all rows from a container. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4465 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4466 * handle: Handle to the window (widget) to be cleared. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4467 * redraw: TRUE to cause the container to redraw immediately. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4468 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4469 void API dw_container_clear(HWND handle, int redraw) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4470 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4471 int _locked_by_me = FALSE; |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4472 DW_MUTEX_LOCK; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4473 DWContainer *cont = handle; |
670
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
4474 [cont clear]; |
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
4475 if(redraw) |
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
4476 { |
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
4477 [cont reloadData]; |
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
4478 } |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4479 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4480 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4481 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4482 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4483 * Removes the first x rows from a container. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4484 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4485 * handle: Handle to the window (widget) to be deleted from. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4486 * rowcount: The number of rows to be deleted. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4487 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4488 void API dw_container_delete(HWND handle, int rowcount) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4489 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4490 int _locked_by_me = FALSE; |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4491 DW_MUTEX_LOCK; |
675
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4492 DWContainer *cont = handle; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4493 int x; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4494 |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4495 for(x=0;x<rowcount;x++) |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4496 { |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4497 [cont removeRow:0]; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4498 } |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4499 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4500 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4501 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4502 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4503 * Scrolls container up or down. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4504 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4505 * handle: Handle to the window (widget) to be scrolled. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4506 * direction: DW_SCROLL_UP, DW_SCROLL_DOWN, DW_SCROLL_TOP or |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4507 * DW_SCROLL_BOTTOM. (rows is ignored for last two) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4508 * rows: The number of rows to be scrolled. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4509 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4510 void API dw_container_scroll(HWND handle, int direction, long rows) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4511 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4512 NSLog(@"dw_container_scroll() unimplemented\n"); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4513 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4514 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4515 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4516 * Starts a new query of a container. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4517 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4518 * handle: Handle to the window (widget) to be queried. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4519 * flags: If this parameter is DW_CRA_SELECTED it will only |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4520 * return items that are currently selected. Otherwise |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4521 * it will return all records in the container. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4522 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4523 char * API dw_container_query_start(HWND handle, unsigned long flags) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4524 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4525 int _locked_by_me = FALSE; |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4526 DW_MUTEX_LOCK; |
675
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4527 DWContainer *cont = handle; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4528 NSIndexSet *selected = [cont selectedRowIndexes]; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4529 NSUInteger result = [selected indexGreaterThanOrEqualToIndex:0]; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4530 char *retval = NULL; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4531 |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4532 if(result != NSNotFound) |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4533 { |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4534 retval = [cont getRowTitle:(int)result]; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4535 [cont setLastQueryPoint:(int)result]; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4536 } |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4537 DW_MUTEX_UNLOCK; |
675
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4538 return retval; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4539 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4540 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4541 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4542 * Continues an existing query of a container. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4543 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4544 * handle: Handle to the window (widget) to be queried. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4545 * flags: If this parameter is DW_CRA_SELECTED it will only |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4546 * return items that are currently selected. Otherwise |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4547 * it will return all records in the container. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4548 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4549 char * API dw_container_query_next(HWND handle, unsigned long flags) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4550 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4551 int _locked_by_me = FALSE; |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4552 DW_MUTEX_LOCK; |
675
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4553 DWContainer *cont = handle; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4554 int lastQueryPoint = [cont lastQueryPoint]; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4555 NSIndexSet *selected = [cont selectedRowIndexes]; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4556 NSUInteger result = [selected indexGreaterThanIndex:lastQueryPoint]; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4557 char *retval = NULL; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4558 |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4559 if(result != NSNotFound) |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4560 { |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4561 retval = [cont getRowTitle:(int)result]; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4562 [cont setLastQueryPoint:(int)result]; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4563 } |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4564 DW_MUTEX_UNLOCK; |
675
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4565 return retval; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4566 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4567 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4568 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4569 * Cursors the item with the text speficied, and scrolls to that item. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4570 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4571 * handle: Handle to the window (widget) to be queried. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4572 * text: Text usually returned by dw_container_query(). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4573 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4574 void API dw_container_cursor(HWND handle, char *text) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4575 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4576 int _locked_by_me = FALSE; |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4577 DW_MUTEX_LOCK; |
675
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4578 DWContainer *cont = handle; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4579 char *thistext; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4580 int x, count = (int)[cont numberOfRowsInTableView:cont]; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4581 |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4582 for(x=0;x<count;x++) |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4583 { |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4584 thistext = [cont getRowTitle:x]; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4585 |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4586 if(thistext == text) |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4587 { |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4588 NSIndexSet *selected = [[NSIndexSet alloc] initWithIndex:(NSUInteger)x]; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4589 |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4590 [cont selectRowIndexes:selected byExtendingSelection:YES]; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4591 [selected release]; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4592 } |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4593 } |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4594 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4595 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4596 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4597 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4598 * Deletes the item with the text speficied. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4599 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4600 * handle: Handle to the window (widget). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4601 * text: Text usually returned by dw_container_query(). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4602 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4603 void API dw_container_delete_row(HWND handle, char *text) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4604 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4605 int _locked_by_me = FALSE; |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4606 DW_MUTEX_LOCK; |
675
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4607 DWContainer *cont = handle; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4608 char *thistext; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4609 int x, count = (int)[cont numberOfRowsInTableView:cont]; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4610 |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4611 for(x=0;x<count;x++) |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4612 { |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4613 thistext = [cont getRowTitle:x]; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4614 |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4615 if(thistext == text) |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4616 { |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4617 [cont removeRow:x]; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4618 return; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4619 } |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4620 } |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4621 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4622 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4623 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4624 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4625 * Optimizes the column widths so that all data is visible. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4626 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4627 * handle: Handle to the window (widget) to be optimized. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4628 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4629 void API dw_container_optimize(HWND handle) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4630 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4631 int _locked_by_me = FALSE; |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4632 DW_MUTEX_LOCK; |
658
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
4633 DWContainer *cont = handle; |
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
4634 /*[cont sizeToFit];*/ |
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
4635 [cont setColumnAutoresizingStyle:NSTableViewUniformColumnAutoresizingStyle]; |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4636 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4637 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4638 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4639 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4640 * Inserts an icon into the taskbar. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4641 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4642 * handle: Window handle that will handle taskbar icon messages. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4643 * icon: Icon handle to display in the taskbar. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4644 * bubbletext: Text to show when the mouse is above the icon. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4645 */ |
671
c60a4f6cfae8
Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
670
diff
changeset
|
4646 void API dw_taskbar_insert(HWND handle, HICN icon, char *bubbletext) |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4647 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4648 NSLog(@"dw_taskbar_insert() unimplemented\n"); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4649 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4650 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4651 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4652 * Deletes an icon from the taskbar. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4653 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4654 * handle: Window handle that was used with dw_taskbar_insert(). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4655 * icon: Icon handle that was used with dw_taskbar_insert(). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4656 */ |
671
c60a4f6cfae8
Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
670
diff
changeset
|
4657 void API dw_taskbar_delete(HWND handle, HICN icon) |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4658 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4659 NSLog(@"dw_taskbar_delete() unimplemented\n"); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4660 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4661 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4662 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4663 * Obtains an icon from a module (or header in GTK). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4664 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4665 * module: Handle to module (DLL) in OS/2 and Windows. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4666 * id: A unsigned long id int the resources on OS/2 and |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4667 * Windows, on GTK this is converted to a pointer |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4668 * to an embedded XPM. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4669 */ |
671
c60a4f6cfae8
Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
670
diff
changeset
|
4670 HICN API dw_icon_load(unsigned long module, unsigned long resid) |
c60a4f6cfae8
Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
670
diff
changeset
|
4671 { |
c60a4f6cfae8
Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
670
diff
changeset
|
4672 NSBundle *bundle = [NSBundle mainBundle]; |
c60a4f6cfae8
Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
670
diff
changeset
|
4673 NSString *respath = [bundle resourcePath]; |
c60a4f6cfae8
Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
670
diff
changeset
|
4674 NSString *filepath = [respath stringByAppendingFormat:@"/%u.png", resid]; |
c60a4f6cfae8
Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
670
diff
changeset
|
4675 NSImage *image = [[NSImage alloc] initWithContentsOfFile:filepath]; |
c60a4f6cfae8
Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
670
diff
changeset
|
4676 return image; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4677 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4678 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4679 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4680 * Obtains an icon from a file. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4681 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4682 * filename: Name of the file, omit extention to have |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4683 * DW pick the appropriate file extension. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4684 * (ICO on OS/2 or Windows, XPM on Unix) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4685 */ |
671
c60a4f6cfae8
Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
670
diff
changeset
|
4686 HICN API dw_icon_load_from_file(char *filename) |
c60a4f6cfae8
Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
670
diff
changeset
|
4687 { |
674
78f9aa6d6d89
Fixes or fonts and loading images from files. Added Mac specific settings to dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
673
diff
changeset
|
4688 NSString *nstr = [ NSString stringWithUTF8String:filename ]; |
78f9aa6d6d89
Fixes or fonts and loading images from files. Added Mac specific settings to dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
673
diff
changeset
|
4689 NSImage *image = [[NSImage alloc] initWithContentsOfFile:nstr]; |
78f9aa6d6d89
Fixes or fonts and loading images from files. Added Mac specific settings to dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
673
diff
changeset
|
4690 if(!image) |
78f9aa6d6d89
Fixes or fonts and loading images from files. Added Mac specific settings to dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
673
diff
changeset
|
4691 { |
78f9aa6d6d89
Fixes or fonts and loading images from files. Added Mac specific settings to dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
673
diff
changeset
|
4692 nstr = [nstr stringByAppendingString:@".png"]; |
78f9aa6d6d89
Fixes or fonts and loading images from files. Added Mac specific settings to dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
673
diff
changeset
|
4693 image = [[NSImage alloc] initWithContentsOfFile:nstr]; |
78f9aa6d6d89
Fixes or fonts and loading images from files. Added Mac specific settings to dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
673
diff
changeset
|
4694 } |
78f9aa6d6d89
Fixes or fonts and loading images from files. Added Mac specific settings to dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
673
diff
changeset
|
4695 return image; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4696 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4697 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4698 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4699 * Obtains an icon from data |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4700 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4701 * filename: Name of the file, omit extention to have |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4702 * DW pick the appropriate file extension. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4703 * (ICO on OS/2 or Windows, XPM on Unix) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4704 */ |
671
c60a4f6cfae8
Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
670
diff
changeset
|
4705 HICN API dw_icon_load_from_data(char *data, int len) |
c60a4f6cfae8
Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
670
diff
changeset
|
4706 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4707 NSData *thisdata = [[NSData alloc] dataWithBytes:data length:len]; |
671
c60a4f6cfae8
Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
670
diff
changeset
|
4708 NSImage *image = [[NSImage alloc] initWithData:thisdata]; |
c60a4f6cfae8
Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
670
diff
changeset
|
4709 return image; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4710 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4711 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4712 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4713 * Frees a loaded resource in OS/2 and Windows. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4714 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4715 * handle: Handle to icon returned by dw_icon_load(). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4716 */ |
671
c60a4f6cfae8
Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
670
diff
changeset
|
4717 void API dw_icon_free(HICN handle) |
c60a4f6cfae8
Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
670
diff
changeset
|
4718 { |
c60a4f6cfae8
Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
670
diff
changeset
|
4719 NSImage *image = handle; |
c60a4f6cfae8
Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
670
diff
changeset
|
4720 [image release]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4721 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4722 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4723 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4724 * Create a new MDI Frame to be packed. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4725 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4726 * id: An ID to be used with dw_window_from_id or 0L. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4727 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
4728 HWND API dw_mdi_new(unsigned long cid) |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4729 { |
684
014b02436c1f
Added MDI simulation code... the MDI "window" will just be a box for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
683
diff
changeset
|
4730 /* There isn't anything like quite like MDI on MacOS... |
014b02436c1f
Added MDI simulation code... the MDI "window" will just be a box for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
683
diff
changeset
|
4731 * However we will make floating windows that hide |
014b02436c1f
Added MDI simulation code... the MDI "window" will just be a box for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
683
diff
changeset
|
4732 * when the application is deactivated to simulate |
014b02436c1f
Added MDI simulation code... the MDI "window" will just be a box for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
683
diff
changeset
|
4733 * similar behavior. |
014b02436c1f
Added MDI simulation code... the MDI "window" will just be a box for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
683
diff
changeset
|
4734 */ |
014b02436c1f
Added MDI simulation code... the MDI "window" will just be a box for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
683
diff
changeset
|
4735 DWMDI *mdi = [[DWMDI alloc] init]; |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
4736 /* [mdi setTag:cid]; Why doesn't this work? */ |
684
014b02436c1f
Added MDI simulation code... the MDI "window" will just be a box for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
683
diff
changeset
|
4737 return mdi; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4738 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4739 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4740 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4741 * Creates a splitbar window (widget) with given parameters. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4742 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4743 * type: Value can be DW_VERT or DW_HORZ. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4744 * topleft: Handle to the window to be top or left. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4745 * bottomright: Handle to the window to be bottom or right. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4746 * Returns: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4747 * A handle to a splitbar window or NULL on failure. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4748 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
4749 HWND API dw_splitbar_new(int type, HWND topleft, HWND bottomright, unsigned long cid) |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4750 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4751 HWND tmpbox = dw_box_new(DW_VERT, 0); |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4752 int _locked_by_me = FALSE; |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4753 DW_MUTEX_LOCK; |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
4754 DWSplitBar *split = [[DWSplitBar alloc] init]; |
668
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
4755 [split setDelegate:split]; |
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
4756 dw_box_pack_start(tmpbox, topleft, 0, 0, TRUE, TRUE, 0); |
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
4757 [split addSubview:tmpbox]; |
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
4758 tmpbox = dw_box_new(DW_VERT, 0); |
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
4759 dw_box_pack_start(tmpbox, bottomright, 0, 0, TRUE, TRUE, 0); |
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
4760 [split addSubview:tmpbox]; |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
4761 if(type == DW_VERT) |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
4762 { |
668
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
4763 [split setVertical:NO]; |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
4764 } |
668
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
4765 else |
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
4766 { |
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
4767 [split setVertical:YES]; |
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
4768 } |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
4769 /* [split setTag:cid]; Why doesn't this work? */ |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4770 DW_MUTEX_UNLOCK; |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
4771 return split; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4772 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4773 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4774 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4775 * Sets the position of a splitbar (pecentage). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4776 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4777 * handle: The handle to the splitbar returned by dw_splitbar_new(). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4778 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4779 void API dw_splitbar_set(HWND handle, float percent) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4780 { |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
4781 DWSplitBar *split = handle; |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4782 int _locked_by_me = FALSE; |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4783 DW_MUTEX_LOCK; |
676
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
4784 NSRect rect = [split frame]; |
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
4785 float pos; |
677
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
4786 /* Calculate the position based on the size */ |
676
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
4787 if([split isVertical]) |
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
4788 { |
677
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
4789 pos = rect.size.width * (percent / 100.0); |
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
4790 } |
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
4791 else |
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
4792 { |
676
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
4793 pos = rect.size.height * (percent / 100.0); |
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
4794 } |
677
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
4795 if(pos > 0) |
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
4796 { |
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
4797 [split setPosition:pos ofDividerAtIndex:0]; |
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
4798 } |
676
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
4799 else |
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
4800 { |
677
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
4801 /* If we have no size.. wait until the resize |
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
4802 * event when we get an actual size to try |
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
4803 * to set the splitbar again. |
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
4804 */ |
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
4805 [split setPercent:percent]; |
676
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
4806 } |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4807 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4808 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4809 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4810 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4811 * Gets the position of a splitbar (pecentage). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4812 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4813 * handle: The handle to the splitbar returned by dw_splitbar_new(). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4814 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4815 float API dw_splitbar_get(HWND handle) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4816 { |
676
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
4817 DWSplitBar *split = handle; |
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
4818 NSRect rect1 = [split frame]; |
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
4819 NSArray *subviews = [split subviews]; |
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
4820 NSView *view = [subviews objectAtIndex:0]; |
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
4821 NSRect rect2 = [view frame]; |
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
4822 float pos, total, retval = 0.0; |
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
4823 if([split isVertical]) |
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
4824 { |
677
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
4825 total = rect1.size.width; |
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
4826 pos = rect2.size.width; |
676
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
4827 } |
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
4828 else |
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
4829 { |
677
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
4830 total = rect1.size.height; |
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
4831 pos = rect2.size.height; |
676
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
4832 } |
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
4833 if(total > 0) |
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
4834 { |
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
4835 retval = pos / total; |
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
4836 } |
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
4837 return retval; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4838 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4839 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4840 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4841 * Create a bitmap object to be packed. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4842 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4843 * id: An ID to be used with dw_window_from_id() or 0L. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4844 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
4845 HWND API dw_bitmap_new(ULONG cid) |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4846 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4847 int _locked_by_me = FALSE; |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4848 DW_MUTEX_LOCK; |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
4849 NSImageView *bitmap = [[NSImageView alloc] init]; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
4850 [bitmap setImageFrameStyle:NSImageFrameNone]; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
4851 [bitmap setEditable:NO]; |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
4852 [bitmap setTag:cid]; |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4853 DW_MUTEX_UNLOCK; |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
4854 return bitmap; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4855 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4856 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4857 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4858 * Creates a pixmap with given parameters. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4859 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4860 * handle: Window handle the pixmap is associated with. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4861 * width: Width of the pixmap in pixels. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4862 * height: Height of the pixmap in pixels. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4863 * depth: Color depth of the pixmap. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4864 * Returns: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4865 * A handle to a pixmap or NULL on failure. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4866 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4867 HPIXMAP API dw_pixmap_new(HWND handle, unsigned long width, unsigned long height, int depth) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4868 { |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
4869 NSSize size = { (float)width, (float)height }; |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
4870 HPIXMAP pixmap; |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
4871 |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
4872 if (!(pixmap = calloc(1,sizeof(struct _hpixmap)))) |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
4873 return NULL; |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
4874 pixmap->width = width; |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
4875 pixmap->height = height; |
664
ba3af8eb56f1
Fixed drawing of rects and points. Fonts now properly draw in color. Updated property list.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
662
diff
changeset
|
4876 NSImage *image = pixmap->handle = [[NSImage alloc] initWithSize:size]; |
ba3af8eb56f1
Fixed drawing of rects and points. Fonts now properly draw in color. Updated property list.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
662
diff
changeset
|
4877 [image setFlipped:YES]; |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
4878 return pixmap; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4879 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4880 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4881 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4882 * Creates a pixmap from a file. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4883 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4884 * handle: Window handle the pixmap is associated with. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4885 * filename: Name of the file, omit extention to have |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4886 * DW pick the appropriate file extension. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4887 * (BMP on OS/2 or Windows, XPM on Unix) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4888 * Returns: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4889 * A handle to a pixmap or NULL on failure. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4890 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4891 HPIXMAP API dw_pixmap_new_from_file(HWND handle, char *filename) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4892 { |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
4893 HPIXMAP pixmap; |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
4894 |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
4895 if (!(pixmap = calloc(1,sizeof(struct _hpixmap)))) |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
4896 return NULL; |
674
78f9aa6d6d89
Fixes or fonts and loading images from files. Added Mac specific settings to dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
673
diff
changeset
|
4897 NSString *nstr = [ NSString stringWithUTF8String:filename ]; |
78f9aa6d6d89
Fixes or fonts and loading images from files. Added Mac specific settings to dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
673
diff
changeset
|
4898 NSImage *image = [[NSImage alloc] initWithContentsOfFile:nstr]; |
78f9aa6d6d89
Fixes or fonts and loading images from files. Added Mac specific settings to dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
673
diff
changeset
|
4899 if(!image) |
78f9aa6d6d89
Fixes or fonts and loading images from files. Added Mac specific settings to dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
673
diff
changeset
|
4900 { |
78f9aa6d6d89
Fixes or fonts and loading images from files. Added Mac specific settings to dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
673
diff
changeset
|
4901 nstr = [nstr stringByAppendingString:@".png"]; |
78f9aa6d6d89
Fixes or fonts and loading images from files. Added Mac specific settings to dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
673
diff
changeset
|
4902 image = [[NSImage alloc] initWithContentsOfFile:nstr]; |
78f9aa6d6d89
Fixes or fonts and loading images from files. Added Mac specific settings to dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
673
diff
changeset
|
4903 } |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
4904 NSSize size = [image size]; |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
4905 pixmap->width = size.width; |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
4906 pixmap->height = size.height; |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
4907 pixmap->handle = image; |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
4908 return pixmap; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4909 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4910 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4911 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4912 * Creates a pixmap from memory. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4913 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4914 * handle: Window handle the pixmap is associated with. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4915 * data: Source of the image data |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4916 * (BMP on OS/2 or Windows, XPM on Unix) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4917 * le: length of data |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4918 * Returns: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4919 * A handle to a pixmap or NULL on failure. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4920 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4921 HPIXMAP API dw_pixmap_new_from_data(HWND handle, char *data, int len) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4922 { |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
4923 HPIXMAP pixmap; |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
4924 |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
4925 if (!(pixmap = calloc(1,sizeof(struct _hpixmap)))) |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
4926 return NULL; |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4927 NSData *thisdata = [[NSData alloc] dataWithBytes:data length:len]; |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
4928 NSImage *image = [[NSImage alloc] initWithData:thisdata]; |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
4929 NSSize size = [image size]; |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
4930 pixmap->width = size.width; |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
4931 pixmap->height = size.height; |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
4932 pixmap->handle = image; |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
4933 return pixmap; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4934 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4935 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4936 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4937 * Creates a bitmap mask for rendering bitmaps with transparent backgrounds |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4938 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4939 void API dw_pixmap_set_transparent_color( HPIXMAP pixmap, ULONG color ) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4940 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4941 NSLog(@"dw_pixmap_set_transparent_color() unimplemented\n"); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4942 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4943 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4944 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4945 * Creates a pixmap from internal resource graphic specified by id. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4946 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4947 * handle: Window handle the pixmap is associated with. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4948 * id: Resource ID associated with requested pixmap. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4949 * Returns: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4950 * A handle to a pixmap or NULL on failure. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4951 */ |
670
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
4952 HPIXMAP API dw_pixmap_grab(HWND handle, ULONG resid) |
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
4953 { |
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
4954 HPIXMAP pixmap; |
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
4955 |
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
4956 if (!(pixmap = calloc(1,sizeof(struct _hpixmap)))) |
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
4957 return NULL; |
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
4958 |
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
4959 NSBundle *bundle = [NSBundle mainBundle]; |
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
4960 NSString *respath = [bundle resourcePath]; |
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
4961 NSString *filepath = [respath stringByAppendingFormat:@"/%u.png", resid]; |
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
4962 NSImage *image = [[NSImage alloc] initWithContentsOfFile:filepath]; |
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
4963 NSSize size = [image size]; |
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
4964 pixmap->width = size.width; |
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
4965 pixmap->height = size.height; |
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
4966 pixmap->handle = image; |
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
4967 [image release]; |
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
4968 return pixmap; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4969 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4970 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4971 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4972 * Destroys an allocated pixmap. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4973 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4974 * pixmap: Handle to a pixmap returned by |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4975 * dw_pixmap_new.. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4976 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4977 void API dw_pixmap_destroy(HPIXMAP pixmap) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4978 { |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
4979 NSImage *image = (NSImage *)pixmap->handle; |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
4980 [image dealloc]; |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
4981 free(pixmap); |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4982 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4983 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4984 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4985 * Copies from one item to another. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4986 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4987 * dest: Destination window handle. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4988 * destp: Destination pixmap. (choose only one). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4989 * xdest: X coordinate of destination. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4990 * ydest: Y coordinate of destination. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4991 * width: Width of area to copy. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4992 * height: Height of area to copy. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4993 * src: Source window handle. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4994 * srcp: Source pixmap. (choose only one). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4995 * xsrc: X coordinate of source. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4996 * ysrc: Y coordinate of source. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4997 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4998 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) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4999 { |
699
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
5000 DWBitBlt *bltinfo = calloc(1, sizeof(DWBitBlt)); |
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
5001 NSValue* bi = [NSValue valueWithPointer:bltinfo]; |
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
5002 |
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
5003 /* Fill in the information */ |
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
5004 bltinfo->dest = dest; |
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
5005 bltinfo->src = src; |
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
5006 bltinfo->xdest = xdest; |
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
5007 bltinfo->ydest = ydest; |
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
5008 bltinfo->width = width; |
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
5009 bltinfo->height = height; |
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
5010 bltinfo->xsrc = xsrc; |
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
5011 bltinfo->ysrc = ysrc; |
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
5012 |
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
5013 if(destp) |
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
5014 { |
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
5015 bltinfo->dest = (id)destp->handle; |
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
5016 } |
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
5017 if(srcp) |
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
5018 { |
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
5019 id object = bltinfo->src = (id)srcp->handle; |
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
5020 [object retain]; |
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
5021 } |
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
5022 [DWObj performSelectorOnMainThread:@selector(doBitBlt:) withObject:bi waitUntilDone:YES]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5023 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5024 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5025 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5026 * Create a new static text window (widget) to be packed. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5027 * Not available under OS/2, eCS |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5028 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5029 * text: The text to be display by the static text widget. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5030 * id: An ID to be used with dw_window_from_id() or 0L. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5031 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
5032 HWND API dw_calendar_new(ULONG cid) |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5033 { |
655
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
5034 DWCalendar *calendar = [[DWCalendar alloc] init]; |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
5035 /*[calendar setDatePickerMode:UIDatePickerModeDate];*/ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
5036 [calendar setTag:cid]; |
655
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
5037 return calendar; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5038 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5039 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5040 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5041 * Sets the current date of a calendar |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5042 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5043 * handle: The handle to the calendar returned by dw_calendar_new(). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5044 * year... |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5045 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5046 void dw_calendar_set_date(HWND handle, unsigned int year, unsigned int month, unsigned int day) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5047 { |
655
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
5048 DWCalendar *calendar = handle; |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
5049 NSDate *date; |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
5050 char buffer[100]; |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
5051 |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
5052 sprintf(buffer, "%04d-%02d-%02d 00:00:00 +0600", year, month, day); |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
5053 |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
5054 date = [[NSDate alloc] initWithString:[ NSString stringWithUTF8String:buffer ]]; |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
5055 [calendar setDateValue:date]; |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
5056 [date release]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5057 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5058 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5059 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5060 * Gets the position of a splitbar (pecentage). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5061 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5062 * handle: The handle to the splitbar returned by dw_splitbar_new(). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5063 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5064 void dw_calendar_get_date(HWND handle, unsigned int *year, unsigned int *month, unsigned int *day) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5065 { |
655
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
5066 DWCalendar *calendar = handle; |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
5067 NSDate *date = [calendar dateValue]; |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
5068 NSDateFormatter *df = [[NSDateFormatter alloc] init]; |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
5069 NSString *nstr = [df stringFromDate:date]; |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
5070 sscanf([ nstr UTF8String ], "%d-%d-%d", year, month, day); |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
5071 [df release]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5072 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5073 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5074 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5075 * Causes the embedded HTML widget to take action. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5076 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5077 * handle: Handle to the window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5078 * action: One of the DW_HTML_* constants. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5079 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5080 void API dw_html_action(HWND handle, int action) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5081 { |
655
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
5082 WebView *html = handle; |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
5083 switch(action) |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
5084 { |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
5085 case DW_HTML_GOBACK: |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
5086 [html goBack]; |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
5087 break; |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
5088 case DW_HTML_GOFORWARD: |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
5089 [html goForward]; |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
5090 break; |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
5091 case DW_HTML_GOHOME: |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
5092 break; |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
5093 case DW_HTML_SEARCH: |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
5094 break; |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
5095 case DW_HTML_RELOAD: |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
5096 [html reload:html]; |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
5097 break; |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
5098 case DW_HTML_STOP: |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
5099 [html stopLoading:html]; |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
5100 break; |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
5101 case DW_HTML_PRINT: |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
5102 break; |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
5103 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5104 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5105 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5106 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5107 * Render raw HTML code in the embedded HTML widget.. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5108 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5109 * handle: Handle to the window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5110 * string: String buffer containt HTML code to |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5111 * be rendered. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5112 * Returns: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5113 * 0 on success. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5114 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5115 int API dw_html_raw(HWND handle, char *string) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5116 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5117 WebView *html = handle; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5118 [[html mainFrame] loadHTMLString:[ NSString stringWithUTF8String:string ] baseURL:nil]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5119 return 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5120 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5121 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5122 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5123 * Render file or web page in the embedded HTML widget.. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5124 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5125 * handle: Handle to the window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5126 * url: Universal Resource Locator of the web or |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5127 * file object to be rendered. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5128 * Returns: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5129 * 0 on success. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5130 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5131 int API dw_html_url(HWND handle, char *url) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5132 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5133 WebView *html = handle; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5134 [[html mainFrame] loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:[ NSString stringWithUTF8String:url ]]]]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5135 return 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5136 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5137 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5138 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5139 * Create a new HTML window (widget) to be packed. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5140 * Not available under OS/2, eCS |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5141 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5142 * text: The default text to be in the entryfield widget. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5143 * id: An ID to be used with dw_window_from_id() or 0L. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5144 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
5145 HWND API dw_html_new(unsigned long cid) |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5146 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
5147 int _locked_by_me = FALSE; |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
5148 DW_MUTEX_LOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5149 WebView *web = [[WebView alloc] init]; |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
5150 /* [web setTag:cid]; Why doesn't this work? */ |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
5151 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5152 return web; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5153 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5154 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5155 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5156 * Returns the current X and Y coordinates of the mouse pointer. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5157 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5158 * x: Pointer to variable to store X coordinate. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5159 * y: Pointer to variable to store Y coordinate. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5160 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5161 void API dw_pointer_query_pos(long *x, long *y) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5162 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5163 NSPoint mouseLoc; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5164 mouseLoc = [NSEvent mouseLocation]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5165 if(x) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5166 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5167 *x = mouseLoc.x; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5168 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5169 if(y) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5170 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5171 *y = mouseLoc.y; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5172 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5173 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5174 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5175 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5176 * Sets the X and Y coordinates of the mouse pointer. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5177 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5178 * x: X coordinate. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5179 * y: Y coordinate. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5180 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5181 void API dw_pointer_set_pos(long x, long y) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5182 { |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
5183 /* From what I have read this isn't possible, agaist human interface rules */ |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5184 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5185 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5186 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5187 * Create a menu object to be popped up. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5188 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5189 * id: An ID to be used for getting the resource from the |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5190 * resource file. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5191 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
5192 HMENUI API dw_menu_new(ULONG cid) |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5193 { |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5194 NSMenu *menu = [[[NSMenu alloc] init] autorelease]; |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5195 [menu setAutoenablesItems:NO]; |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
5196 /* [menu setTag:cid]; Why doesn't this work? */ |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5197 return menu; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5198 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5199 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5200 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5201 * Create a menubar on a window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5202 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5203 * location: Handle of a window frame to be attached to. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5204 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5205 HMENUI API dw_menubar_new(HWND location) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5206 { |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5207 NSWindow *window = location; |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5208 NSMenu *windowmenu = _generate_main_menu(); |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5209 [[window contentView] setMenu:windowmenu]; |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5210 return (HMENUI)windowmenu; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5211 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5212 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5213 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5214 * Destroys a menu created with dw_menubar_new or dw_menu_new. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5215 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5216 * menu: Handle of a menu. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5217 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5218 void API dw_menu_destroy(HMENUI *menu) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5219 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5220 NSMenu *thismenu = *menu; |
658
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
5221 [thismenu release]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5222 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5223 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5224 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5225 * Pops up a context menu at given x and y coordinates. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5226 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5227 * menu: The handle the the existing menu. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5228 * parent: Handle to the window initiating the popup. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5229 * x: X coordinate. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5230 * y: Y coordinate. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5231 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5232 void API dw_menu_popup(HMENUI *menu, HWND parent, int x, int y) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5233 { |
702
e9a3d1da3d3e
dw_menu_popup() now uses the coordinates specified instead of the event coorindates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
701
diff
changeset
|
5234 NSMenu *thismenu = (NSMenu *)*menu; |
711
82250177f814
Fix for popup menus not being created when window handle passed is a toplevel window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
710
diff
changeset
|
5235 id object = parent; |
82250177f814
Fix for popup menus not being created when window handle passed is a toplevel window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
710
diff
changeset
|
5236 NSView *view = [object isKindOfClass:[NSWindow class]] ? [object contentView] : parent; |
702
e9a3d1da3d3e
dw_menu_popup() now uses the coordinates specified instead of the event coorindates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
701
diff
changeset
|
5237 NSWindow *window = [view window]; |
701
c91a1b345f2e
Fix for button press and context menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
700
diff
changeset
|
5238 NSEvent *event = [DWApp currentEvent]; |
702
e9a3d1da3d3e
dw_menu_popup() now uses the coordinates specified instead of the event coorindates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
701
diff
changeset
|
5239 NSEvent* fake = [NSEvent mouseEventWithType:NSRightMouseDown |
e9a3d1da3d3e
dw_menu_popup() now uses the coordinates specified instead of the event coorindates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
701
diff
changeset
|
5240 location:[window convertScreenToBase:NSMakePoint(x, y)] |
e9a3d1da3d3e
dw_menu_popup() now uses the coordinates specified instead of the event coorindates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
701
diff
changeset
|
5241 modifierFlags:0 |
e9a3d1da3d3e
dw_menu_popup() now uses the coordinates specified instead of the event coorindates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
701
diff
changeset
|
5242 timestamp:[event timestamp] |
e9a3d1da3d3e
dw_menu_popup() now uses the coordinates specified instead of the event coorindates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
701
diff
changeset
|
5243 windowNumber:[window windowNumber] |
e9a3d1da3d3e
dw_menu_popup() now uses the coordinates specified instead of the event coorindates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
701
diff
changeset
|
5244 context:[NSGraphicsContext currentContext] |
e9a3d1da3d3e
dw_menu_popup() now uses the coordinates specified instead of the event coorindates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
701
diff
changeset
|
5245 eventNumber:1 |
e9a3d1da3d3e
dw_menu_popup() now uses the coordinates specified instead of the event coorindates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
701
diff
changeset
|
5246 clickCount:1 |
e9a3d1da3d3e
dw_menu_popup() now uses the coordinates specified instead of the event coorindates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
701
diff
changeset
|
5247 pressure:0.0]; |
e9a3d1da3d3e
dw_menu_popup() now uses the coordinates specified instead of the event coorindates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
701
diff
changeset
|
5248 [NSMenu popUpContextMenu:thismenu withEvent:fake forView:view]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5249 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5250 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5251 char _removetilde(char *dest, char *src) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5252 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5253 int z, cur=0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5254 char accel = '\0'; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5255 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5256 for(z=0;z<strlen(src);z++) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5257 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5258 if(src[z] != '~') |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5259 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5260 dest[cur] = src[z]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5261 cur++; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5262 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5263 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5264 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5265 accel = src[z+1]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5266 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5267 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5268 dest[cur] = 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5269 return accel; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5270 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5271 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5272 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5273 * Adds a menuitem or submenu to an existing menu. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5274 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5275 * menu: The handle the the existing menu. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5276 * title: The title text on the menu item to be added. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5277 * id: An ID to be used for message passing. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5278 * flags: Extended attributes to set on the menu. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5279 * end: If TRUE memu is positioned at the end of the menu. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5280 * check: If TRUE menu is "check"able. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5281 * flags: Extended attributes to set on the menu. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5282 * submenu: Handle to an existing menu to be a submenu or NULL. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5283 */ |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5284 HWND API dw_menu_append_item(HMENUI menux, char *title, ULONG itemid, ULONG flags, int end, int check, HMENUI submenux) |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5285 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5286 NSMenu *menu = menux; |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5287 NSMenu *submenu = submenux; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5288 NSMenuItem *item = NULL; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5289 if(strlen(title) == 0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5290 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5291 [menu addItem:[NSMenuItem separatorItem]]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5292 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5293 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5294 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5295 char accel[2]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5296 char *newtitle = malloc(strlen(title)+1); |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5297 NSString *nstr; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5298 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5299 accel[0] = _removetilde(newtitle, title); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5300 accel[1] = 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5301 |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5302 nstr = [ NSString stringWithUTF8String:newtitle ]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5303 free(newtitle); |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5304 |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5305 item = [menu addItemWithTitle: nstr |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5306 action:@selector(menuHandler:) |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5307 keyEquivalent:[ NSString stringWithUTF8String:accel ]]; |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5308 [item setTag:itemid]; |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5309 if(flags & DW_MIS_CHECKED) |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5310 { |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5311 [item setState:NSOnState]; |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5312 } |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5313 if(flags & DW_MIS_DISABLED) |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5314 { |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5315 [item setEnabled:NO]; |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5316 } |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5317 |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5318 if(submenux) |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5319 { |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5320 [submenu setTitle:nstr]; |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5321 [menu setSubmenu:submenu forItem:item]; |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5322 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5323 return item; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5324 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5325 return item; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5326 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5327 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5328 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5329 * Sets the state of a menu item check. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5330 * Deprecated; use dw_menu_item_set_state() |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5331 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5332 * menu: The handle the the existing menu. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5333 * id: Menuitem id. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5334 * check: TRUE for checked FALSE for not checked. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5335 */ |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5336 void API dw_menu_item_set_check(HMENUI menux, unsigned long itemid, int check) |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5337 { |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5338 id menu = menux; |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5339 NSMenuItem *menuitem = (NSMenuItem *)[menu itemWithTag:itemid]; |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5340 |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5341 if(menuitem != nil) |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5342 { |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5343 if(check) |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5344 { |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5345 [menuitem setState:NSOnState]; |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5346 } |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5347 else |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5348 { |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5349 [menuitem setState:NSOffState]; |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5350 } |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5351 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5352 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5353 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5354 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5355 * Sets the state of a menu item. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5356 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5357 * menu: The handle to the existing menu. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5358 * id: Menuitem id. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5359 * flags: DW_MIS_ENABLED/DW_MIS_DISABLED |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5360 * DW_MIS_CHECKED/DW_MIS_UNCHECKED |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5361 */ |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5362 void API dw_menu_item_set_state(HMENUI menux, unsigned long itemid, unsigned long state) |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5363 { |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5364 id menu = menux; |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5365 NSMenuItem *menuitem = (NSMenuItem *)[menu itemWithTag:itemid]; |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5366 |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5367 if(menuitem != nil) |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5368 { |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5369 if(state & DW_MIS_CHECKED) |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5370 { |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5371 [menuitem setState:NSOnState]; |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5372 } |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5373 else if(state & DW_MIS_UNCHECKED) |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5374 { |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5375 [menuitem setState:NSOffState]; |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5376 } |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5377 if(state & DW_MIS_ENABLED) |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5378 { |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5379 [menuitem setEnabled:YES]; |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5380 } |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5381 else if(state & DW_MIS_DISABLED) |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5382 { |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5383 [menuitem setEnabled:NO]; |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5384 } |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5385 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5386 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5387 |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5388 /* Gets the notebook page from associated ID */ |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5389 DWNotebookPage *_notepage_from_id(DWNotebook *notebook, unsigned long pageid) |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5390 { |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5391 NSArray *pages = [notebook tabViewItems]; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5392 for(DWNotebookPage *notepage in pages) |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5393 { |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5394 if([notepage pageid] == pageid) |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5395 { |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5396 return notepage; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5397 } |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5398 } |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5399 return nil; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5400 } |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5401 |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5402 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5403 * Create a notebook object to be packed. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5404 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5405 * id: An ID to be used for getting the resource from the |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5406 * resource file. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5407 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
5408 HWND API dw_notebook_new(ULONG cid, int top) |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5409 { |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5410 DWNotebook *notebook = [[DWNotebook alloc] init]; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5411 [notebook setDelegate:notebook]; |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
5412 /* [notebook setTag:cid]; Why doesn't this work? */ |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5413 return notebook; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5414 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5415 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5416 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5417 * Adds a new page to specified notebook. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5418 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5419 * handle: Window (widget) handle. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5420 * flags: Any additional page creation flags. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5421 * front: If TRUE page is added at the beginning. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5422 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5423 unsigned long API dw_notebook_page_new(HWND handle, ULONG flags, int front) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5424 { |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5425 DWNotebook *notebook = handle; |
665
e6bec2290f3f
Fixing warnings with Xcode 4 and switched to manual releasing in the draw functions to stop leaking.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
664
diff
changeset
|
5426 NSInteger page = [notebook pageid]; |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5427 DWNotebookPage *notepage = [[DWNotebookPage alloc] initWithIdentifier:nil]; |
666
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
5428 [notepage setPageid:(NSInteger)page]; |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5429 if(front) |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5430 { |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5431 [notebook insertTabViewItem:notepage atIndex:(NSInteger)0]; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5432 } |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5433 else |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5434 { |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5435 [notebook addTabViewItem:notepage]; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5436 } |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5437 [notebook setPageid:(page+1)]; |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
5438 [notepage release]; |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5439 return (unsigned long)page; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5440 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5441 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5442 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5443 * Remove a page from a notebook. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5444 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5445 * handle: Handle to the notebook widget. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5446 * pageid: ID of the page to be destroyed. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5447 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5448 void API dw_notebook_page_destroy(HWND handle, unsigned int pageid) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5449 { |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5450 DWNotebook *notebook = handle; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5451 DWNotebookPage *notepage = _notepage_from_id(notebook, pageid); |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5452 |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5453 if(notepage != nil) |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5454 { |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5455 [notebook removeTabViewItem:notepage]; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5456 [notepage release]; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5457 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5458 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5459 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5460 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5461 * Queries the currently visible page ID. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5462 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5463 * handle: Handle to the notebook widget. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5464 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5465 unsigned long API dw_notebook_page_get(HWND handle) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5466 { |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5467 DWNotebook *notebook = handle; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5468 DWNotebookPage *notepage = (DWNotebookPage *)[notebook selectedTabViewItem]; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5469 return [notepage pageid]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5470 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5471 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5472 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5473 * Sets the currently visibale page ID. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5474 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5475 * handle: Handle to the notebook widget. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5476 * pageid: ID of the page to be made visible. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5477 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5478 void API dw_notebook_page_set(HWND handle, unsigned int pageid) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5479 { |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5480 DWNotebook *notebook = handle; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5481 DWNotebookPage *notepage = _notepage_from_id(notebook, pageid); |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5482 |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5483 if(notepage != nil) |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5484 { |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5485 [notebook selectTabViewItem:notepage]; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5486 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5487 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5488 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5489 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5490 * Sets the text on the specified notebook tab. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5491 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5492 * handle: Notebook handle. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5493 * pageid: Page ID of the tab to set. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5494 * text: Pointer to the text to set. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5495 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5496 void API dw_notebook_page_set_text(HWND handle, ULONG pageid, char *text) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5497 { |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5498 DWNotebook *notebook = handle; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5499 DWNotebookPage *notepage = _notepage_from_id(notebook, pageid); |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5500 |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5501 if(notepage != nil) |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5502 { |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5503 [notepage setLabel:[ NSString stringWithUTF8String:text ]]; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5504 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5505 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5506 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5507 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5508 * Sets the text on the specified notebook tab status area. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5509 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5510 * handle: Notebook handle. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5511 * pageid: Page ID of the tab to set. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5512 * text: Pointer to the text to set. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5513 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5514 void API dw_notebook_page_set_status_text(HWND handle, ULONG pageid, char *text) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5515 { |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5516 /* Note supported here... do nothing */ |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5517 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5518 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5519 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5520 * Packs the specified box into the notebook page. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5521 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5522 * handle: Handle to the notebook to be packed. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5523 * pageid: Page ID in the notebook which is being packed. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5524 * page: Box handle to be packed. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5525 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5526 void API dw_notebook_pack(HWND handle, ULONG pageid, HWND page) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5527 { |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5528 DWNotebook *notebook = handle; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5529 DWNotebookPage *notepage = _notepage_from_id(notebook, pageid); |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5530 |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5531 if(notepage != nil) |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5532 { |
667
28727d9a835c
Fix for a rather serious notebook layout bug.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
666
diff
changeset
|
5533 HWND tmpbox = dw_box_new(DW_VERT, 0); |
28727d9a835c
Fix for a rather serious notebook layout bug.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
666
diff
changeset
|
5534 DWBox *box = tmpbox; |
28727d9a835c
Fix for a rather serious notebook layout bug.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
666
diff
changeset
|
5535 |
28727d9a835c
Fix for a rather serious notebook layout bug.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
666
diff
changeset
|
5536 dw_box_pack_start(tmpbox, page, 0, 0, TRUE, TRUE, 0); |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5537 [notepage setView:box]; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5538 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5539 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5540 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5541 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5542 * Create a new Window Frame. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5543 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5544 * owner: The Owner's window handle or HWND_DESKTOP. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5545 * title: The Window title. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5546 * flStyle: Style flags, see the PM reference. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5547 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5548 HWND API dw_window_new(HWND hwndOwner, char *title, ULONG flStyle) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5549 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
5550 int _locked_by_me = FALSE; |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
5551 DW_MUTEX_LOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5552 NSRect frame = NSMakeRect(1,1,1,1); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5553 NSWindow *window = [[NSWindow alloc] |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5554 initWithContentRect:frame |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
5555 styleMask:(flStyle | NSTexturedBackgroundWindowMask) |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5556 backing:NSBackingStoreBuffered |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5557 defer:false]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5558 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5559 [window setTitle:[ NSString stringWithUTF8String:title ]]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5560 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5561 DWView *view = [[DWView alloc] init]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5562 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5563 [window setContentView:view]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5564 [window setDelegate:view]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5565 [window makeKeyAndOrderFront:nil]; |
719
d5e49ef8f541
Updated the #if for Snow Leopard/Leopard builds to handle them not being defined properly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
718
diff
changeset
|
5566 #ifdef BUILDING_FOR_SNOW_LEOPARD |
661
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
5567 [window setAllowsConcurrentViewDrawing:NO]; |
718
002f33d4439d
More 10.5 fixes... some selectors cause exceptions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
717
diff
changeset
|
5568 #endif |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
5569 [view release]; |
684
014b02436c1f
Added MDI simulation code... the MDI "window" will just be a box for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
683
diff
changeset
|
5570 |
014b02436c1f
Added MDI simulation code... the MDI "window" will just be a box for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
683
diff
changeset
|
5571 /* If it isn't a toplevel window... */ |
014b02436c1f
Added MDI simulation code... the MDI "window" will just be a box for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
683
diff
changeset
|
5572 if(hwndOwner) |
014b02436c1f
Added MDI simulation code... the MDI "window" will just be a box for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
683
diff
changeset
|
5573 { |
014b02436c1f
Added MDI simulation code... the MDI "window" will just be a box for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
683
diff
changeset
|
5574 id object = hwndOwner; |
014b02436c1f
Added MDI simulation code... the MDI "window" will just be a box for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
683
diff
changeset
|
5575 |
014b02436c1f
Added MDI simulation code... the MDI "window" will just be a box for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
683
diff
changeset
|
5576 /* Check to see if the parent is an MDI window */ |
014b02436c1f
Added MDI simulation code... the MDI "window" will just be a box for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
683
diff
changeset
|
5577 if([object isMemberOfClass:[DWMDI class]]) |
014b02436c1f
Added MDI simulation code... the MDI "window" will just be a box for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
683
diff
changeset
|
5578 { |
014b02436c1f
Added MDI simulation code... the MDI "window" will just be a box for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
683
diff
changeset
|
5579 /* Set the window level to be floating */ |
014b02436c1f
Added MDI simulation code... the MDI "window" will just be a box for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
683
diff
changeset
|
5580 [window setLevel:NSFloatingWindowLevel]; |
014b02436c1f
Added MDI simulation code... the MDI "window" will just be a box for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
683
diff
changeset
|
5581 [window setHidesOnDeactivate:YES]; |
014b02436c1f
Added MDI simulation code... the MDI "window" will just be a box for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
683
diff
changeset
|
5582 } |
014b02436c1f
Added MDI simulation code... the MDI "window" will just be a box for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
683
diff
changeset
|
5583 } |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
5584 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5585 return (HWND)window; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5586 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5587 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5588 /* |
651
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5589 * Call a function from the window (widget)'s context. |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5590 * Parameters: |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5591 * handle: Window handle of the widget. |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5592 * function: Function pointer to be called. |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5593 * data: Pointer to the data to be passed to the function. |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5594 */ |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5595 void API dw_window_function(HWND handle, void *function, void *data) |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5596 { |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5597 void (* windowfunc)(void *); |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5598 |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5599 windowfunc = function; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5600 |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5601 if(windowfunc) |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5602 windowfunc(data); |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5603 } |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5604 |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5605 |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5606 /* |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5607 * Changes the appearance of the mouse pointer. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5608 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5609 * handle: Handle to widget for which to change. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5610 * cursortype: ID of the pointer you want. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5611 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5612 void API dw_window_set_pointer(HWND handle, int pointertype) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5613 { |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
5614 id object = handle; |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
5615 |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
5616 if([ object isKindOfClass:[ NSView class ] ]) |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
5617 { |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
5618 NSView *view = handle; |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
5619 |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
5620 if(pointertype == DW_POINTER_DEFAULT) |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
5621 { |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
5622 [view discardCursorRects]; |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
5623 } |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
5624 else if(pointertype == DW_POINTER_ARROW) |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
5625 { |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
5626 NSRect rect = [view frame]; |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
5627 NSCursor *cursor = [NSCursor arrowCursor]; |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
5628 |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
5629 [view addCursorRect:rect cursor:cursor]; |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
5630 } |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
5631 /* No cursor for DW_POINTER_CLOCK? */ |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
5632 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5633 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5634 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5635 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5636 * Makes the window visible. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5637 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5638 * handle: The window handle to make visible. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5639 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5640 int API dw_window_show(HWND handle) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5641 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5642 NSObject *object = handle; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5643 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5644 if([ object isKindOfClass:[ NSWindow class ] ]) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5645 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5646 NSWindow *window = handle; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5647 if([window isMiniaturized]) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5648 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5649 [window deminiaturize:nil]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5650 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5651 [[window contentView] windowResized:nil]; |
668
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
5652 [[window contentView] windowDidBecomeMain:nil]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5653 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5654 return 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5655 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5656 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5657 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5658 * Makes the window invisible. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5659 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5660 * handle: The window handle to make visible. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5661 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5662 int API dw_window_hide(HWND handle) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5663 { |
686
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5664 /* TODO: Figure out proper dw_window_hide behavior... |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5665 * individual windows don't appear to be hidable, |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5666 * but all application windows can be hidden/deactivated |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5667 * via the NS/DWApplication class. |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5668 */ |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5669 return 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5670 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5671 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5672 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5673 * Sets the colors used by a specified window (widget) handle. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5674 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5675 * handle: The window (widget) handle. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5676 * fore: Foreground color in DW_RGB format or a default color index. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5677 * back: Background color in DW_RGB format or a default color index. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5678 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5679 int API dw_window_set_color(HWND handle, ULONG fore, ULONG back) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5680 { |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
5681 id object = handle; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
5682 unsigned long _fore = _get_color(fore); |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
5683 unsigned long _back = _get_color(back); |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
5684 |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
5685 if([object isMemberOfClass:[NSTextFieldCell class]]) |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
5686 { |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
5687 NSTextFieldCell *text = object; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
5688 [text setTextColor:[NSColor colorWithDeviceRed: DW_RED_VALUE(_fore)/255.0 green: DW_GREEN_VALUE(_fore)/255.0 blue: DW_BLUE_VALUE(_fore)/255.0 alpha: 1]]; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
5689 } |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
5690 else if([object isMemberOfClass:[DWBox class]]) |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
5691 { |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
5692 DWBox *box = object; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
5693 |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
5694 [box setColor:_back]; |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
5695 } |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
5696 return 0; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5697 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5698 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5699 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5700 * Sets the font used by a specified window (widget) handle. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5701 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5702 * handle: The window (widget) handle. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5703 * border: Size of the window border in pixels. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5704 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5705 int API dw_window_set_border(HWND handle, int border) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5706 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5707 return 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5708 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5709 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5710 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5711 * Sets the style of a given window (widget). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5712 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5713 * handle: Window (widget) handle. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5714 * width: New width in pixels. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5715 * height: New height in pixels. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5716 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5717 void API dw_window_set_style(HWND handle, ULONG style, ULONG mask) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5718 { |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
5719 id object = handle; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
5720 |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
5721 if([object isMemberOfClass:[NSWindow class]]) |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
5722 { |
719
d5e49ef8f541
Updated the #if for Snow Leopard/Leopard builds to handle them not being defined properly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
718
diff
changeset
|
5723 #ifdef BUILDING_FOR_SNOW_LEOPARD |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
5724 NSWindow *window = object; |
665
e6bec2290f3f
Fixing warnings with Xcode 4 and switched to manual releasing in the draw functions to stop leaking.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
664
diff
changeset
|
5725 int currentstyle = (int)[window styleMask]; |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
5726 int tmp; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
5727 |
665
e6bec2290f3f
Fixing warnings with Xcode 4 and switched to manual releasing in the draw functions to stop leaking.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
664
diff
changeset
|
5728 tmp = currentstyle | (int)mask; |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
5729 tmp ^= mask; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
5730 tmp |= style; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
5731 |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
5732 [window setStyleMask:tmp]; |
718
002f33d4439d
More 10.5 fixes... some selectors cause exceptions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
717
diff
changeset
|
5733 #endif |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
5734 } |
675
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
5735 else if([object isMemberOfClass:[NSTextView class]]) |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
5736 { |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
5737 NSTextView *tv = handle; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
5738 [tv setAlignment:(style & mask)]; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
5739 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5740 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5741 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5742 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5743 * Sets the default focus item for a window/dialog. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5744 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5745 * window: Toplevel window or dialog. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5746 * defaultitem: Handle to the dialog item to be default. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5747 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5748 void API dw_window_default(HWND window, HWND defaultitem) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5749 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5750 NSLog(@"dw_window_default() unimplemented\n"); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5751 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5752 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5753 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5754 * Sets window to click the default dialog item when an ENTER is pressed. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5755 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5756 * window: Window (widget) to look for the ENTER press. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5757 * next: Window (widget) to move to next (or click) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5758 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5759 void API dw_window_click_default(HWND window, HWND next) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5760 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5761 NSLog(@"dw_window_click_default() unimplemented\n"); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5762 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5763 |
686
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5764 static id _DWCapture; |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5765 |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5766 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5767 * Captures the mouse input to this window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5768 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5769 * handle: Handle to receive mouse input. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5770 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5771 void API dw_window_capture(HWND handle) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5772 { |
686
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5773 id object = handle; |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5774 |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5775 if(![object isMemberOfClass:[NSWindow class]]) |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5776 { |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5777 object = [object window]; |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5778 } |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5779 if(object) |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5780 { |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5781 [object setAcceptsMouseMovedEvents:YES]; |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5782 _DWCapture = object; |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5783 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5784 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5785 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5786 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5787 * Releases previous mouse capture. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5788 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5789 void API dw_window_release(void) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5790 { |
686
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5791 if(_DWCapture) |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5792 { |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5793 [_DWCapture setAcceptsMouseMovedEvents:NO]; |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5794 _DWCapture = nil; |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5795 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5796 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5797 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5798 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5799 * Tracks this window movement. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5800 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5801 * handle: Handle to frame to be tracked. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5802 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5803 void API dw_window_track(HWND handle) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5804 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5805 NSLog(@"dw_window_track() unimplemented\n"); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5806 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5807 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5808 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5809 * Changes a window's parent to newparent. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5810 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5811 * handle: The window handle to destroy. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5812 * newparent: The window's new parent window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5813 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5814 void API dw_window_reparent(HWND handle, HWND newparent) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5815 { |
686
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5816 id object = handle; |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5817 |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5818 if([object isMemberOfClass:[NSWindow class]]) |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5819 { |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5820 /* We can't actually reparent on MacOS but if the |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5821 * new parent is an MDI window, change to be a |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5822 * floating window... otherwise set it to normal. |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5823 */ |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5824 NSWindow *window = handle; |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5825 |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5826 /* If it isn't a toplevel window... */ |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5827 if(newparent) |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5828 { |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5829 object = newparent; |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5830 |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5831 /* Check to see if the parent is an MDI window */ |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5832 if([object isMemberOfClass:[DWMDI class]]) |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5833 { |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5834 /* Set the window level to be floating */ |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5835 [window setLevel:NSFloatingWindowLevel]; |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5836 [window setHidesOnDeactivate:YES]; |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5837 return; |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5838 } |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5839 } |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5840 /* Set the window back to a normal window */ |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5841 [window setLevel:NSNormalWindowLevel]; |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5842 [window setHidesOnDeactivate:NO]; |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5843 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5844 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5845 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5846 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5847 * Sets the font used by a specified window (widget) handle. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5848 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5849 * handle: The window (widget) handle. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5850 * fontname: Name and size of the font in the form "size.fontname" |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5851 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5852 int API dw_window_set_font(HWND handle, char *fontname) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5853 { |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
5854 char *fontcopy = strdup(fontname); |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
5855 char *name = strchr(fontcopy, '.'); |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
5856 if(name) |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
5857 { |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
5858 int size = atoi(fontcopy); |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
5859 *name = 0; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
5860 name++; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
5861 NSFont *font = [NSFont fontWithName:[ NSString stringWithUTF8String:name ] size:(float)size]; |
673
6d0f0dc7ff7c
Some minor font fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
672
diff
changeset
|
5862 if(font) |
6d0f0dc7ff7c
Some minor font fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
672
diff
changeset
|
5863 { |
6d0f0dc7ff7c
Some minor font fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
672
diff
changeset
|
5864 id object = handle; |
6d0f0dc7ff7c
Some minor font fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
672
diff
changeset
|
5865 if([object window]) |
6d0f0dc7ff7c
Some minor font fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
672
diff
changeset
|
5866 { |
6d0f0dc7ff7c
Some minor font fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
672
diff
changeset
|
5867 [object lockFocus]; |
6d0f0dc7ff7c
Some minor font fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
672
diff
changeset
|
5868 [font set]; |
6d0f0dc7ff7c
Some minor font fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
672
diff
changeset
|
5869 [object unlockFocus]; |
6d0f0dc7ff7c
Some minor font fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
672
diff
changeset
|
5870 } |
674
78f9aa6d6d89
Fixes or fonts and loading images from files. Added Mac specific settings to dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
673
diff
changeset
|
5871 if([object isMemberOfClass:[NSControl class]]) |
78f9aa6d6d89
Fixes or fonts and loading images from files. Added Mac specific settings to dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
673
diff
changeset
|
5872 { |
78f9aa6d6d89
Fixes or fonts and loading images from files. Added Mac specific settings to dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
673
diff
changeset
|
5873 [object setFont:font]; |
78f9aa6d6d89
Fixes or fonts and loading images from files. Added Mac specific settings to dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
673
diff
changeset
|
5874 } |
673
6d0f0dc7ff7c
Some minor font fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
672
diff
changeset
|
5875 } |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
5876 } |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
5877 free(fontcopy); |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5878 return 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5879 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5880 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5881 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5882 * Destroys a window and all of it's children. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5883 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5884 * handle: The window handle to destroy. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5885 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5886 int API dw_window_destroy(HWND handle) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5887 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
5888 int _locked_by_me = FALSE; |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
5889 DW_MUTEX_LOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5890 NSObject *object = handle; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5891 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5892 if([ object isKindOfClass:[ NSWindow class ] ]) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5893 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5894 NSWindow *window = handle; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5895 [window close]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5896 } |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
5897 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5898 return 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5899 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5900 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5901 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5902 * Gets the text used for a given window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5903 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5904 * handle: Handle to the window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5905 * Returns: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5906 * text: The text associsated with a given window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5907 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5908 char * API dw_window_get_text(HWND handle) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5909 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5910 NSObject *object = handle; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5911 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5912 if([ object isKindOfClass:[ NSControl class ] ]) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5913 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5914 NSControl *control = handle; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5915 NSString *nsstr = [ control stringValue]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5916 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5917 return strdup([ nsstr UTF8String ]); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5918 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5919 else if([ object isKindOfClass:[ NSWindow class ] ]) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5920 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5921 NSWindow *window = handle; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5922 NSString *nsstr = [ window title]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5923 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5924 return strdup([ nsstr UTF8String ]); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5925 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5926 return NULL; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5927 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5928 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5929 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5930 * Sets the text used for a given window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5931 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5932 * handle: Handle to the window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5933 * text: The text associsated with a given window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5934 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5935 void API dw_window_set_text(HWND handle, char *text) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5936 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
5937 int _locked_by_me = FALSE; |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
5938 DW_MUTEX_LOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5939 NSObject *object = handle; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5940 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5941 if([ object isKindOfClass:[ NSControl class ] ]) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5942 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5943 NSControl *control = handle; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5944 [control setStringValue:[ NSString stringWithUTF8String:text ]]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5945 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5946 else if([ object isKindOfClass:[ NSWindow class ] ]) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5947 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5948 NSWindow *window = handle; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5949 [window setTitle:[ NSString stringWithUTF8String:text ]]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5950 } |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
5951 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5952 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5953 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5954 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5955 * Disables given window (widget). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5956 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5957 * handle: Handle to the window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5958 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5959 void API dw_window_disable(HWND handle) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5960 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5961 NSObject *object = handle; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5962 if([ object isKindOfClass:[ NSControl class ] ]) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5963 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5964 NSControl *control = handle; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5965 [control setEnabled:NO]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5966 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5967 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5968 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5969 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5970 * Enables given window (widget). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5971 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5972 * handle: Handle to the window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5973 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5974 void API dw_window_enable(HWND handle) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5975 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5976 NSObject *object = handle; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5977 if([ object isKindOfClass:[ NSControl class ] ]) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5978 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5979 NSControl *control = handle; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5980 [control setEnabled:YES]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5981 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5982 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5983 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5984 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5985 * Sets the bitmap used for a given static window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5986 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5987 * handle: Handle to the window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5988 * id: An ID to be used to specify the icon, |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5989 * (pass 0 if you use the filename param) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5990 * filename: a path to a file (Bitmap on OS/2 or |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5991 * Windows and a pixmap on Unix, pass |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5992 * NULL if you use the id param) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5993 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
5994 void API dw_window_set_bitmap_from_data(HWND handle, unsigned long cid, char *data, int len) |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5995 { |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
5996 NSObject *object = handle; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
5997 if([ object isKindOfClass:[ NSImageView class ] ]) |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
5998 { |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
5999 NSImageView *iv = handle; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
6000 NSData *thisdata = [[NSData alloc] dataWithBytes:data length:len]; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
6001 NSImage *pixmap = [[NSImage alloc] initWithData:thisdata]; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
6002 |
675
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
6003 if(pixmap) |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
6004 { |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
6005 [iv setImage:pixmap]; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
6006 } |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
6007 [pixmap release]; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
6008 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6009 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6010 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6011 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6012 * Sets the bitmap used for a given static window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6013 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6014 * handle: Handle to the window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6015 * id: An ID to be used to specify the icon, |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6016 * (pass 0 if you use the filename param) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6017 * filename: a path to a file (Bitmap on OS/2 or |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6018 * Windows and a pixmap on Unix, pass |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6019 * NULL if you use the id param) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6020 */ |
675
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
6021 void API dw_window_set_bitmap(HWND handle, unsigned long resid, char *filename) |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6022 { |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
6023 NSObject *object = handle; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
6024 if([ object isKindOfClass:[ NSImageView class ] ]) |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
6025 { |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
6026 NSImageView *iv = handle; |
675
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
6027 NSImage *bitmap = NULL; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
6028 |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
6029 if(filename) |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
6030 { |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
6031 bitmap = [[NSImage alloc] initWithContentsOfFile:[ NSString stringWithUTF8String:filename ]]; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
6032 } |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
6033 else if(resid > 0 && resid < 65536) |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
6034 { |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
6035 bitmap = dw_icon_load(0, resid); |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
6036 } |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
6037 |
675
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
6038 if(bitmap) |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
6039 { |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
6040 [iv setImage:bitmap]; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
6041 } |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
6042 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6043 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6044 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6045 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6046 * Sets the icon used for a given window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6047 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6048 * handle: Handle to the window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6049 * id: An ID to be used to specify the icon. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6050 */ |
672
388f2a48aaae
Missed one function to typedef. Fixed errors in the test program and switched to using
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
671
diff
changeset
|
6051 void API dw_window_set_icon(HWND handle, HICN icon) |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6052 { |
661
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
6053 /* This isn't needed, it is loaded from the bundle */ |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6054 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6055 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6056 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6057 * Gets the child window handle with specified ID. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6058 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6059 * handle: Handle to the parent window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6060 * id: Integer ID of the child. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6061 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
6062 HWND API dw_window_from_id(HWND handle, int cid) |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6063 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6064 NSObject *object = handle; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6065 NSView *view = handle; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6066 if([ object isKindOfClass:[ NSWindow class ] ]) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6067 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6068 NSWindow *window = handle; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6069 view = [window contentView]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6070 } |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
6071 return [view viewWithTag:cid]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6072 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6073 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6074 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6075 * Minimizes or Iconifies a top-level window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6076 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6077 * handle: The window handle to minimize. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6078 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6079 int API dw_window_minimize(HWND handle) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6080 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6081 NSWindow *window = handle; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6082 [window miniaturize:nil]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6083 return 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6084 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6085 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6086 /* Causes entire window to be invalidated and redrawn. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6087 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6088 * handle: Toplevel window handle to be redrawn. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6089 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6090 void API dw_window_redraw(HWND handle) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6091 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6092 NSWindow *window = handle; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6093 [window flushWindow]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6094 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6095 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6096 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6097 * Makes the window topmost. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6098 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6099 * handle: The window handle to make topmost. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6100 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6101 int API dw_window_raise(HWND handle) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6102 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6103 NSWindow *window = handle; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6104 [window orderFront:nil]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6105 return 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6106 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6107 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6108 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6109 * Makes the window bottommost. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6110 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6111 * handle: The window handle to make bottommost. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6112 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6113 int API dw_window_lower(HWND handle) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6114 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6115 NSWindow *window = handle; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6116 [window orderBack:nil]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6117 return 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6118 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6119 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6120 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6121 * Sets the size of a given window (widget). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6122 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6123 * handle: Window (widget) handle. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6124 * width: New width in pixels. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6125 * height: New height in pixels. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6126 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6127 void API dw_window_set_size(HWND handle, ULONG width, ULONG height) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6128 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
6129 int _locked_by_me = FALSE; |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
6130 DW_MUTEX_LOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6131 NSObject *object = handle; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6132 NSSize size; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6133 size.width = width; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6134 size.height = height; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6135 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6136 if([ object isKindOfClass:[ NSWindow class ] ]) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6137 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6138 NSWindow *window = handle; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6139 [window setContentSize:size]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6140 } |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
6141 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6142 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6143 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6144 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6145 * Sets the position of a given window (widget). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6146 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6147 * handle: Window (widget) handle. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6148 * x: X location from the bottom left. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6149 * y: Y location from the bottom left. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6150 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6151 void API dw_window_set_pos(HWND handle, LONG x, LONG y) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6152 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
6153 int _locked_by_me = FALSE; |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
6154 DW_MUTEX_LOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6155 NSObject *object = handle; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6156 NSPoint point; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6157 point.x = x; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6158 point.y = y; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6159 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6160 if([ object isKindOfClass:[ NSWindow class ] ]) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6161 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6162 NSWindow *window = handle; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6163 [window setFrameOrigin:point]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6164 } |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
6165 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6166 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6167 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6168 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6169 * Sets the position and size of a given window (widget). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6170 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6171 * handle: Window (widget) handle. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6172 * x: X location from the bottom left. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6173 * y: Y location from the bottom left. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6174 * width: Width of the widget. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6175 * height: Height of the widget. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6176 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6177 void API dw_window_set_pos_size(HWND handle, LONG x, LONG y, ULONG width, ULONG height) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6178 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6179 dw_window_set_pos(handle, x, y); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6180 dw_window_set_size(handle, width, height); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6181 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6182 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6183 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6184 * Gets the position and size of a given window (widget). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6185 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6186 * handle: Window (widget) handle. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6187 * x: X location from the bottom left. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6188 * y: Y location from the bottom left. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6189 * width: Width of the widget. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6190 * height: Height of the widget. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6191 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6192 void API dw_window_get_pos_size(HWND handle, LONG *x, LONG *y, ULONG *width, ULONG *height) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6193 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6194 NSObject *object = handle; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6195 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6196 if([ object isKindOfClass:[ NSWindow class ] ]) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6197 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6198 NSWindow *window = handle; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6199 NSRect rect = [window frame]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6200 if(x) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6201 *x = rect.origin.x; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6202 if(y) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6203 *y = rect.origin.y; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6204 if(width) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6205 *width = rect.size.width; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6206 if(height) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6207 *height = rect.size.height; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6208 return; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6209 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6210 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6211 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6212 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6213 * Returns the width of the screen. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6214 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6215 int API dw_screen_width(void) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6216 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6217 NSRect screenRect = [[NSScreen mainScreen] frame]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6218 return screenRect.size.width; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6219 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6220 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6221 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6222 * Returns the height of the screen. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6223 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6224 int API dw_screen_height(void) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6225 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6226 NSRect screenRect = [[NSScreen mainScreen] frame]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6227 return screenRect.size.height; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6228 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6229 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6230 /* This should return the current color depth */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6231 unsigned long API dw_color_depth_get(void) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6232 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6233 NSWindowDepth screenDepth = [[NSScreen mainScreen] depth]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6234 return NSBitsPerPixelFromDepth(screenDepth); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6235 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6236 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6237 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6238 * Returns some information about the current operating environment. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6239 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6240 * env: Pointer to a DWEnv struct. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6241 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6242 void dw_environment_query(DWEnv *env) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6243 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6244 struct utsname name; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6245 char tempbuf[100]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6246 int len, z; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6247 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6248 uname(&name); |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
6249 strcpy(env->osName, "MacOS"); |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6250 strcpy(tempbuf, name.release); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6251 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6252 env->MajorBuild = env->MinorBuild = 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6253 |
665
e6bec2290f3f
Fixing warnings with Xcode 4 and switched to manual releasing in the draw functions to stop leaking.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
664
diff
changeset
|
6254 len = (int)strlen(tempbuf); |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6255 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6256 strcpy(env->buildDate, __DATE__); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6257 strcpy(env->buildTime, __TIME__); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6258 env->DWMajorVersion = DW_MAJOR_VERSION; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6259 env->DWMinorVersion = DW_MINOR_VERSION; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6260 env->DWSubVersion = DW_SUB_VERSION; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6261 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6262 for(z=1;z<len;z++) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6263 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6264 if(tempbuf[z] == '.') |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6265 { |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
6266 int ver = atoi(tempbuf); |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6267 tempbuf[z] = '\0'; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
6268 if(ver > 4) |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
6269 { |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
6270 env->MajorVersion = 10; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
6271 env->MinorVersion = ver - 4; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
6272 env->MajorBuild = atoi(&tempbuf[z+1]); |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
6273 } |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
6274 else |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
6275 { |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
6276 env->MajorVersion = ver; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
6277 env->MinorVersion = atoi(&tempbuf[z+1]); |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
6278 } |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
6279 |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6280 return; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6281 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6282 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6283 env->MajorVersion = atoi(tempbuf); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6284 env->MinorVersion = 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6285 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6286 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6287 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6288 * Emits a beep. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6289 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6290 * freq: Frequency. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6291 * dur: Duration. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6292 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6293 void API dw_beep(int freq, int dur) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6294 { |
651
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6295 NSBeep(); |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6296 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6297 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6298 /* Call this after drawing to the screen to make sure |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6299 * anything you have drawn is visible. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6300 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6301 void API dw_flush(void) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6302 { |
671
c60a4f6cfae8
Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
670
diff
changeset
|
6303 /* This may need to be thread specific */ |
699
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
6304 [DWObj performSelectorOnMainThread:@selector(doFlush:) withObject:nil waitUntilDone:NO]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6305 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6306 |
651
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6307 /* Functions for managing the user data lists that are associated with |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6308 * a given window handle. Used in dw_window_set_data() and |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6309 * dw_window_get_data(). |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6310 */ |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6311 UserData *_find_userdata(UserData **root, char *varname) |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6312 { |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6313 UserData *tmp = *root; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6314 |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6315 while(tmp) |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6316 { |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6317 if(strcasecmp(tmp->varname, varname) == 0) |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6318 return tmp; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6319 tmp = tmp->next; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6320 } |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6321 return NULL; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6322 } |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6323 |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6324 int _new_userdata(UserData **root, char *varname, void *data) |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6325 { |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6326 UserData *new = _find_userdata(root, varname); |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6327 |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6328 if(new) |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6329 { |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6330 new->data = data; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6331 return TRUE; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6332 } |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6333 else |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6334 { |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6335 new = malloc(sizeof(UserData)); |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6336 if(new) |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6337 { |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6338 new->varname = strdup(varname); |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6339 new->data = data; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6340 |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6341 new->next = NULL; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6342 |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6343 if (!*root) |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6344 *root = new; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6345 else |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6346 { |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6347 UserData *prev = NULL, *tmp = *root; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6348 while(tmp) |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6349 { |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6350 prev = tmp; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6351 tmp = tmp->next; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6352 } |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6353 if(prev) |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6354 prev->next = new; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6355 else |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6356 *root = new; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6357 } |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6358 return TRUE; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6359 } |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6360 } |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6361 return FALSE; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6362 } |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6363 |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6364 int _remove_userdata(UserData **root, char *varname, int all) |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6365 { |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6366 UserData *prev = NULL, *tmp = *root; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6367 |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6368 while(tmp) |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6369 { |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6370 if(all || strcasecmp(tmp->varname, varname) == 0) |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6371 { |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6372 if(!prev) |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6373 { |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6374 *root = tmp->next; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6375 free(tmp->varname); |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6376 free(tmp); |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6377 if(!all) |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6378 return 0; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6379 tmp = *root; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6380 } |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6381 else |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6382 { |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6383 /* If all is true we should |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6384 * never get here. |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6385 */ |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6386 prev->next = tmp->next; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6387 free(tmp->varname); |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6388 free(tmp); |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6389 return 0; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6390 } |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6391 } |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6392 else |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6393 { |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6394 prev = tmp; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6395 tmp = tmp->next; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6396 } |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6397 } |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6398 return 0; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6399 } |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6400 |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6401 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6402 * Add a named user data item to a window handle. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6403 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6404 * window: Window handle of signal to be called back. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6405 * dataname: A string pointer identifying which signal to be hooked. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6406 * data: User data to be passed to the handler function. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6407 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6408 void dw_window_set_data(HWND window, char *dataname, void *data) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6409 { |
651
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6410 id object = window; |
681
5fe12469c1fb
Fix for dw_window_set/get_data() on a top-level window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
680
diff
changeset
|
6411 if([object isMemberOfClass:[NSWindow class]]) |
5fe12469c1fb
Fix for dw_window_set/get_data() on a top-level window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
680
diff
changeset
|
6412 { |
5fe12469c1fb
Fix for dw_window_set/get_data() on a top-level window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
680
diff
changeset
|
6413 NSWindow *win = window; |
5fe12469c1fb
Fix for dw_window_set/get_data() on a top-level window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
680
diff
changeset
|
6414 object = [win contentView]; |
5fe12469c1fb
Fix for dw_window_set/get_data() on a top-level window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
680
diff
changeset
|
6415 } |
5fe12469c1fb
Fix for dw_window_set/get_data() on a top-level window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
680
diff
changeset
|
6416 else if([object isMemberOfClass:[NSScrollView class]]) |
676
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
6417 { |
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
6418 NSScrollView *sv = window; |
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
6419 object = [sv documentView]; |
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
6420 } |
651
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6421 WindowData *blah = (WindowData *)[object userdata]; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6422 |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6423 if(!blah) |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6424 { |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6425 if(!dataname) |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6426 return; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6427 |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6428 blah = calloc(1, sizeof(WindowData)); |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6429 [object setUserdata:blah]; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6430 } |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6431 |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6432 if(data) |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6433 _new_userdata(&(blah->root), dataname, data); |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6434 else |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6435 { |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6436 if(dataname) |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6437 _remove_userdata(&(blah->root), dataname, FALSE); |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6438 else |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6439 _remove_userdata(&(blah->root), NULL, TRUE); |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6440 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6441 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6442 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6443 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6444 * Gets a named user data item to a window handle. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6445 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6446 * window: Window handle of signal to be called back. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6447 * dataname: A string pointer identifying which signal to be hooked. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6448 * data: User data to be passed to the handler function. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6449 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6450 void *dw_window_get_data(HWND window, char *dataname) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6451 { |
651
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6452 id object = window; |
681
5fe12469c1fb
Fix for dw_window_set/get_data() on a top-level window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
680
diff
changeset
|
6453 if([object isMemberOfClass:[NSWindow class]]) |
5fe12469c1fb
Fix for dw_window_set/get_data() on a top-level window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
680
diff
changeset
|
6454 { |
5fe12469c1fb
Fix for dw_window_set/get_data() on a top-level window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
680
diff
changeset
|
6455 NSWindow *win = window; |
5fe12469c1fb
Fix for dw_window_set/get_data() on a top-level window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
680
diff
changeset
|
6456 object = [win contentView]; |
5fe12469c1fb
Fix for dw_window_set/get_data() on a top-level window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
680
diff
changeset
|
6457 } |
5fe12469c1fb
Fix for dw_window_set/get_data() on a top-level window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
680
diff
changeset
|
6458 else if([object isMemberOfClass:[NSScrollView class]]) |
676
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
6459 { |
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
6460 NSScrollView *sv = window; |
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
6461 object = [sv documentView]; |
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
6462 } |
651
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6463 WindowData *blah = (WindowData *)[object userdata]; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6464 |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6465 if(blah && blah->root && dataname) |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6466 { |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6467 UserData *ud = _find_userdata(&(blah->root), dataname); |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6468 if(ud) |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6469 return ud->data; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6470 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6471 return NULL; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6472 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6473 |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
6474 #define DW_TIMER_MAX 64 |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
6475 NSTimer *DWTimers[DW_TIMER_MAX]; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
6476 |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6477 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6478 * Add a callback to a timer event. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6479 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6480 * interval: Milliseconds to delay between calls. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6481 * sigfunc: The pointer to the function to be used as the callback. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6482 * data: User data to be passed to the handler function. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6483 * Returns: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6484 * Timer ID for use with dw_timer_disconnect(), 0 on error. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6485 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6486 int API dw_timer_connect(int interval, void *sigfunc, void *data) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6487 { |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
6488 int z; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
6489 |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
6490 for(z=0;z<DW_TIMER_MAX;z++) |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6491 { |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
6492 if(!DWTimers[z]) |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6493 { |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
6494 break; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6495 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6496 } |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
6497 |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
6498 if(sigfunc && !DWTimers[z]) |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
6499 { |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
6500 NSTimeInterval seconds = (double)interval / 1000.0; |
688
b52f1d4a60dd
Fixes for timers not working properly. Includes commented out test container code for threadsafety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
687
diff
changeset
|
6501 NSTimer *thistimer = DWTimers[z] = [NSTimer scheduledTimerWithTimeInterval:seconds target:DWHandler selector:@selector(runTimer:) userInfo:nil repeats:YES]; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
6502 _new_signal(0, thistimer, z+1, sigfunc, data); |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
6503 return z+1; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
6504 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6505 return 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6506 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6507 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6508 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6509 * Removes timer callback. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6510 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6511 * id: Timer ID returned by dw_timer_connect(). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6512 */ |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
6513 void API dw_timer_disconnect(int timerid) |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6514 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6515 SignalHandler *prev = NULL, *tmp = Root; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
6516 NSTimer *thistimer; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6517 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6518 /* 0 is an invalid timer ID */ |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
6519 if(timerid < 1 || !DWTimers[timerid-1]) |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6520 return; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6521 |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
6522 thistimer = DWTimers[timerid-1]; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
6523 DWTimers[timerid-1] = nil; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
6524 |
688
b52f1d4a60dd
Fixes for timers not working properly. Includes commented out test container code for threadsafety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
687
diff
changeset
|
6525 [thistimer invalidate]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6526 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6527 while(tmp) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6528 { |
688
b52f1d4a60dd
Fixes for timers not working properly. Includes commented out test container code for threadsafety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
687
diff
changeset
|
6529 if(tmp->id == timerid && tmp->window == thistimer) |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6530 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6531 if(prev) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6532 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6533 prev->next = tmp->next; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6534 free(tmp); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6535 tmp = prev->next; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6536 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6537 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6538 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6539 Root = tmp->next; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6540 free(tmp); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6541 tmp = Root; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6542 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6543 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6544 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6545 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6546 prev = tmp; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6547 tmp = tmp->next; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6548 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6549 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6550 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6551 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6552 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6553 * Add a callback to a window event. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6554 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6555 * window: Window handle of signal to be called back. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6556 * signame: A string pointer identifying which signal to be hooked. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6557 * sigfunc: The pointer to the function to be used as the callback. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6558 * data: User data to be passed to the handler function. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6559 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6560 void API dw_signal_connect(HWND window, char *signame, void *sigfunc, void *data) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6561 { |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
6562 ULONG message = 0, msgid = 0; |
723
37c8d2b4cec5
Initial key press event/signal handling... does not seem to trap on all controls...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
722
diff
changeset
|
6563 |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6564 if(window && signame && sigfunc) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6565 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6566 if((message = _findsigmessage(signame)) != 0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6567 { |
665
e6bec2290f3f
Fixing warnings with Xcode 4 and switched to manual releasing in the draw functions to stop leaking.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
664
diff
changeset
|
6568 _new_signal(message, window, (int)msgid, sigfunc, data); |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6569 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6570 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6571 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6572 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6573 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6574 * Removes callbacks for a given window with given name. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6575 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6576 * window: Window handle of callback to be removed. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6577 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6578 void API dw_signal_disconnect_by_name(HWND window, char *signame) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6579 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6580 SignalHandler *prev = NULL, *tmp = Root; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6581 ULONG message; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6582 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6583 if(!window || !signame || (message = _findsigmessage(signame)) == 0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6584 return; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6585 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6586 while(tmp) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6587 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6588 if(tmp->window == window && tmp->message == message) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6589 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6590 if(prev) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6591 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6592 prev->next = tmp->next; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6593 free(tmp); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6594 tmp = prev->next; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6595 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6596 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6597 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6598 Root = tmp->next; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6599 free(tmp); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6600 tmp = Root; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6601 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6602 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6603 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6604 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6605 prev = tmp; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6606 tmp = tmp->next; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6607 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6608 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6609 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6610 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6611 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6612 * Removes all callbacks for a given window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6613 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6614 * window: Window handle of callback to be removed. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6615 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6616 void API dw_signal_disconnect_by_window(HWND window) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6617 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6618 SignalHandler *prev = NULL, *tmp = Root; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6619 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6620 while(tmp) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6621 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6622 if(tmp->window == window) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6623 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6624 if(prev) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6625 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6626 prev->next = tmp->next; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6627 free(tmp); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6628 tmp = prev->next; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6629 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6630 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6631 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6632 Root = tmp->next; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6633 free(tmp); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6634 tmp = Root; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6635 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6636 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6637 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6638 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6639 prev = tmp; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6640 tmp = tmp->next; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6641 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6642 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6643 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6644 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6645 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6646 * Removes all callbacks for a given window with specified data. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6647 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6648 * window: Window handle of callback to be removed. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6649 * data: Pointer to the data to be compared against. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6650 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6651 void API dw_signal_disconnect_by_data(HWND window, void *data) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6652 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6653 SignalHandler *prev = NULL, *tmp = Root; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6654 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6655 while(tmp) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6656 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6657 if(tmp->window == window && tmp->data == data) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6658 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6659 if(prev) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6660 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6661 prev->next = tmp->next; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6662 free(tmp); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6663 tmp = prev->next; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6664 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6665 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6666 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6667 Root = tmp->next; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6668 free(tmp); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6669 tmp = Root; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6670 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6671 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6672 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6673 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6674 prev = tmp; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6675 tmp = tmp->next; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6676 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6677 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6678 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6679 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6680 void _my_strlwr(char *buf) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6681 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6682 int z, len = strlen(buf); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6683 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6684 for(z=0;z<len;z++) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6685 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6686 if(buf[z] >= 'A' && buf[z] <= 'Z') |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6687 buf[z] -= 'A' - 'a'; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6688 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6689 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6690 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6691 /* Open a shared library and return a handle. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6692 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6693 * name: Base name of the shared library. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6694 * handle: Pointer to a module handle, |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6695 * will be filled in with the handle. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6696 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6697 int dw_module_load(char *name, HMOD *handle) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6698 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6699 int len; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6700 char *newname; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6701 char errorbuf[1024]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6702 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6703 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6704 if(!handle) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6705 return -1; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6706 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6707 if((len = strlen(name)) == 0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6708 return -1; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6709 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6710 /* Lenth + "lib" + ".dylib" + NULL */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6711 newname = malloc(len + 10); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6712 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6713 if(!newname) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6714 return -1; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6715 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6716 sprintf(newname, "lib%s.dylib", name); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6717 _my_strlwr(newname); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6718 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6719 *handle = dlopen(newname, RTLD_NOW); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6720 if(*handle == NULL) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6721 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6722 strncpy(errorbuf, dlerror(), 1024); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6723 printf("%s\n", errorbuf); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6724 sprintf(newname, "lib%s.dylib", name); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6725 *handle = dlopen(newname, RTLD_NOW); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6726 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6727 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6728 free(newname); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6729 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6730 return (NULL == *handle) ? -1 : 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6731 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6732 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6733 /* Queries the address of a symbol within open handle. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6734 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6735 * handle: Module handle returned by dw_module_load() |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6736 * name: Name of the symbol you want the address of. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6737 * func: A pointer to a function pointer, to obtain |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6738 * the address. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6739 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6740 int dw_module_symbol(HMOD handle, char *name, void**func) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6741 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6742 if(!func || !name) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6743 return -1; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6744 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6745 if(strlen(name) == 0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6746 return -1; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6747 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6748 *func = (void*)dlsym(handle, name); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6749 return (NULL == *func); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6750 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6751 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6752 /* Frees the shared library previously opened. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6753 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6754 * handle: Module handle returned by dw_module_load() |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6755 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6756 int dw_module_close(HMOD handle) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6757 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6758 if(handle) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6759 return dlclose(handle); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6760 return 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6761 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6762 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6763 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6764 * Returns the handle to an unnamed mutex semaphore. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6765 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6766 HMTX dw_mutex_new(void) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6767 { |
725
4e09c92363df
Experimental changes to dw_main_sleep() and dw_main_iteration() to hopefully solve some issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
724
diff
changeset
|
6768 HMTX mutex = malloc(sizeof(pthread_mutex_t)); |
727
f190b5c2ce16
Fixed 2 errors in the tree select event handler. Also removed unused experimental code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
726
diff
changeset
|
6769 |
725
4e09c92363df
Experimental changes to dw_main_sleep() and dw_main_iteration() to hopefully solve some issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
724
diff
changeset
|
6770 pthread_mutex_init(mutex, NULL); |
4e09c92363df
Experimental changes to dw_main_sleep() and dw_main_iteration() to hopefully solve some issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
724
diff
changeset
|
6771 return mutex; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6772 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6773 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6774 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6775 * Closes a semaphore created by dw_mutex_new(). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6776 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6777 * mutex: The handle to the mutex returned by dw_mutex_new(). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6778 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6779 void dw_mutex_close(HMTX mutex) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6780 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6781 if(mutex) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6782 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6783 pthread_mutex_destroy(mutex); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6784 free(mutex); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6785 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6786 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6787 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6788 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6789 * Tries to gain access to the semaphore, if it can't it blocks. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6790 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6791 * mutex: The handle to the mutex returned by dw_mutex_new(). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6792 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6793 void dw_mutex_lock(HMTX mutex) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6794 { |
693
2f21ee9d7c7b
Experimental change for locking on the main thread... will be committing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
692
diff
changeset
|
6795 /* We need to handle locks from the main thread differently... |
2f21ee9d7c7b
Experimental change for locking on the main thread... will be committing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
692
diff
changeset
|
6796 * since we can't stop message processing... otherwise we |
2f21ee9d7c7b
Experimental change for locking on the main thread... will be committing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
692
diff
changeset
|
6797 * will deadlock... so try to acquire the lock and continue |
2f21ee9d7c7b
Experimental change for locking on the main thread... will be committing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
692
diff
changeset
|
6798 * processing messages in between tries. |
2f21ee9d7c7b
Experimental change for locking on the main thread... will be committing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
692
diff
changeset
|
6799 */ |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
6800 if(DWThread == pthread_self()) |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
6801 { |
693
2f21ee9d7c7b
Experimental change for locking on the main thread... will be committing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
692
diff
changeset
|
6802 while(pthread_mutex_trylock(mutex) != 0) |
2f21ee9d7c7b
Experimental change for locking on the main thread... will be committing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
692
diff
changeset
|
6803 { |
725
4e09c92363df
Experimental changes to dw_main_sleep() and dw_main_iteration() to hopefully solve some issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
724
diff
changeset
|
6804 /* Process any pending events */ |
4e09c92363df
Experimental changes to dw_main_sleep() and dw_main_iteration() to hopefully solve some issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
724
diff
changeset
|
6805 while(_dw_main_iteration([NSDate dateWithTimeIntervalSinceNow:0.01])) |
4e09c92363df
Experimental changes to dw_main_sleep() and dw_main_iteration() to hopefully solve some issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
724
diff
changeset
|
6806 { |
4e09c92363df
Experimental changes to dw_main_sleep() and dw_main_iteration() to hopefully solve some issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
724
diff
changeset
|
6807 /* Just loop */ |
4e09c92363df
Experimental changes to dw_main_sleep() and dw_main_iteration() to hopefully solve some issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
724
diff
changeset
|
6808 } |
693
2f21ee9d7c7b
Experimental change for locking on the main thread... will be committing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
692
diff
changeset
|
6809 } |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
6810 } |
693
2f21ee9d7c7b
Experimental change for locking on the main thread... will be committing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
692
diff
changeset
|
6811 else |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
6812 { |
693
2f21ee9d7c7b
Experimental change for locking on the main thread... will be committing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
692
diff
changeset
|
6813 pthread_mutex_lock(mutex); |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
6814 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6815 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6816 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6817 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6818 * Reliquishes the access to the semaphore. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6819 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6820 * mutex: The handle to the mutex returned by dw_mutex_new(). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6821 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6822 void dw_mutex_unlock(HMTX mutex) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6823 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6824 pthread_mutex_unlock(mutex); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6825 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6826 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6827 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6828 * Returns the handle to an unnamed event semaphore. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6829 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6830 HEV dw_event_new(void) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6831 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6832 HEV eve = (HEV)malloc(sizeof(struct _dw_unix_event)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6833 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6834 if(!eve) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6835 return NULL; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6836 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6837 /* We need to be careful here, mutexes on Linux are |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6838 * FAST by default but are error checking on other |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6839 * systems such as FreeBSD and OS/2, perhaps others. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6840 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6841 pthread_mutex_init (&(eve->mutex), NULL); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6842 pthread_mutex_lock (&(eve->mutex)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6843 pthread_cond_init (&(eve->event), NULL); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6844 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6845 pthread_mutex_unlock (&(eve->mutex)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6846 eve->alive = 1; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6847 eve->posted = 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6848 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6849 return eve; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6850 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6851 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6852 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6853 * Resets a semaphore created by dw_event_new(). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6854 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6855 * eve: The handle to the event returned by dw_event_new(). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6856 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6857 int dw_event_reset (HEV eve) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6858 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6859 if(!eve) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6860 return FALSE; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6861 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6862 pthread_mutex_lock (&(eve->mutex)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6863 pthread_cond_broadcast (&(eve->event)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6864 pthread_cond_init (&(eve->event), NULL); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6865 eve->posted = 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6866 pthread_mutex_unlock (&(eve->mutex)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6867 return 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6868 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6869 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6870 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6871 * Posts a semaphore created by dw_event_new(). Causing all threads |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6872 * waiting on this event in dw_event_wait to continue. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6873 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6874 * eve: The handle to the event returned by dw_event_new(). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6875 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6876 int dw_event_post (HEV eve) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6877 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6878 if(!eve) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6879 return FALSE; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6880 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6881 pthread_mutex_lock (&(eve->mutex)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6882 pthread_cond_broadcast (&(eve->event)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6883 eve->posted = 1; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6884 pthread_mutex_unlock (&(eve->mutex)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6885 return 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6886 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6887 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6888 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6889 * Waits on a semaphore created by dw_event_new(), until the |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6890 * event gets posted or until the timeout expires. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6891 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6892 * eve: The handle to the event returned by dw_event_new(). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6893 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6894 int dw_event_wait(HEV eve, unsigned long timeout) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6895 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6896 int rc; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6897 struct timeval now; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6898 struct timespec timeo; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6899 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6900 if(!eve) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6901 return FALSE; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6902 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6903 if(eve->posted) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6904 return 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6905 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6906 pthread_mutex_lock (&(eve->mutex)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6907 gettimeofday(&now, 0); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6908 timeo.tv_sec = now.tv_sec + (timeout / 1000); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6909 timeo.tv_nsec = now.tv_usec * 1000; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6910 rc = pthread_cond_timedwait (&(eve->event), &(eve->mutex), &timeo); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6911 pthread_mutex_unlock (&(eve->mutex)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6912 if(!rc) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6913 return 1; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6914 if(rc == ETIMEDOUT) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6915 return -1; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6916 return 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6917 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6918 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6919 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6920 * Closes a semaphore created by dw_event_new(). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6921 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6922 * eve: The handle to the event returned by dw_event_new(). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6923 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6924 int dw_event_close(HEV *eve) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6925 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6926 if(!eve || !(*eve)) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6927 return FALSE; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6928 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6929 pthread_mutex_lock (&((*eve)->mutex)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6930 pthread_cond_destroy (&((*eve)->event)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6931 pthread_mutex_unlock (&((*eve)->mutex)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6932 pthread_mutex_destroy (&((*eve)->mutex)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6933 free(*eve); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6934 *eve = NULL; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6935 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6936 return TRUE; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6937 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6938 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6939 struct _seminfo { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6940 int fd; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6941 int waiting; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6942 }; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6943 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6944 static void _handle_sem(int *tmpsock) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6945 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6946 fd_set rd; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6947 struct _seminfo *array = (struct _seminfo *)malloc(sizeof(struct _seminfo)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6948 int listenfd = tmpsock[0]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6949 int bytesread, connectcount = 1, maxfd, z, posted = 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6950 char command; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6951 sigset_t mask; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6952 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6953 sigfillset(&mask); /* Mask all allowed signals */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6954 pthread_sigmask(SIG_BLOCK, &mask, NULL); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6955 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6956 /* problems */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6957 if(tmpsock[1] == -1) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6958 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6959 free(array); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6960 return; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6961 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6962 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6963 array[0].fd = tmpsock[1]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6964 array[0].waiting = 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6965 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6966 /* Free the memory allocated in dw_named_event_new. */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6967 free(tmpsock); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6968 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6969 while(1) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6970 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6971 FD_ZERO(&rd); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6972 FD_SET(listenfd, &rd); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6973 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6974 maxfd = listenfd; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6975 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6976 /* Added any connections to the named event semaphore */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6977 for(z=0;z<connectcount;z++) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6978 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6979 if(array[z].fd > maxfd) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6980 maxfd = array[z].fd; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6981 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6982 FD_SET(array[z].fd, &rd); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6983 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6984 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6985 if(select(maxfd+1, &rd, NULL, NULL, NULL) == -1) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6986 return; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6987 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6988 if(FD_ISSET(listenfd, &rd)) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6989 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6990 struct _seminfo *newarray; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6991 int newfd = accept(listenfd, 0, 0); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6992 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6993 if(newfd > -1) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6994 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6995 /* Add new connections to the set */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6996 newarray = (struct _seminfo *)malloc(sizeof(struct _seminfo)*(connectcount+1)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6997 memcpy(newarray, array, sizeof(struct _seminfo)*(connectcount)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6998 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6999 newarray[connectcount].fd = newfd; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7000 newarray[connectcount].waiting = 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7001 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7002 connectcount++; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7003 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7004 /* Replace old array with new one */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7005 free(array); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7006 array = newarray; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7007 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7008 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7009 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7010 /* Handle any events posted to the semaphore */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7011 for(z=0;z<connectcount;z++) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7012 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7013 if(FD_ISSET(array[z].fd, &rd)) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7014 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7015 if((bytesread = read(array[z].fd, &command, 1)) < 1) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7016 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7017 struct _seminfo *newarray; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7018 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7019 /* Remove this connection from the set */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7020 newarray = (struct _seminfo *)malloc(sizeof(struct _seminfo)*(connectcount-1)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7021 if(!z) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7022 memcpy(newarray, &array[1], sizeof(struct _seminfo)*(connectcount-1)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7023 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7024 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7025 memcpy(newarray, array, sizeof(struct _seminfo)*z); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7026 if(z!=(connectcount-1)) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7027 memcpy(&newarray[z], &array[z+1], sizeof(struct _seminfo)*(z-connectcount-1)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7028 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7029 connectcount--; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7030 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7031 /* Replace old array with new one */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7032 free(array); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7033 array = newarray; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7034 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7035 else if(bytesread == 1) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7036 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7037 switch(command) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7038 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7039 case 0: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7040 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7041 /* Reset */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7042 posted = 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7043 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7044 break; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7045 case 1: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7046 /* Post */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7047 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7048 int s; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7049 char tmp = (char)0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7050 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7051 posted = 1; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7052 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7053 for(s=0;s<connectcount;s++) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7054 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7055 /* The semaphore has been posted so |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7056 * we tell all the waiting threads to |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7057 * continue. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7058 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7059 if(array[s].waiting) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7060 write(array[s].fd, &tmp, 1); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7061 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7062 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7063 break; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7064 case 2: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7065 /* Wait */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7066 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7067 char tmp = (char)0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7068 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7069 array[z].waiting = 1; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7070 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7071 /* If we are posted exit immeditately */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7072 if(posted) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7073 write(array[z].fd, &tmp, 1); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7074 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7075 break; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7076 case 3: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7077 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7078 /* Done Waiting */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7079 array[z].waiting = 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7080 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7081 break; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7082 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7083 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7084 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7085 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7086 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7087 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7088 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7089 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7090 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7091 /* Using domain sockets on unix for IPC */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7092 /* Create a named event semaphore which can be |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7093 * opened from other processes. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7094 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7095 * eve: Pointer to an event handle to receive handle. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7096 * name: Name given to semaphore which can be opened |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7097 * by other processes. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7098 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7099 HEV dw_named_event_new(char *name) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7100 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7101 struct sockaddr_un un; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7102 int ev, *tmpsock = (int *)malloc(sizeof(int)*2); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7103 HEV eve; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7104 DWTID dwthread; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7105 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7106 if(!tmpsock) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7107 return NULL; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7108 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7109 eve = (HEV)malloc(sizeof(struct _dw_unix_event)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7110 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7111 if(!eve) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7112 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7113 free(tmpsock); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7114 return NULL; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7115 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7116 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7117 tmpsock[0] = socket(AF_UNIX, SOCK_STREAM, 0); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7118 ev = socket(AF_UNIX, SOCK_STREAM, 0); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7119 memset(&un, 0, sizeof(un)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7120 un.sun_family=AF_UNIX; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7121 mkdir("/tmp/.dw", S_IWGRP|S_IWOTH); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7122 strcpy(un.sun_path, "/tmp/.dw/"); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7123 strcat(un.sun_path, name); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7124 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7125 /* just to be safe, this should be changed |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7126 * to support multiple instances. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7127 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7128 remove(un.sun_path); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7129 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7130 bind(tmpsock[0], (struct sockaddr *)&un, sizeof(un)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7131 listen(tmpsock[0], 0); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7132 connect(ev, (struct sockaddr *)&un, sizeof(un)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7133 tmpsock[1] = accept(tmpsock[0], 0, 0); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7134 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7135 if(tmpsock[0] < 0 || tmpsock[1] < 0 || ev < 0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7136 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7137 if(tmpsock[0] > -1) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7138 close(tmpsock[0]); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7139 if(tmpsock[1] > -1) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7140 close(tmpsock[1]); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7141 if(ev > -1) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7142 close(ev); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7143 free(tmpsock); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7144 free(eve); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7145 return NULL; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7146 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7147 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7148 /* Create a thread to handle this event semaphore */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7149 pthread_create(&dwthread, NULL, (void *)_handle_sem, (void *)tmpsock); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7150 eve->alive = ev; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7151 return eve; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7152 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7153 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7154 /* Open an already existing named event semaphore. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7155 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7156 * eve: Pointer to an event handle to receive handle. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7157 * name: Name given to semaphore which can be opened |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7158 * by other processes. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7159 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7160 HEV dw_named_event_get(char *name) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7161 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7162 struct sockaddr_un un; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7163 HEV eve; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7164 int ev = socket(AF_UNIX, SOCK_STREAM, 0); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7165 if(ev < 0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7166 return NULL; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7167 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7168 eve = (HEV)malloc(sizeof(struct _dw_unix_event)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7169 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7170 if(!eve) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7171 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7172 close(ev); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7173 return NULL; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7174 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7175 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7176 un.sun_family=AF_UNIX; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7177 mkdir("/tmp/.dw", S_IWGRP|S_IWOTH); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7178 strcpy(un.sun_path, "/tmp/.dw/"); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7179 strcat(un.sun_path, name); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7180 connect(ev, (struct sockaddr *)&un, sizeof(un)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7181 eve->alive = ev; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7182 return eve; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7183 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7184 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7185 /* Resets the event semaphore so threads who call wait |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7186 * on this semaphore will block. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7187 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7188 * eve: Handle to the semaphore obtained by |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7189 * an open or create call. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7190 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7191 int dw_named_event_reset(HEV eve) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7192 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7193 /* signal reset */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7194 char tmp = (char)0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7195 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7196 if(!eve || eve->alive < 0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7197 return 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7198 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7199 if(write(eve->alive, &tmp, 1) == 1) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7200 return 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7201 return 1; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7202 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7203 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7204 /* Sets the posted state of an event semaphore, any threads |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7205 * waiting on the semaphore will no longer block. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7206 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7207 * eve: Handle to the semaphore obtained by |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7208 * an open or create call. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7209 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7210 int dw_named_event_post(HEV eve) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7211 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7212 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7213 /* signal post */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7214 char tmp = (char)1; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7215 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7216 if(!eve || eve->alive < 0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7217 return 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7218 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7219 if(write(eve->alive, &tmp, 1) == 1) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7220 return 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7221 return 1; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7222 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7223 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7224 /* Waits on the specified semaphore until it becomes |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7225 * posted, or returns immediately if it already is posted. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7226 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7227 * eve: Handle to the semaphore obtained by |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7228 * an open or create call. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7229 * timeout: Number of milliseconds before timing out |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7230 * or -1 if indefinite. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7231 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7232 int dw_named_event_wait(HEV eve, unsigned long timeout) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7233 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7234 fd_set rd; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7235 struct timeval tv, *useme; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7236 int retval = 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7237 char tmp; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7238 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7239 if(!eve || eve->alive < 0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7240 return DW_ERROR_NON_INIT; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7241 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7242 /* Set the timout or infinite */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7243 if(timeout == -1) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7244 useme = NULL; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7245 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7246 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7247 tv.tv_sec = timeout / 1000; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7248 tv.tv_usec = timeout % 1000; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7249 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7250 useme = &tv; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7251 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7252 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7253 FD_ZERO(&rd); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7254 FD_SET(eve->alive, &rd); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7255 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7256 /* Signal wait */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7257 tmp = (char)2; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7258 write(eve->alive, &tmp, 1); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7259 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7260 retval = select(eve->alive+1, &rd, NULL, NULL, useme); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7261 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7262 /* Signal done waiting. */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7263 tmp = (char)3; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7264 write(eve->alive, &tmp, 1); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7265 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7266 if(retval == 0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7267 return DW_ERROR_TIMEOUT; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7268 else if(retval == -1) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7269 return DW_ERROR_INTERRUPT; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7270 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7271 /* Clear the entry from the pipe so |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7272 * we don't loop endlessly. :) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7273 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7274 read(eve->alive, &tmp, 1); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7275 return 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7276 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7277 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7278 /* Release this semaphore, if there are no more open |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7279 * handles on this semaphore the semaphore will be destroyed. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7280 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7281 * eve: Handle to the semaphore obtained by |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7282 * an open or create call. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7283 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7284 int dw_named_event_close(HEV eve) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7285 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7286 /* Finally close the domain socket, |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7287 * cleanup will continue in _handle_sem. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7288 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7289 if(eve) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7290 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7291 close(eve->alive); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7292 free(eve); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7293 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7294 return 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7295 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7296 |
697
830e1f3672b9
Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
696
diff
changeset
|
7297 #if !defined(GARBAGE_COLLECT) |
830e1f3672b9
Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
696
diff
changeset
|
7298 pthread_key_t _dw_pool_key; |
830e1f3672b9
Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
696
diff
changeset
|
7299 #endif |
830e1f3672b9
Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
696
diff
changeset
|
7300 |
830e1f3672b9
Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
696
diff
changeset
|
7301 /* Mac specific function to cause garbage collection */ |
830e1f3672b9
Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
696
diff
changeset
|
7302 void _dw_pool_drain(void) |
830e1f3672b9
Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
696
diff
changeset
|
7303 { |
830e1f3672b9
Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
696
diff
changeset
|
7304 #if !defined(GARBAGE_COLLECT) |
830e1f3672b9
Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
696
diff
changeset
|
7305 NSAutoreleasePool *pool = pthread_getspecific(_dw_pool_key); |
830e1f3672b9
Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
696
diff
changeset
|
7306 [pool drain]; |
698
e19f69a78f21
Fix for pool being removed and not just drained.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
697
diff
changeset
|
7307 pool = [[NSAutoreleasePool alloc] init]; |
e19f69a78f21
Fix for pool being removed and not just drained.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
697
diff
changeset
|
7308 pthread_setspecific(_dw_pool_key, pool); |
697
830e1f3672b9
Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
696
diff
changeset
|
7309 #endif |
830e1f3672b9
Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
696
diff
changeset
|
7310 } |
830e1f3672b9
Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
696
diff
changeset
|
7311 |
830e1f3672b9
Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
696
diff
changeset
|
7312 /* |
830e1f3672b9
Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
696
diff
changeset
|
7313 * Setup thread independent pools. |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7314 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7315 void _dwthreadstart(void *data) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7316 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7317 void (*threadfunc)(void *) = NULL; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7318 void **tmp = (void **)data; |
671
c60a4f6cfae8
Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
670
diff
changeset
|
7319 /* If we aren't using garbage collection we need autorelease pools */ |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
7320 #if !defined(GARBAGE_COLLECT) |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
7321 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; |
697
830e1f3672b9
Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
696
diff
changeset
|
7322 pthread_setspecific(_dw_pool_key, pool); |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
7323 #endif |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
7324 |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7325 threadfunc = (void (*)(void *))tmp[0]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7326 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7327 threadfunc(tmp[1]); |
671
c60a4f6cfae8
Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
670
diff
changeset
|
7328 /* Release the pool when we are done so we don't leak */ |
666
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
7329 #if !defined(GARBAGE_COLLECT) |
698
e19f69a78f21
Fix for pool being removed and not just drained.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
697
diff
changeset
|
7330 pool = pthread_getspecific(_dw_pool_key); |
666
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
7331 [pool release]; |
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
7332 #endif |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7333 free(tmp); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7334 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7335 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7336 /* |
697
830e1f3672b9
Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
696
diff
changeset
|
7337 * Initializes the Dynamic Windows engine. |
830e1f3672b9
Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
696
diff
changeset
|
7338 * Parameters: |
830e1f3672b9
Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
696
diff
changeset
|
7339 * newthread: True if this is the only thread. |
830e1f3672b9
Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
696
diff
changeset
|
7340 * False if there is already a message loop running. |
830e1f3672b9
Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
696
diff
changeset
|
7341 */ |
830e1f3672b9
Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
696
diff
changeset
|
7342 int API dw_init(int newthread, int argc, char *argv[]) |
830e1f3672b9
Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
696
diff
changeset
|
7343 { |
830e1f3672b9
Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
696
diff
changeset
|
7344 /* Create the application object */ |
830e1f3672b9
Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
696
diff
changeset
|
7345 DWApp = [NSApplication sharedApplication]; |
830e1f3672b9
Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
696
diff
changeset
|
7346 /* Create object for handling timers */ |
830e1f3672b9
Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
696
diff
changeset
|
7347 DWHandler = [[DWTimerHandler alloc] init]; |
830e1f3672b9
Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
696
diff
changeset
|
7348 /* If we aren't using garbage collection we need autorelease pools */ |
830e1f3672b9
Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
696
diff
changeset
|
7349 #if !defined(GARBAGE_COLLECT) |
830e1f3672b9
Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
696
diff
changeset
|
7350 pthread_key_create(&_dw_pool_key, NULL); |
830e1f3672b9
Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
696
diff
changeset
|
7351 pool = [[NSAutoreleasePool alloc] init]; |
726
ecf47778caff
Possible fix for container string columns not showing correctly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
725
diff
changeset
|
7352 pthread_setspecific(_dw_pool_key, pool); |
697
830e1f3672b9
Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
696
diff
changeset
|
7353 #endif |
830e1f3672b9
Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
696
diff
changeset
|
7354 /* Create a default main menu, with just the application menu */ |
830e1f3672b9
Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
696
diff
changeset
|
7355 DWMainMenu = _generate_main_menu(); |
830e1f3672b9
Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
696
diff
changeset
|
7356 [DWApp setMainMenu:DWMainMenu]; |
830e1f3672b9
Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
696
diff
changeset
|
7357 DWObj = [[DWObject alloc] init]; |
830e1f3672b9
Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
696
diff
changeset
|
7358 /* Create mutexes for thread safety */ |
830e1f3672b9
Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
696
diff
changeset
|
7359 DWRunMutex = dw_mutex_new(); |
830e1f3672b9
Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
696
diff
changeset
|
7360 DWThreadMutex = dw_mutex_new(); |
830e1f3672b9
Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
696
diff
changeset
|
7361 DWThreadMutex2 = dw_mutex_new(); |
830e1f3672b9
Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
696
diff
changeset
|
7362 /* Use NSThread to start a dummy thread to initialize the threading subsystem */ |
830e1f3672b9
Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
696
diff
changeset
|
7363 NSThread *thread = [[ NSThread alloc] initWithTarget:DWObj selector:@selector(uselessThread:) object:nil]; |
830e1f3672b9
Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
696
diff
changeset
|
7364 [thread start]; |
830e1f3672b9
Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
696
diff
changeset
|
7365 [thread release]; |
830e1f3672b9
Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
696
diff
changeset
|
7366 return 0; |
830e1f3672b9
Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
696
diff
changeset
|
7367 } |
830e1f3672b9
Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
696
diff
changeset
|
7368 |
830e1f3672b9
Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
696
diff
changeset
|
7369 /* |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7370 * Allocates a shared memory region with a name. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7371 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7372 * handle: A pointer to receive a SHM identifier. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7373 * dest: A pointer to a pointer to receive the memory address. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7374 * size: Size in bytes of the shared memory region to allocate. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7375 * name: A string pointer to a unique memory name. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7376 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7377 HSHM dw_named_memory_new(void **dest, int size, char *name) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7378 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7379 char namebuf[1024]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7380 struct _dw_unix_shm *handle = malloc(sizeof(struct _dw_unix_shm)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7381 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7382 mkdir("/tmp/.dw", S_IWGRP|S_IWOTH); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7383 sprintf(namebuf, "/tmp/.dw/%s", name); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7384 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7385 if((handle->fd = open(namebuf, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR)) < 0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7386 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7387 free(handle); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7388 return NULL; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7389 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7390 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7391 ftruncate(handle->fd, size); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7392 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7393 /* attach the shared memory segment to our process's address space. */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7394 *dest = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, handle->fd, 0); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7395 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7396 if(*dest == MAP_FAILED) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7397 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7398 close(handle->fd); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7399 *dest = NULL; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7400 free(handle); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7401 return NULL; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7402 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7403 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7404 handle->size = size; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7405 handle->sid = getsid(0); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7406 handle->path = strdup(namebuf); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7407 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7408 return handle; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7409 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7410 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7411 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7412 * Aquires shared memory region with a name. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7413 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7414 * dest: A pointer to a pointer to receive the memory address. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7415 * size: Size in bytes of the shared memory region to requested. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7416 * name: A string pointer to a unique memory name. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7417 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7418 HSHM dw_named_memory_get(void **dest, int size, char *name) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7419 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7420 char namebuf[1024]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7421 struct _dw_unix_shm *handle = malloc(sizeof(struct _dw_unix_shm)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7422 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7423 mkdir("/tmp/.dw", S_IWGRP|S_IWOTH); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7424 sprintf(namebuf, "/tmp/.dw/%s", name); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7425 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7426 if((handle->fd = open(namebuf, O_RDWR)) < 0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7427 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7428 free(handle); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7429 return NULL; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7430 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7431 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7432 /* attach the shared memory segment to our process's address space. */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7433 *dest = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, handle->fd, 0); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7434 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7435 if(*dest == MAP_FAILED) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7436 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7437 close(handle->fd); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7438 *dest = NULL; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7439 free(handle); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7440 return NULL; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7441 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7442 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7443 handle->size = size; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7444 handle->sid = -1; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7445 handle->path = NULL; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7446 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7447 return handle; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7448 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7449 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7450 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7451 * Frees a shared memory region previously allocated. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7452 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7453 * handle: Handle obtained from DB_named_memory_allocate. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7454 * ptr: The memory address aquired with DB_named_memory_allocate. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7455 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7456 int dw_named_memory_free(HSHM handle, void *ptr) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7457 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7458 struct _dw_unix_shm *h = handle; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7459 int rc = munmap(ptr, h->size); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7460 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7461 close(h->fd); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7462 if(h->path) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7463 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7464 /* Only remove the actual file if we are the |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7465 * creator of the file. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7466 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7467 if(h->sid != -1 && h->sid == getsid(0)) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7468 remove(h->path); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7469 free(h->path); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7470 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7471 return rc; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7472 } |
697
830e1f3672b9
Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
696
diff
changeset
|
7473 |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7474 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7475 * Creates a new thread with a starting point of func. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7476 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7477 * func: Function which will be run in the new thread. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7478 * data: Parameter(s) passed to the function. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7479 * stack: Stack size of new thread (OS/2 and Windows only). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7480 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7481 DWTID dw_thread_new(void *func, void *data, int stack) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7482 { |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
7483 DWTID thread; |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
7484 void **tmp = malloc(sizeof(void *) * 2); |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
7485 int rc; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7486 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7487 tmp[0] = func; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7488 tmp[1] = data; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7489 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7490 rc = pthread_create(&thread, NULL, (void *)_dwthreadstart, (void *)tmp); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7491 if(rc == 0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7492 return thread; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7493 return (DWTID)-1; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7494 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7495 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7496 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7497 * Ends execution of current thread immediately. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7498 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7499 void dw_thread_end(void) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7500 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7501 pthread_exit(NULL); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7502 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7503 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7504 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7505 * Returns the current thread's ID. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7506 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7507 DWTID dw_thread_id(void) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7508 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7509 return (DWTID)pthread_self(); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7510 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7511 |
661
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7512 /* |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7513 * Execute and external program in a seperate session. |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7514 * Parameters: |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7515 * program: Program name with optional path. |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7516 * type: Either DW_EXEC_CON or DW_EXEC_GUI. |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7517 * params: An array of pointers to string arguements. |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7518 * Returns: |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7519 * -1 on error. |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7520 */ |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7521 int dw_exec(char *program, int type, char **params) |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7522 { |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7523 int ret = -1; |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7524 |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7525 if((ret = fork()) == 0) |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7526 { |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7527 int i; |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7528 |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7529 for (i = 3; i < 256; i++) |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7530 close(i); |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7531 setsid(); |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7532 if(type == DW_EXEC_GUI) |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7533 { |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7534 execvp(program, params); |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7535 } |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7536 else if(type == DW_EXEC_CON) |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7537 { |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7538 char **tmpargs; |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7539 |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7540 if(!params) |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7541 { |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7542 tmpargs = malloc(sizeof(char *)); |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7543 tmpargs[0] = NULL; |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7544 } |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7545 else |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7546 { |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7547 int z = 0; |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7548 |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7549 while(params[z]) |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7550 { |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7551 z++; |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7552 } |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7553 tmpargs = malloc(sizeof(char *)*(z+3)); |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7554 z=0; |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7555 tmpargs[0] = "xterm"; |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7556 tmpargs[1] = "-e"; |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7557 while(params[z]) |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7558 { |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7559 tmpargs[z+2] = params[z]; |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7560 z++; |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7561 } |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7562 tmpargs[z+2] = NULL; |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7563 } |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7564 execvp("xterm", tmpargs); |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7565 free(tmpargs); |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7566 } |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7567 /* If we got here exec failed */ |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7568 _exit(-1); |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7569 } |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7570 return ret; |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7571 } |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7572 |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7573 /* |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7574 * Loads a web browser pointed at the given URL. |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7575 * Parameters: |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7576 * url: Uniform resource locator. |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7577 */ |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7578 int dw_browse(char *url) |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7579 { |
715
5f8102bd7646
dw_browse() reimplmented so it actually works as expected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
714
diff
changeset
|
7580 NSURL *myurl = [NSURL URLWithString:[NSString stringWithUTF8String:url]]; |
5f8102bd7646
dw_browse() reimplmented so it actually works as expected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
714
diff
changeset
|
7581 [[NSWorkspace sharedWorkspace] openURL:myurl]; |
5f8102bd7646
dw_browse() reimplmented so it actually works as expected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
714
diff
changeset
|
7582 return 0; |
5f8102bd7646
dw_browse() reimplmented so it actually works as expected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
714
diff
changeset
|
7583 } |