Mercurial > dwindows
annotate mac/dw.m @ 795:f23cad02cfb3
Make listbox, container and tree cells uneditable.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Wed, 23 Mar 2011 04:40:32 +0000 |
parents | e9bc14c5c72d |
children | 3a3fae1f31bd |
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> |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
12 #import <WebKit/WebKit.h> |
650
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 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
45 0x00000000, /* 0 black */ |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
46 0x000000bb, /* 1 red */ |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
47 0x0000bb00, /* 2 green */ |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
48 0x0000aaaa, /* 3 yellow */ |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
49 0x00cc0000, /* 4 blue */ |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
50 0x00bb00bb, /* 5 magenta */ |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
51 0x00bbbb00, /* 6 cyan */ |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
52 0x00bbbbbb, /* 7 white */ |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
53 0x00777777, /* 8 grey */ |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
54 0x000000ff, /* 9 bright red */ |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
55 0x0000ff00, /* 10 bright green */ |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
56 0x0000eeee, /* 11 bright yellow */ |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
57 0x00ff0000, /* 12 bright blue */ |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
58 0x00ff00ff, /* 13 bright magenta */ |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
59 0x00eeee00, /* 14 bright cyan */ |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
60 0x00ffffff, /* 15 bright white */ |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
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 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
66 if(thiscolor & DW_RGB_COLOR) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
67 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
68 return thiscolor & ~DW_RGB_COLOR; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
69 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
70 else if(thiscolor < 17) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
71 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
72 return _colors[thiscolor]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
73 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
74 return 0; |
657
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 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
79 struct _sighandler *next; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
80 ULONG message; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
81 HWND window; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
82 int id; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
83 void *signalfunction; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
84 void *data; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
85 |
652
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 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
97 SignalHandler *tmp = Root; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
98 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
99 /* Find any callbacks for this function */ |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
100 while(tmp) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
101 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
102 if(tmp->message == messageid && window == tmp->window) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
103 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
104 return tmp; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
105 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
106 tmp = tmp->next; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
107 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
108 return NULL; |
652
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 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
113 ULONG message; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
114 char name[30]; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
115 |
703
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] = { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
122 { 1, DW_SIGNAL_CONFIGURE }, |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
123 { 2, DW_SIGNAL_KEY_PRESS }, |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
124 { 3, DW_SIGNAL_BUTTON_PRESS }, |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
125 { 4, DW_SIGNAL_BUTTON_RELEASE }, |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
126 { 5, DW_SIGNAL_MOTION_NOTIFY }, |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
127 { 6, DW_SIGNAL_DELETE }, |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
128 { 7, DW_SIGNAL_EXPOSE }, |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
129 { 8, DW_SIGNAL_CLICKED }, |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
130 { 9, DW_SIGNAL_ITEM_ENTER }, |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
131 { 10, DW_SIGNAL_ITEM_CONTEXT }, |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
132 { 11, DW_SIGNAL_LIST_SELECT }, |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
133 { 12, DW_SIGNAL_ITEM_SELECT }, |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
134 { 13, DW_SIGNAL_SET_FOCUS }, |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
135 { 14, DW_SIGNAL_VALUE_CHANGED }, |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
136 { 15, DW_SIGNAL_SWITCH_PAGE }, |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
137 { 16, DW_SIGNAL_TREE_EXPAND } |
703
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 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
142 SignalHandler *handler = _get_handler(object, message); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
143 /* NSLog(@"Event handler - type %d\n", message); */ |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
144 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
145 if(handler) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
146 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
147 switch(message) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
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 */ |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
150 case 0: |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
151 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
152 int (* API timerfunc)(void *) = (int (* API)(void *))handler->signalfunction; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
153 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
154 if(!timerfunc(handler->data)) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
155 dw_timer_disconnect(handler->id); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
156 return 0; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
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 */ |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
159 case 1: |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
160 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
161 int (*sizefunc)(HWND, int, int, void *) = handler->signalfunction; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
162 NSSize size; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
163 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
164 if([object isMemberOfClass:[NSWindow class]]) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
165 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
166 NSWindow *window = object; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
167 size = [[window contentView] frame].size; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
168 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
169 else |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
170 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
171 NSView *view = object; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
172 size = [view frame].size; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
173 } |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
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; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
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]; |
745
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
187 char ch = '\0'; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
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 } |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
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 */ |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
202 case 3: |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
203 case 4: |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
204 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
205 int (* API buttonfunc)(HWND, int, int, int, void *) = (int (* API)(HWND, int, int, int, void *))handler->signalfunction; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
206 int button = (int)event; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
207 LONG x,y; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
208 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
209 dw_pointer_query_pos(&x, &y); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
210 |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
211 return buttonfunc(object, (int)x, (int)y, button, handler->data); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
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 */ |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
214 case 6: |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
215 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
216 int (* API closefunc)(HWND, void *) = (int (* API)(HWND, void *))handler->signalfunction; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
217 return closefunc(object, handler->data); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
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 */ |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
220 case 7: |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
221 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
222 DWExpose exp; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
223 int (* API exposefunc)(HWND, DWExpose *, void *) = (int (* API)(HWND, DWExpose *, void *))handler->signalfunction; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
224 NSRect rect = [object frame]; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
225 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
226 exp.x = rect.origin.x; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
227 exp.y = rect.origin.y; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
228 exp.width = rect.size.width; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
229 exp.height = rect.size.height; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
230 int result = exposefunc(object, &exp, handler->data); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
231 [[object window] flushWindow]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
232 return result; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
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 */ |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
235 case 8: |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
236 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
237 int (* API clickfunc)(HWND, void *) = (int (* API)(HWND, void *))handler->signalfunction; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
238 |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
239 return clickfunc(object, handler->data); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
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; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
245 |
669
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 */ |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
249 case 10: |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
250 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
251 int (* API containercontextfunc)(HWND, char *, int, int, void *, void *) = (int (* API)(HWND, char *, int, int, void *, void *))handler->signalfunction; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
252 char *text = (char *)event; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
253 void *user = NULL; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
254 LONG x,y; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
255 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
256 dw_pointer_query_pos(&x, &y); |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
257 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
258 return containercontextfunc(handler->window, text, (int)x, (int)y, handler->data, user); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
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; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
266 |
703
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 */ |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
270 case 12: |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
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; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
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]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
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 } |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
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); |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
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; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
305 |
703
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; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
313 |
703
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; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
319 |
722
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 } |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
322 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
323 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
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; |
740
bb3b2d804f0e
Working on fonts some more.... setting a default label font that is smaller.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
739
diff
changeset
|
338 NSFont *DWDefaultFont; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
339 DWTimerHandler *DWHandler; |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
340 #if !defined(GARBAGE_COLLECT) |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
341 NSAutoreleasePool *pool; |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
342 #endif |
661
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
343 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
|
344 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
|
345 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
|
346 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
|
347 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
|
348 DWTID _dw_mutex_locked = (DWTID)-1; |
754
0d0dc78c589d
Clang complains about the types I used for the OS version.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
753
diff
changeset
|
349 SInt32 DWOSMajor, DWOSMinor, DWOSBuild; |
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
|
350 |
699
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
351 /* 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
|
352 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
|
353 { |
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
354 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
|
355 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
|
356 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
|
357 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
|
358 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
|
359 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
|
360 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
|
361 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
|
362 } DWBitBlt; |
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
363 |
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
|
364 /* 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
|
365 @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
|
366 -(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
|
367 -(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
|
368 -(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
|
369 -(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
|
370 @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
|
371 |
578bbfd8c904
Added 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 @implementation DWObject |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
373 -(void)uselessThread:(id)sender { /* Thread only to initialize threading */ } |
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
|
374 -(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
|
375 { |
578bbfd8c904
Added 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(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
|
377 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
|
378 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
|
379 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
|
380 } |
699
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
381 -(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
|
382 { |
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
383 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
|
384 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
|
385 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
|
386 id bltsrc = bltinfo->src; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
387 |
699
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
388 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
|
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 [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
|
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 else |
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
393 { |
747
a4f99795ff26
Abort drawing functions if we fail to lock focus on a render control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
745
diff
changeset
|
394 if([bltdest lockFocusIfCanDraw] == NO) |
a4f99795ff26
Abort drawing functions if we fail to lock focus on a render control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
745
diff
changeset
|
395 { |
a4f99795ff26
Abort drawing functions if we fail to lock focus on a render control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
745
diff
changeset
|
396 return; |
a4f99795ff26
Abort drawing functions if we fail to lock focus on a render control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
745
diff
changeset
|
397 } |
699
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
398 _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
|
399 } |
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
400 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
|
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 NSImage *image = bltsrc; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
403 [image drawAtPoint:NSMakePoint(bltinfo->xdest, bltinfo->ydest) fromRect:NSMakeRect(bltinfo->xsrc, bltinfo->ysrc, bltinfo->width, bltinfo->height) |
699
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
404 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
|
405 [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
|
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 [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
|
408 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
|
409 } |
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
410 -(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
|
411 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
412 if(_DWLastDrawable) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
413 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
414 id object = _DWLastDrawable; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
415 NSWindow *window = [object window]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
416 [window flushWindow]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
417 } |
699
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
418 } |
735
b75be4860279
Possible fix for initial window creation with 0 size... not sure if the size I picked is good or not...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
734
diff
changeset
|
419 -(void)doWindowFunc:(id)param |
b75be4860279
Possible fix for initial window creation with 0 size... not sure if the size I picked is good or not...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
734
diff
changeset
|
420 { |
b75be4860279
Possible fix for initial window creation with 0 size... not sure if the size I picked is good or not...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
734
diff
changeset
|
421 NSValue *v = (NSValue *)param; |
b75be4860279
Possible fix for initial window creation with 0 size... not sure if the size I picked is good or not...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
734
diff
changeset
|
422 void **params = (void **)[v pointerValue]; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
423 void (* windowfunc)(void *); |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
424 |
735
b75be4860279
Possible fix for initial window creation with 0 size... not sure if the size I picked is good or not...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
734
diff
changeset
|
425 if(params) |
b75be4860279
Possible fix for initial window creation with 0 size... not sure if the size I picked is good or not...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
734
diff
changeset
|
426 { |
b75be4860279
Possible fix for initial window creation with 0 size... not sure if the size I picked is good or not...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
734
diff
changeset
|
427 windowfunc = params[0]; |
b75be4860279
Possible fix for initial window creation with 0 size... not sure if the size I picked is good or not...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
734
diff
changeset
|
428 if(windowfunc) |
b75be4860279
Possible fix for initial window creation with 0 size... not sure if the size I picked is good or not...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
734
diff
changeset
|
429 { |
b75be4860279
Possible fix for initial window creation with 0 size... not sure if the size I picked is good or not...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
734
diff
changeset
|
430 windowfunc(params[1]); |
b75be4860279
Possible fix for initial window creation with 0 size... not sure if the size I picked is good or not...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
734
diff
changeset
|
431 } |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
432 } |
735
b75be4860279
Possible fix for initial window creation with 0 size... not sure if the size I picked is good or not...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
734
diff
changeset
|
433 } |
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
|
434 @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
|
435 |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
436 DWObject *DWObj; |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
437 |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
438 /* 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
|
439 * 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
|
440 * basically everything. Was hoping to add methods |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
441 * to the superclasses but it looks like you can |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
442 * only add methods and no variables, which isn't |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
443 * going to work. -Brian |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
444 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
445 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
446 /* Subclass for a box type */ |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
447 @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
|
448 #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
|
449 <NSWindowDelegate> |
17923b931393
Fixes for building for MacOS 10.5 and PPC
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
715
diff
changeset
|
450 #endif |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
451 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
452 Box *box; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
453 void *userdata; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
454 NSColor *bgcolor; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
455 } |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
456 -(id)init; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
457 -(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
|
458 -(Box *)box; |
792
fc6a626a96cc
Initial groupbox support. Sizing of the content frame is not quite right yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
768
diff
changeset
|
459 -(id)contentView; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
460 -(void *)userdata; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
461 -(void)setUserdata:(void *)input; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
462 -(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
|
463 -(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
|
464 -(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
|
465 -(void)mouseUp:(NSEvent *)theEvent; |
701
c91a1b345f2e
Fix for button press and context menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
700
diff
changeset
|
466 -(NSMenu *)menuForEvent:(NSEvent *)theEvent; |
c91a1b345f2e
Fix for button press and context menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
700
diff
changeset
|
467 -(void)rightMouseUp:(NSEvent *)theEvent; |
c91a1b345f2e
Fix for button press and context menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
700
diff
changeset
|
468 -(void)otherMouseDown:(NSEvent *)theEvent; |
c91a1b345f2e
Fix for button press and context menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
700
diff
changeset
|
469 -(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
|
470 -(void)keyDown:(NSEvent *)theEvent; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
471 -(void)setColor:(unsigned long)input; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
472 @end |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
473 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
474 @implementation DWBox |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
475 -(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
|
476 { |
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
477 self = [super init]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
478 |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
479 if (self) |
666
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
480 { |
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
481 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
|
482 } |
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
483 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
|
484 } |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
485 -(void)dealloc |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
486 { |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
487 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
|
488 free(box); |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
489 _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
|
490 [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
|
491 } |
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
492 -(Box *)box { return box; } |
792
fc6a626a96cc
Initial groupbox support. Sizing of the content frame is not quite right yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
768
diff
changeset
|
493 -(id)contentView { return self; } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
494 -(void *)userdata { return userdata; } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
495 -(void)setUserdata:(void *)input { userdata = input; } |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
496 -(void)drawRect:(NSRect)rect |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
497 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
498 if(bgcolor) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
499 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
500 [bgcolor set]; |
755
f574028932cc
Fix for crash when changing background colors, needed retain and release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
754
diff
changeset
|
501 NSRectFill([self bounds]); |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
502 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
503 } |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
504 -(BOOL)isFlipped { return YES; } |
701
c91a1b345f2e
Fix for button press and context menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
700
diff
changeset
|
505 -(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
|
506 -(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
|
507 -(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
|
508 -(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
|
509 -(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
|
510 -(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
|
511 -(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
|
512 -(void)setColor:(unsigned long)input |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
513 { |
755
f574028932cc
Fix for crash when changing background colors, needed retain and release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
754
diff
changeset
|
514 id orig = bgcolor; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
515 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
516 if(input == _colors[DW_CLR_DEFAULT]) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
517 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
518 bgcolor = nil; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
519 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
520 else |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
521 { |
755
f574028932cc
Fix for crash when changing background colors, needed retain and release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
754
diff
changeset
|
522 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] retain]; |
f574028932cc
Fix for crash when changing background colors, needed retain and release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
754
diff
changeset
|
523 } |
f574028932cc
Fix for crash when changing background colors, needed retain and release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
754
diff
changeset
|
524 [orig release]; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
525 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
526 @end |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
527 |
792
fc6a626a96cc
Initial groupbox support. Sizing of the content frame is not quite right yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
768
diff
changeset
|
528 /* Subclass for a group box type */ |
fc6a626a96cc
Initial groupbox support. Sizing of the content frame is not quite right yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
768
diff
changeset
|
529 @interface DWGroupBox : NSBox |
fc6a626a96cc
Initial groupbox support. Sizing of the content frame is not quite right yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
768
diff
changeset
|
530 { |
fc6a626a96cc
Initial groupbox support. Sizing of the content frame is not quite right yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
768
diff
changeset
|
531 void *userdata; |
fc6a626a96cc
Initial groupbox support. Sizing of the content frame is not quite right yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
768
diff
changeset
|
532 NSColor *bgcolor; |
fc6a626a96cc
Initial groupbox support. Sizing of the content frame is not quite right yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
768
diff
changeset
|
533 } |
fc6a626a96cc
Initial groupbox support. Sizing of the content frame is not quite right yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
768
diff
changeset
|
534 -(Box *)box; |
fc6a626a96cc
Initial groupbox support. Sizing of the content frame is not quite right yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
768
diff
changeset
|
535 -(void *)userdata; |
fc6a626a96cc
Initial groupbox support. Sizing of the content frame is not quite right yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
768
diff
changeset
|
536 -(void)setUserdata:(void *)input; |
fc6a626a96cc
Initial groupbox support. Sizing of the content frame is not quite right yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
768
diff
changeset
|
537 @end |
fc6a626a96cc
Initial groupbox support. Sizing of the content frame is not quite right yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
768
diff
changeset
|
538 |
fc6a626a96cc
Initial groupbox support. Sizing of the content frame is not quite right yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
768
diff
changeset
|
539 @implementation DWGroupBox |
fc6a626a96cc
Initial groupbox support. Sizing of the content frame is not quite right yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
768
diff
changeset
|
540 -(Box *)box { return [[self contentView] box]; } |
fc6a626a96cc
Initial groupbox support. Sizing of the content frame is not quite right yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
768
diff
changeset
|
541 -(void *)userdata { return userdata; } |
fc6a626a96cc
Initial groupbox support. Sizing of the content frame is not quite right yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
768
diff
changeset
|
542 -(void)setUserdata:(void *)input { userdata = input; } |
fc6a626a96cc
Initial groupbox support. Sizing of the content frame is not quite right yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
768
diff
changeset
|
543 @end |
fc6a626a96cc
Initial groupbox support. Sizing of the content frame is not quite right yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
768
diff
changeset
|
544 |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
545 /* Subclass for a top-level window */ |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
546 @interface DWView : DWBox |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
547 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
548 NSMenu *windowmenu; |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
549 } |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
550 -(BOOL)windowShouldClose:(id)sender; |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
551 -(void)setMenu:(NSMenu *)input; |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
552 -(void)windowDidBecomeMain:(id)sender; |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
553 -(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
|
554 -(void)keyDown:(NSEvent *)theEvent; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
555 @end |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
556 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
557 @implementation DWView |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
558 -(BOOL)windowShouldClose:(id)sender |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
559 { |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
560 if(_event_handler(self, nil, 6) == FALSE) |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
561 return NO; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
562 return YES; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
563 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
564 - (void)viewDidMoveToWindow |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
565 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
566 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(windowResized:) name:NSWindowDidResizeNotification object:[self window]]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
567 [[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
|
568 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
569 - (void)dealloc |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
570 { |
736
5b48519a7fb2
Added retains to the window menus so they don't get autoreleased when switching between
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
735
diff
changeset
|
571 if(windowmenu) |
5b48519a7fb2
Added retains to the window menus so they don't get autoreleased when switching between
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
735
diff
changeset
|
572 { |
5b48519a7fb2
Added retains to the window menus so they don't get autoreleased when switching between
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
735
diff
changeset
|
573 [windowmenu release]; |
5b48519a7fb2
Added retains to the window menus so they don't get autoreleased when switching between
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
735
diff
changeset
|
574 } |
5b48519a7fb2
Added retains to the window menus so they don't get autoreleased when switching between
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
735
diff
changeset
|
575 [[NSNotificationCenter defaultCenter] removeObserver:self]; |
5b48519a7fb2
Added retains to the window menus so they don't get autoreleased when switching between
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
735
diff
changeset
|
576 [super dealloc]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
577 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
578 - (void)windowResized:(NSNotification *)notification; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
579 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
580 NSSize size = [self frame].size; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
581 _do_resize(box, size.width, size.height); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
582 _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
|
583 } |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
584 -(void)windowDidBecomeMain:(id)sender |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
585 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
586 if(windowmenu) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
587 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
588 [DWApp setMainMenu:windowmenu]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
589 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
590 else |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
591 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
592 [DWApp setMainMenu:DWMainMenu]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
593 } |
703
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
594 _event_handler(self, nil, 13); |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
595 } |
736
5b48519a7fb2
Added retains to the window menus so they don't get autoreleased when switching between
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
735
diff
changeset
|
596 -(void)setMenu:(NSMenu *)input { windowmenu = input; [windowmenu retain]; } |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
597 -(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
|
598 -(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
|
599 @end |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
600 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
601 /* Subclass for a button type */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
602 @interface DWButton : NSButton |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
603 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
604 void *userdata; |
793
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
605 NSButtonType buttonType; |
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
606 DWBox *parent; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
607 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
608 -(void *)userdata; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
609 -(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
|
610 -(void)buttonClicked:(id)sender; |
793
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
611 -(void)setButtonType:(NSButtonType)input; |
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
612 -(NSButtonType)buttonType; |
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
613 -(void)setParent:(DWBox *)input; |
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
614 -(DWBox *)parent; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
615 @end |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
616 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
617 @implementation DWButton |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
618 -(void *)userdata { return userdata; } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
619 -(void)setUserdata:(void *)input { userdata = input; } |
793
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
620 -(void)buttonClicked:(id)sender |
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
621 { |
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
622 _event_handler(self, nil, 8); |
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
623 if([self buttonType] == NSRadioButton) |
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
624 { |
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
625 DWBox *viewbox = [self parent]; |
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
626 Box *thisbox = [viewbox box]; |
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
627 int z; |
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
628 |
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
629 for(z=0;z<thisbox->count;z++) |
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
630 { |
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
631 if(thisbox->items[z].type != TYPEBOX) |
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
632 { |
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
633 id object = thisbox->items[z].hwnd; |
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
634 |
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
635 if([object isMemberOfClass:[DWButton class]]) |
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
636 { |
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
637 DWButton *button = object; |
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
638 |
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
639 if(button != self && [button buttonType] == NSRadioButton) |
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
640 { |
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
641 [button setState:NSOffState]; |
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
642 } |
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
643 } |
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
644 } |
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
645 } |
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
646 } |
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
647 } |
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
648 -(void)setButtonType:(NSButtonType)input { buttonType = input; [super setButtonType:input]; } |
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
649 -(NSButtonType)buttonType { return buttonType; } |
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
650 -(void)setParent:(DWBox *)input { parent = input; } |
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
651 -(DWBox *)parent { return parent; } |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
652 -(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
|
653 @end |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
654 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
655 /* Subclass for a progress type */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
656 @interface DWPercent : NSProgressIndicator |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
657 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
658 void *userdata; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
659 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
660 -(void *)userdata; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
661 -(void)setUserdata:(void *)input; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
662 @end |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
663 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
664 @implementation DWPercent |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
665 -(void *)userdata { return userdata; } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
666 -(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
|
667 -(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
|
668 @end |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
669 |
651
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
670 /* Subclass for a entryfield type */ |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
671 @interface DWEntryField : NSTextField |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
672 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
673 void *userdata; |
768
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
674 id clickDefault; |
651
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
675 } |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
676 -(void *)userdata; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
677 -(void)setUserdata:(void *)input; |
768
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
678 -(void)setClickDefault:(id)input; |
651
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
679 @end |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
680 |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
681 @implementation DWEntryField |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
682 -(void *)userdata { return userdata; } |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
683 -(void)setUserdata:(void *)input { userdata = input; } |
768
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
684 -(void)setClickDefault:(id)input { clickDefault = input; } |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
685 -(void)keyUp:(NSEvent *)theEvent |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
686 { |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
687 unichar vk = [[theEvent charactersIgnoringModifiers] characterAtIndex:0]; |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
688 if(clickDefault && vk == VK_RETURN) |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
689 { |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
690 [[self window] makeFirstResponder:clickDefault]; |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
691 } else |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
692 { |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
693 [super keyUp:theEvent]; |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
694 } |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
695 } |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
696 -(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
|
697 @end |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
698 |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
699 /* Subclass for a entryfield password type */ |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
700 @interface DWEntryFieldPassword : NSSecureTextField |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
701 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
702 void *userdata; |
768
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
703 id clickDefault; |
651
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
704 } |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
705 -(void *)userdata; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
706 -(void)setUserdata:(void *)input; |
768
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
707 -(void)setClickDefault:(id)input; |
651
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
708 @end |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
709 |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
710 @implementation DWEntryFieldPassword |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
711 -(void *)userdata { return userdata; } |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
712 -(void)setUserdata:(void *)input { userdata = input; } |
768
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
713 -(void)setClickDefault:(id)input { clickDefault = input; } |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
714 -(void)keyUp:(NSEvent *)theEvent |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
715 { |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
716 if(clickDefault && [[theEvent charactersIgnoringModifiers] characterAtIndex:0] == VK_RETURN) |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
717 { |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
718 [[self window] makeFirstResponder:clickDefault]; |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
719 } else |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
720 { |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
721 [super keyUp:theEvent]; |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
722 } |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
723 } |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
724 -(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
|
725 @end |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
726 |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
727 /* Subclass for a Notebook control type */ |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
728 @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
|
729 #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
|
730 <NSTabViewDelegate> |
17923b931393
Fixes for building for MacOS 10.5 and PPC
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
715
diff
changeset
|
731 #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
|
732 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
733 void *userdata; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
734 int 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
|
735 } |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
736 -(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
|
737 -(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
|
738 -(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
|
739 -(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
|
740 -(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
|
741 @end |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
742 |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
743 /* 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
|
744 @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
|
745 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
746 void *userdata; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
747 int 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
|
748 } |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
749 -(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
|
750 -(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
|
751 -(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
|
752 -(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
|
753 @end |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
754 |
703
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
755 @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
|
756 -(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
|
757 -(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
|
758 -(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
|
759 -(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
|
760 -(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
|
761 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
762 id object = [notepage view]; |
703
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
763 DWNotebookPage *page = (DWNotebookPage *)notepage; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
764 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
765 if([object isMemberOfClass:[DWBox class]]) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
766 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
767 DWBox *view = object; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
768 Box *box = [view box]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
769 NSSize size = [view frame].size; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
770 _do_resize(box, size.width, size.height); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
771 } |
703
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
772 _event_handler(self, (void *)[page pageid], 15); |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
773 } |
703
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
774 -(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
|
775 @end |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
776 |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
777 @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
|
778 -(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
|
779 -(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
|
780 -(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
|
781 -(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
|
782 -(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
|
783 @end |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
784 |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
785 /* Subclass for a color chooser type */ |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
786 @interface DWColorChoose : NSColorPanel |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
787 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
788 DWDialog *dialog; |
732
db3a173e487e
Fixes for the color chooser... it now works a single time. However...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
731
diff
changeset
|
789 NSColor *pickedcolor; |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
790 } |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
791 -(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
|
792 -(void)setDialog:(DWDialog *)input; |
732
db3a173e487e
Fixes for the color chooser... it now works a single time. However...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
731
diff
changeset
|
793 -(DWDialog *)dialog; |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
794 @end |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
795 |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
796 @implementation DWColorChoose |
732
db3a173e487e
Fixes for the color chooser... it now works a single time. However...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
731
diff
changeset
|
797 -(void)changeColor:(id)sender { pickedcolor = [self color]; } |
733
8d5e5b89725f
Fixed the crashing issue with dw_color_choose() it now functions properly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
732
diff
changeset
|
798 -(BOOL)windowShouldClose:(id)window { DWDialog *d = dialog; dialog = nil; dw_dialog_dismiss(d, pickedcolor); [window orderOut:nil]; return 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
|
799 -(void)setDialog:(DWDialog *)input { dialog = input; } |
732
db3a173e487e
Fixes for the color chooser... it now works a single time. However...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
731
diff
changeset
|
800 -(DWDialog *)dialog { return dialog; } |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
801 @end |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
802 |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
803 /* Subclass for a splitbar type */ |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
804 @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
|
805 #ifdef BUILDING_FOR_SNOW_LEOPARD |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
806 <NSSplitViewDelegate> |
717
17923b931393
Fixes for building for MacOS 10.5 and PPC
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
715
diff
changeset
|
807 #endif |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
808 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
809 void *userdata; |
677
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
810 float percent; |
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
811 } |
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
812 -(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
|
813 -(void *)userdata; |
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
814 -(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
|
815 -(float)percent; |
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
816 -(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
|
817 @end |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
818 |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
819 @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
|
820 -(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
|
821 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
822 NSArray *views = [self subviews]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
823 id object; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
824 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
825 for(object in views) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
826 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
827 if([object isMemberOfClass:[DWBox class]]) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
828 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
829 DWBox *view = object; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
830 Box *box = [view box]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
831 NSSize size = [view frame].size; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
832 _do_resize(box, size.width, size.height); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
833 } |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
834 } |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
835 } |
677
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
836 -(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
|
837 -(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
|
838 -(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
|
839 -(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
|
840 -(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
|
841 @end |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
842 |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
843 /* 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
|
844 @interface DWSlider : NSSlider |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
845 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
846 void *userdata; |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
847 } |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
848 -(void *)userdata; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
849 -(void)setUserdata:(void *)input; |
704
336800e9e648
Fixes to the slider control so events happen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
703
diff
changeset
|
850 -(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
|
851 @end |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
852 |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
853 @implementation DWSlider |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
854 -(void *)userdata { return userdata; } |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
855 -(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
|
856 -(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
|
857 -(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
|
858 @end |
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 /* 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
|
861 @interface DWScrollbar : NSScroller |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
862 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
863 void *userdata; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
864 float range; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
865 float visible; |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
866 } |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
867 -(void *)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; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
869 -(float)range; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
870 -(float)visible; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
871 -(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
|
872 -(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
|
873 @end |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
874 |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
875 @implementation DWScrollbar |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
876 -(void *)userdata { return userdata; } |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
877 -(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
|
878 -(float)range { return range; } |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
879 -(float)visible { return visible; } |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
880 -(void)setRange:(float)input1 andVisible:(float)input2 { range = input1; visible = input2; } |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
881 -(void)scrollerChanged:(id)sender |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
882 { |
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
|
883 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
|
884 int page = (int)(proportion * range); |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
885 int max = (int)(range - 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
|
886 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
|
887 int newpos = result; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
888 |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
889 switch ([sender hitPart]) |
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
|
890 { |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
891 |
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
|
892 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
|
893 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
|
894 { |
86d76fc09237
Added support for scrollbar line and page scrolling. Need to check the calculations...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
706
diff
changeset
|
895 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
|
896 } |
86d76fc09237
Added support for scrollbar line and page scrolling. Need to check the calculations...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
706
diff
changeset
|
897 break; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
898 |
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
|
899 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
|
900 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
|
901 { |
86d76fc09237
Added support for scrollbar line and page scrolling. Need to check the calculations...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
706
diff
changeset
|
902 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
|
903 } |
86d76fc09237
Added support for scrollbar line and page scrolling. Need to check the calculations...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
706
diff
changeset
|
904 break; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
905 |
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
|
906 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
|
907 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
|
908 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
|
909 { |
86d76fc09237
Added support for scrollbar line and page scrolling. Need to check the calculations...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
706
diff
changeset
|
910 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
|
911 } |
86d76fc09237
Added support for scrollbar line and page scrolling. Need to check the calculations...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
706
diff
changeset
|
912 break; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
913 |
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
|
914 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
|
915 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
|
916 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
|
917 { |
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
|
918 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
|
919 } |
86d76fc09237
Added support for scrollbar line and page scrolling. Need to check the calculations...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
706
diff
changeset
|
920 break; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
921 |
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
|
922 default: |
745
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
923 ; /* do nothing */ |
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
|
924 } |
86d76fc09237
Added support for scrollbar line and page scrolling. Need to check the calculations...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
706
diff
changeset
|
925 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
|
926 { |
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
|
927 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
|
928 [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
|
929 } |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
930 _event_handler(self, (void *)newpos, 14); |
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
|
931 } |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
932 -(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
|
933 @end |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
934 |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
935 /* Subclass for a render area type */ |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
936 @interface DWRender : NSView |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
937 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
938 void *userdata; |
745
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
939 NSFont *font; |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
940 } |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
941 -(void *)userdata; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
942 -(void)setUserdata:(void *)input; |
745
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
943 -(void)setFont:(NSFont *)input; |
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
944 -(NSFont *)font; |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
945 -(void)mouseDown:(NSEvent *)theEvent; |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
946 -(void)mouseUp:(NSEvent *)theEvent; |
701
c91a1b345f2e
Fix for button press and context menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
700
diff
changeset
|
947 -(NSMenu *)menuForEvent:(NSEvent *)theEvent; |
c91a1b345f2e
Fix for button press and context menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
700
diff
changeset
|
948 -(void)rightMouseUp:(NSEvent *)theEvent; |
c91a1b345f2e
Fix for button press and context menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
700
diff
changeset
|
949 -(void)otherMouseDown:(NSEvent *)theEvent; |
c91a1b345f2e
Fix for button press and context menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
700
diff
changeset
|
950 -(void)otherMouseUp:(NSEvent *)theEvent; |
c91a1b345f2e
Fix for button press and context menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
700
diff
changeset
|
951 -(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
|
952 -(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
|
953 -(BOOL)isFlipped; |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
954 @end |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
955 |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
956 @implementation DWRender |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
957 -(void *)userdata { return userdata; } |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
958 -(void)setUserdata:(void *)input { userdata = input; } |
745
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
959 -(void)setFont:(NSFont *)input { [font release]; font = input; [font retain]; } |
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
960 -(NSFont *)font { return font; } |
701
c91a1b345f2e
Fix for button press and context menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
700
diff
changeset
|
961 -(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
|
962 -(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
|
963 -(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
|
964 -(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
|
965 -(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
|
966 -(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
|
967 -(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
|
968 -(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
|
969 -(BOOL)isFlipped { return NO; } |
745
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
970 -(void)dealloc { UserData *root = userdata; _remove_userdata(&root, NULL, TRUE); [font release]; [super dealloc]; } |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
971 @end |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
972 |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
973 /* Subclass for a MLE type */ |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
974 @interface DWMLE : NSTextView |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
975 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
976 void *userdata; |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
977 } |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
978 -(void *)userdata; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
979 -(void)setUserdata:(void *)input; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
980 @end |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
981 |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
982 @implementation DWMLE |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
983 -(void *)userdata { return userdata; } |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
984 -(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
|
985 -(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
|
986 @end |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
987 |
655
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
988 /* Subclass for a Container/List type */ |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
989 @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
|
990 #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
|
991 <NSTableViewDataSource> |
17923b931393
Fixes for building for MacOS 10.5 and PPC
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
715
diff
changeset
|
992 #endif |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
993 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
994 void *userdata; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
995 NSMutableArray *tvcols; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
996 NSMutableArray *data; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
997 NSMutableArray *types; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
998 NSPointerArray *titles; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
999 int lastAddPoint, lastQueryPoint; |
668
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
1000 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
|
1001 } |
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
1002 -(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
|
1003 -(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
|
1004 -(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
|
1005 -(void *)userdata; |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
1006 -(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
|
1007 -(id)scrollview; |
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
1008 -(void)setScrollview:(id)input; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
1009 -(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
|
1010 -(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
|
1011 -(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
|
1012 -(int)addRows:(int)number; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
1013 -(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
|
1014 -(void)removeRow:(int)row; |
659
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
1015 -(void)setRow:(int)row title:(void *)input; |
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
1016 -(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
|
1017 -(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
|
1018 -(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
|
1019 -(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
|
1020 -(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
|
1021 -(void)setLastQueryPoint:(int)input; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
1022 -(void)clear; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
1023 -(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
|
1024 -(void)doubleClicked:(id)sender; |
659
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
1025 -(void)selectionChanged:(id)sender; |
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
1026 -(NSMenu *)menuForEvent:(NSEvent *)event; |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
1027 @end |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
1028 |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
1029 @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
|
1030 -(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
|
1031 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1032 if(tvcols && data) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1033 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1034 int cols = (int)[tvcols count]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1035 if(cols) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1036 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1037 return [data count] / cols; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1038 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1039 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1040 return 0; |
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
|
1041 } |
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
1042 -(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
|
1043 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1044 if(tvcols) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1045 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1046 int z, col = -1; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1047 int count = (int)[tvcols count]; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
1048 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1049 for(z=0;z<count;z++) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1050 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1051 if([tvcols objectAtIndex:z] == aCol) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1052 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1053 col = z; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1054 break; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1055 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1056 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1057 if(col != -1) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1058 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1059 int index = (int)(aRow * count) + col; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1060 id this = [data objectAtIndex:index]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1061 return ([this isKindOfClass:[NSNull class]]) ? nil : this; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1062 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1063 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1064 return nil; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
1065 } |
708
5fe2ca5ef88b
Fixes for container event handling. Also made container/listbox cells non-editable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
707
diff
changeset
|
1066 -(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
|
1067 -(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
|
1068 -(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
|
1069 -(id)scrollview { return scrollview; } |
17923b931393
Fixes for building for MacOS 10.5 and PPC
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
715
diff
changeset
|
1070 -(void)setScrollview:(id)input { scrollview = input; } |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
1071 -(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
|
1072 -(NSTableColumn *)getColumn:(int)col { if(tvcols) { return [tvcols objectAtIndex:col]; } return nil; } |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1073 -(int)insertRow:(NSArray *)input at:(int)index |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1074 { |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1075 if(data) |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1076 { |
687
5dde8d34bc69
Implemented dw_listbox_insert for containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
686
diff
changeset
|
1077 unsigned long start = [tvcols count] * index; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1078 NSIndexSet *set = [[NSIndexSet alloc] initWithIndexesInRange:NSMakeRange(start, start + [tvcols count])]; |
687
5dde8d34bc69
Implemented dw_listbox_insert for containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
686
diff
changeset
|
1079 if(index < lastAddPoint) |
5dde8d34bc69
Implemented dw_listbox_insert for containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
686
diff
changeset
|
1080 { |
5dde8d34bc69
Implemented dw_listbox_insert for containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
686
diff
changeset
|
1081 lastAddPoint++; |
5dde8d34bc69
Implemented dw_listbox_insert for containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
686
diff
changeset
|
1082 } |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1083 [data insertObjects:input atIndexes:set]; |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1084 [titles insertPointer:NULL atIndex:index]; |
687
5dde8d34bc69
Implemented dw_listbox_insert for containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
686
diff
changeset
|
1085 [set release]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1086 return (int)[titles count]; |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1087 } |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1088 return 0; |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1089 } |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1090 -(int)addRow:(NSArray *)input |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1091 { |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1092 if(data) |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1093 { |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1094 lastAddPoint = (int)[titles count]; |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1095 [data addObjectsFromArray:input]; |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1096 [titles addPointer:NULL]; |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1097 return (int)[titles count]; |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1098 } |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1099 return 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
|
1100 } |
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
|
1101 -(int)addRows:(int)number |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
1102 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1103 if(tvcols) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1104 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1105 int count = (int)(number * [tvcols count]); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1106 int z; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
1107 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1108 lastAddPoint = (int)[titles count]; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
1109 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1110 for(z=0;z<count;z++) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1111 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1112 [data addObject:[NSNull null]]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1113 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1114 for(z=0;z<number;z++) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1115 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1116 [titles addPointer:NULL]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1117 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1118 return (int)[titles count]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1119 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1120 return 0; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
1121 } |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
1122 -(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
|
1123 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1124 if(tvcols && input) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1125 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1126 int index = (int)(row * [tvcols count]) + col; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1127 [data replaceObjectAtIndex:index withObject:input]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1128 } |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
1129 } |
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
|
1130 -(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
|
1131 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1132 if(tvcols) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1133 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1134 int z, start, end; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1135 int count = (int)[tvcols count]; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
1136 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1137 start = count * row; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1138 end = start + count; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
1139 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1140 for(z=start;z<end;z++) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1141 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1142 [data removeObjectAtIndex:z]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1143 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1144 [titles removePointerAtIndex:row]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1145 if(lastAddPoint > 0 && lastAddPoint < row) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1146 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1147 lastAddPoint--; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1148 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1149 } |
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
|
1150 } |
659
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
1151 -(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
|
1152 -(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
|
1153 -(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
|
1154 -(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
|
1155 -(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
|
1156 -(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
|
1157 -(void)setLastQueryPoint:(int)input { lastQueryPoint = input; } |
659
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
1158 -(void)clear { if(data) { [data removeAllObjects]; while([titles count]) { [titles removePointerAtIndex:0]; } } lastAddPoint = 0; } |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1159 -(void)setup |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1160 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1161 tvcols = [[[NSMutableArray alloc] init] retain]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1162 data = [[[NSMutableArray alloc] init] retain]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1163 types = [[[NSMutableArray alloc] init] retain]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1164 titles = [[NSPointerArray pointerArrayWithWeakObjects] retain]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1165 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(selectionChanged:) name:NSTableViewSelectionDidChangeNotification object:self]; |
659
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
1166 } |
708
5fe2ca5ef88b
Fixes for container event handling. Also made container/listbox cells non-editable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
707
diff
changeset
|
1167 -(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
|
1168 { |
5fe2ca5ef88b
Fixes for container event handling. Also made container/listbox cells non-editable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
707
diff
changeset
|
1169 /* Handler for container class */ |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1170 _event_handler(self, (NSEvent *)[self getRowTitle:(int)[self selectedRow]], 9); |
708
5fe2ca5ef88b
Fixes for container event handling. Also made container/listbox cells non-editable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
707
diff
changeset
|
1171 } |
659
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
1172 -(void)selectionChanged:(id)sender |
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
1173 { |
703
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
1174 /* Handler for container class */ |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1175 _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
|
1176 /* Handler for listbox class */ |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1177 _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
|
1178 } |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1179 -(NSMenu *)menuForEvent:(NSEvent *)event |
659
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
1180 { |
710
78460ff977c1
Finishing up tree event/signal handlers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
709
diff
changeset
|
1181 int row; |
78460ff977c1
Finishing up tree event/signal handlers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
709
diff
changeset
|
1182 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
|
1183 row = (int)[self rowAtPoint:where]; |
78460ff977c1
Finishing up tree event/signal handlers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
709
diff
changeset
|
1184 _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
|
1185 return nil; |
659
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
1186 } |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1187 -(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
|
1188 @end |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1189 |
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
|
1190 /* 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
|
1191 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
|
1192 { |
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
|
1193 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
|
1194 { |
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
|
1195 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
|
1196 int z; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1197 |
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
|
1198 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
|
1199 { |
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
|
1200 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
|
1201 NSMutableArray *children = (NSMutableArray *)[pnt pointerAtIndex:3]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1202 |
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
|
1203 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
|
1204 { |
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
|
1205 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
|
1206 { |
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
|
1207 _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
|
1208 } |
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
|
1209 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
|
1210 { |
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
|
1211 _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
|
1212 } |
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
|
1213 } |
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
|
1214 } |
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
|
1215 } |
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
|
1216 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
|
1217 { |
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
|
1218 [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
|
1219 } |
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
|
1220 } |
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
|
1221 |
680
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1222 /* Subclass for a Tree type */ |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1223 @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
|
1224 #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
|
1225 <NSOutlineViewDataSource> |
17923b931393
Fixes for building for MacOS 10.5 and PPC
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
715
diff
changeset
|
1226 #endif |
680
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1227 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1228 void *userdata; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1229 NSTableColumn *imagecol; |
680
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1230 NSTableColumn *textcol; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1231 NSMutableArray *data; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1232 /* Each data item consists of a linked lists of tree item data. |
680
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1233 * 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
|
1234 */ |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1235 id scrollview; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1236 } |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1237 -(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
|
1238 -(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
|
1239 -(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
|
1240 -(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
|
1241 -(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
|
1242 -(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
|
1243 -(void *)userdata; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1244 -(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
|
1245 -(void)treeSelectionChanged:(id)sender; |
722
5a8d5161651d
Implemented tree expand event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
721
diff
changeset
|
1246 -(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
|
1247 -(NSScrollView *)scrollview; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1248 -(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
|
1249 -(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
|
1250 -(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
|
1251 @end |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1252 |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1253 @implementation DWTree |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1254 -(id)init |
680
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1255 { |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1256 self = [super init]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1257 |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1258 if (self) |
680
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1259 { |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1260 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
|
1261 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
|
1262 [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
|
1263 [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
|
1264 [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
|
1265 [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
|
1266 textcol = [[NSTableColumn alloc] init]; |
795
f23cad02cfb3
Make listbox, container and tree cells uneditable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
794
diff
changeset
|
1267 [textcol setEditable:NO]; |
680
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1268 [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
|
1269 [self setOutlineTableColumn:textcol]; |
743
4462bc7de1e3
Possible fix for container (and possibly tree) controls picking up combobox events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
742
diff
changeset
|
1270 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(treeSelectionChanged:) name:NSOutlineViewSelectionDidChangeNotification object:self]; |
4462bc7de1e3
Possible fix for container (and possibly tree) controls picking up combobox events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
742
diff
changeset
|
1271 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(treeItemExpanded:) name:NSOutlineViewItemDidExpandNotification object:self]; |
680
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1272 } |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1273 return self; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1274 } |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1275 -(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
|
1276 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1277 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
|
1278 { |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1279 NSMutableArray *array = [item pointerAtIndex:3]; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1280 return array ? [array objectAtIndex:index] : nil; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1281 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1282 else |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1283 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1284 return [data objectAtIndex:index]; |
680
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1285 } |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1286 } |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1287 -(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
|
1288 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1289 return [self outlineView:outlineView numberOfChildrenOfItem:item] != 0; |
680
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1290 } |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1291 -(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
|
1292 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1293 if(item) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1294 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1295 if([item isKindOfClass:[NSPointerArray class]]) |
680
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1296 { |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1297 NSMutableArray *array = [item pointerAtIndex:3]; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1298 return array ? (int)[array count] : 0; |
680
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1299 } |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1300 else |
680
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1301 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1302 return 0; |
680
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1303 } |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1304 } |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1305 else |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1306 { |
680
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1307 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
|
1308 } |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1309 } |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1310 -(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
|
1311 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1312 if(item) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1313 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1314 if([item isKindOfClass:[NSPointerArray class]]) |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1315 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1316 NSPointerArray *this = (NSPointerArray *)item; |
680
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1317 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
|
1318 { |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1319 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
|
1320 } |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1321 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
|
1322 } |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1323 else |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1324 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1325 return nil; |
680
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1326 } |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1327 } |
680
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1328 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
|
1329 } |
710
78460ff977c1
Finishing up tree event/signal handlers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
709
diff
changeset
|
1330 -(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
|
1331 -(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
|
1332 { |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1333 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
|
1334 if(parent) |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1335 { |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1336 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
|
1337 if(!children) |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1338 { |
692
bd909322f40d
Added "retain"s to the DWTree/DWContainer/DWListBox classes memory allocation
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
691
diff
changeset
|
1339 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
|
1340 [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
|
1341 } |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1342 } |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1343 else |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1344 { |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1345 if(!data) |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1346 { |
692
bd909322f40d
Added "retain"s to the DWTree/DWContainer/DWListBox classes memory allocation
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
691
diff
changeset
|
1347 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
|
1348 } |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1349 } |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1350 [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
|
1351 } |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1352 -(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
|
1353 -(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
|
1354 -(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
|
1355 { |
710
78460ff977c1
Finishing up tree event/signal handlers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
709
diff
changeset
|
1356 /* 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
|
1357 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
|
1358 |
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
|
1359 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
|
1360 { |
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
|
1361 _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
|
1362 } |
710
78460ff977c1
Finishing up tree event/signal handlers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
709
diff
changeset
|
1363 } |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1364 -(void)treeItemExpanded:(NSNotification *)notification |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1365 { |
722
5a8d5161651d
Implemented tree expand event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
721
diff
changeset
|
1366 id item = [[notification userInfo ] objectForKey: @"NSObject"]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1367 |
722
5a8d5161651d
Implemented tree expand event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
721
diff
changeset
|
1368 if(item) |
5a8d5161651d
Implemented tree expand event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
721
diff
changeset
|
1369 { |
5a8d5161651d
Implemented tree expand event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
721
diff
changeset
|
1370 _event_handler(self, (void *)item, 16); |
5a8d5161651d
Implemented tree expand event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
721
diff
changeset
|
1371 } |
5a8d5161651d
Implemented tree expand event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
721
diff
changeset
|
1372 } |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1373 -(NSMenu *)menuForEvent:(NSEvent *)event |
710
78460ff977c1
Finishing up tree event/signal handlers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
709
diff
changeset
|
1374 { |
78460ff977c1
Finishing up tree event/signal handlers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
709
diff
changeset
|
1375 int row; |
78460ff977c1
Finishing up tree event/signal handlers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
709
diff
changeset
|
1376 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
|
1377 row = (int)[self rowAtPoint:where]; |
78460ff977c1
Finishing up tree event/signal handlers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
709
diff
changeset
|
1378 id item = [self itemAtRow:row]; |
78460ff977c1
Finishing up tree event/signal handlers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
709
diff
changeset
|
1379 NSString *nstr = [item pointerAtIndex:1]; |
78460ff977c1
Finishing up tree event/signal handlers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
709
diff
changeset
|
1380 _event_handler(self, (NSEvent *)[nstr UTF8String], 10); |
78460ff977c1
Finishing up tree event/signal handlers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
709
diff
changeset
|
1381 return nil; |
709
5a268d5f1cfa
Fixes for tree event handling. Still more to come shortly...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
708
diff
changeset
|
1382 } |
680
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1383 -(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
|
1384 -(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
|
1385 -(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
|
1386 -(void)clear { NSMutableArray *toclear = data; data = nil; _free_tree_recurse(toclear, NULL); [self reloadData]; } |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1387 -(void)dealloc |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1388 { |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1389 UserData *root = userdata; |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1390 _remove_userdata(&root, NULL, TRUE); |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1391 _free_tree_recurse(data, NULL); |
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
|
1392 [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
|
1393 [textcol release]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1394 [super dealloc]; |
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
|
1395 } |
680
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1396 @end |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1397 |
656
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
1398 /* Subclass for a Calendar type */ |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1399 @interface DWCalendar : NSDatePicker |
655
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
1400 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1401 void *userdata; |
655
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
1402 } |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
1403 -(void *)userdata; |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
1404 -(void)setUserdata:(void *)input; |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
1405 @end |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
1406 |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
1407 @implementation DWCalendar |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
1408 -(void *)userdata { return userdata; } |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
1409 -(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
|
1410 -(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
|
1411 @end |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
1412 |
656
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
1413 /* Subclass for a Combobox type */ |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1414 @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
|
1415 #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
|
1416 <NSComboBoxDelegate> |
17923b931393
Fixes for building for MacOS 10.5 and PPC
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
715
diff
changeset
|
1417 #endif |
656
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
1418 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1419 void *userdata; |
768
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
1420 id clickDefault; |
656
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
1421 } |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
1422 -(void *)userdata; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
1423 -(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
|
1424 -(void)comboBoxSelectionDidChange:(NSNotification *)not; |
768
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
1425 -(void)setClickDefault:(id)input; |
656
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
1426 @end |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
1427 |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
1428 @implementation DWComboBox |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
1429 -(void *)userdata { return userdata; } |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
1430 -(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
|
1431 -(void)comboBoxSelectionDidChange:(NSNotification *)not { _event_handler(self, (void *)[self indexOfSelectedItem], 11); } |
768
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
1432 -(void)setClickDefault:(id)input { clickDefault = input; } |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
1433 -(void)keyUp:(NSEvent *)theEvent |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
1434 { |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
1435 if(clickDefault && [[theEvent charactersIgnoringModifiers] characterAtIndex:0] == VK_RETURN) |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
1436 { |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
1437 [[self window] makeFirstResponder:clickDefault]; |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
1438 } else |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
1439 { |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
1440 [super keyUp:theEvent]; |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
1441 } |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
1442 } |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1443 -(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
|
1444 @end |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1445 |
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
|
1446 /* 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
|
1447 /* This is a bad way of doing this... but I can't get the other methods to work */ |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1448 @interface DWStepper : NSStepper |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1449 { |
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
|
1450 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
|
1451 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
|
1452 } |
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
|
1453 -(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
|
1454 -(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
|
1455 -(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
|
1456 -(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
|
1457 -(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
|
1458 -(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
|
1459 @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
|
1460 |
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
|
1461 @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
|
1462 -(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
|
1463 -(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
|
1464 -(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
|
1465 -(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
|
1466 -(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
|
1467 { |
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
|
1468 [super mouseDown:event]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1469 if([[NSApp currentEvent] type] == NSLeftMouseUp) |
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
|
1470 { |
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
|
1471 [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
|
1472 _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
|
1473 } |
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
|
1474 } |
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
|
1475 -(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
|
1476 { |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1477 [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
|
1478 _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
|
1479 } |
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
|
1480 @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
|
1481 |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1482 /* Subclass for a Spinbutton type */ |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1483 @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
|
1484 #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
|
1485 <NSTextFieldDelegate> |
17923b931393
Fixes for building for MacOS 10.5 and PPC
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
715
diff
changeset
|
1486 #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
|
1487 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1488 void *userdata; |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1489 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
|
1490 DWStepper *stepper; |
768
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
1491 id clickDefault; |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1492 } |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1493 -(id)init; |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1494 -(void *)userdata; |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1495 -(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
|
1496 -(NSTextField *)textfield; |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1497 -(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
|
1498 -(void)controlTextDidChange:(NSNotification *)aNotification; |
768
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
1499 -(void)setClickDefault:(id)input; |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1500 @end |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1501 |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1502 @implementation DWSpinButton |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1503 -(id)init |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1504 { |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1505 self = [super init]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1506 |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1507 if(self) |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1508 { |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1509 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
|
1510 [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
|
1511 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
|
1512 [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
|
1513 [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
|
1514 [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
|
1515 [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
|
1516 [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
|
1517 } |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1518 return self; |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1519 } |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1520 -(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
|
1521 -(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
|
1522 -(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
|
1523 -(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
|
1524 -(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
|
1525 { |
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
|
1526 [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
|
1527 [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
|
1528 _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
|
1529 } |
768
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
1530 -(void)setClickDefault:(id)input { clickDefault = input; } |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
1531 -(void)keyUp:(NSEvent *)theEvent |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
1532 { |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
1533 if(clickDefault && [[theEvent charactersIgnoringModifiers] characterAtIndex:0] == VK_RETURN) |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
1534 { |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
1535 [[self window] makeFirstResponder:clickDefault]; |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
1536 } |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
1537 else |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
1538 { |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
1539 [super keyUp:theEvent]; |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
1540 } |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
1541 } |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
1542 -(void)performClick:(id)sender { [textfield performClick:sender]; } |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1543 -(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
|
1544 @end |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
1545 |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1546 /* Subclass for a MDI type |
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
|
1547 * 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
|
1548 * 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
|
1549 */ |
014b02436c1f
Added MDI simulation code... the MDI "window" will just be a box for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
683
diff
changeset
|
1550 @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
|
1551 @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
|
1552 |
014b02436c1f
Added MDI simulation code... the MDI "window" will just be a box for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
683
diff
changeset
|
1553 @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
|
1554 @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
|
1555 |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1556 /* 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
|
1557 */ |
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
|
1558 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
|
1559 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1560 SignalHandler *new = malloc(sizeof(SignalHandler)); |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
1561 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1562 new->message = message; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1563 new->window = window; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1564 new->id = msgid; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1565 new->signalfunction = signalfunction; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1566 new->data = data; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1567 new->next = NULL; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
1568 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1569 if (!Root) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1570 Root = new; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1571 else |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1572 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1573 SignalHandler *prev = NULL, *tmp = Root; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1574 while(tmp) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1575 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1576 if(tmp->message == message && |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1577 tmp->window == window && |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1578 tmp->id == msgid && |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1579 tmp->signalfunction == signalfunction) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1580 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1581 tmp->data = data; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1582 free(new); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1583 return; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1584 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1585 prev = tmp; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1586 tmp = tmp->next; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1587 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1588 if(prev) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1589 prev->next = new; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1590 else |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1591 Root = new; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1592 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1593 } |
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 /* 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
|
1596 ULONG _findsigmessage(char *signame) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1597 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1598 int z; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
1599 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1600 for(z=0;z<SIGNALMAX;z++) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1601 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1602 if(strcasecmp(signame, SignalTranslate[z].name) == 0) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1603 return SignalTranslate[z].message; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1604 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1605 return 0L; |
650
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 unsigned long _foreground = 0xAAAAAA, _background = 0; |
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 /* 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
|
1611 * and does expansion as necessary. |
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 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
|
1614 int pass, int *usedpadx, int *usedpady) |
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 int z, currentx = 0, currenty = 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1617 int uymax = 0, uxmax = 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1618 int upymax = 0, upxmax = 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1619 /* Used for the SIZEEXPAND */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1620 int nux = *usedx, nuy = *usedy; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1621 int nupx = *usedpadx, nupy = *usedpady; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
1622 |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1623 (*usedx) += (thisbox->pad * 2); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1624 (*usedy) += (thisbox->pad * 2); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1625 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1626 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
|
1627 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1628 if(thisbox->items[z].type == TYPEBOX) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1629 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1630 int initialx, initialy; |
792
fc6a626a96cc
Initial groupbox support. Sizing of the content frame is not quite right yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
768
diff
changeset
|
1631 id box = thisbox->items[z].hwnd; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1632 Box *tmp = [box box]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1633 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1634 initialx = x - (*usedx); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1635 initialy = y - (*usedy); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1636 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1637 if(tmp) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1638 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1639 int newx, newy; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1640 int nux = *usedx, nuy = *usedy; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1641 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
|
1642 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1643 /* 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
|
1644 * 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
|
1645 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1646 if(pass == 2) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1647 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1648 int deep = *depth + 1; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1649 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1650 _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
|
1651 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1652 tmp->upx = upx - *usedpadx; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1653 tmp->upy = upy - *usedpady; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1654 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1655 newx = x - nux; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1656 newy = y - nuy; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1657 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1658 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
|
1659 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
|
1660 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1661 tmp->parentxratio = thisbox->xratio; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1662 tmp->parentyratio = thisbox->yratio; |
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 tmp->parentpad = tmp->pad; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1665 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1666 /* Just in case */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1667 tmp->xratio = thisbox->xratio; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1668 tmp->yratio = thisbox->yratio; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1669 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1670 if(thisbox->type == DW_VERT) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1671 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1672 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
|
1673 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
|
1674 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1675 else |
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 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
|
1678 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
|
1679 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1680 if(thisbox->type == DW_HORZ) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1681 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1682 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
|
1683 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
|
1684 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1685 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1686 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1687 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
|
1688 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
|
1689 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1690 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1691 nux = *usedx; nuy = *usedy; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1692 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
|
1693 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1694 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1695 (*depth)++; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1696 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1697 _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
|
1698 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1699 (*depth)--; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1700 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1701 newx = x - nux; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1702 newy = y - nuy; |
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 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
|
1705 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
|
1706 } |
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 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1709 if(pass > 1 && *depth > 0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1710 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1711 if(thisbox->type == DW_VERT) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1712 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1713 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
|
1714 thisbox->items[z].xratio = 1.0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1715 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1716 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
|
1717 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1718 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1719 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1720 if(thisbox->minwidth-thisbox->upx == 0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1721 thisbox->items[z].xratio = 1.0; |
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 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
|
1724 } |
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 if(thisbox->type == DW_HORZ) |
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 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
|
1729 thisbox->items[z].yratio = 1.0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1730 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1731 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
|
1732 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1733 else |
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 if(thisbox->minheight-thisbox->upy == 0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1736 thisbox->items[z].yratio = 1.0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1737 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1738 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
|
1739 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1740 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1741 if(thisbox->items[z].type == TYPEBOX) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1742 { |
792
fc6a626a96cc
Initial groupbox support. Sizing of the content frame is not quite right yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
768
diff
changeset
|
1743 id box = thisbox->items[z].hwnd; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1744 Box *tmp = [box box]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1745 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1746 if(tmp) |
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 tmp->parentxratio = thisbox->items[z].xratio; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1749 tmp->parentyratio = thisbox->items[z].yratio; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1750 } |
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 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1753 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1754 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1755 thisbox->items[z].xratio = thisbox->xratio; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1756 thisbox->items[z].yratio = thisbox->yratio; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1757 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1758 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1759 if(thisbox->type == DW_VERT) |
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((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
|
1762 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
|
1763 if(thisbox->items[z].hsize != SIZEEXPAND) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1764 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1765 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
|
1766 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
|
1767 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1768 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1769 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1770 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
|
1771 upxmax = thisbox->items[z].pad*2; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1772 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1773 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1774 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1775 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1776 if(thisbox->items[z].width == -1) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1777 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1778 /* 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
|
1779 /* thisbox->items[z].width = */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1780 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1781 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1782 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1783 (*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
|
1784 if(thisbox->items[z].hsize != SIZEEXPAND) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1785 (*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
|
1786 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1787 (*usedpadx) += thisbox->items[z].pad*2; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1788 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1789 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1790 if(thisbox->type == DW_HORZ) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1791 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1792 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
|
1793 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
|
1794 if(thisbox->items[z].vsize != SIZEEXPAND) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1795 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1796 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
|
1797 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
|
1798 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1799 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1800 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1801 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
|
1802 upymax = thisbox->items[z].pad*2; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1803 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1804 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1805 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1806 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1807 if(thisbox->items[z].height == -1) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1808 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1809 /* 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
|
1810 /* thisbox->items[z].height = */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1811 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1812 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1813 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1814 (*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
|
1815 if(thisbox->items[z].vsize != SIZEEXPAND) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1816 (*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
|
1817 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1818 (*usedpady) += thisbox->items[z].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 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1823 (*usedx) += uxmax; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1824 (*usedy) += uymax; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1825 (*usedpadx) += upxmax; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1826 (*usedpady) += upymax; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1827 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1828 currentx += thisbox->pad; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1829 currenty += thisbox->pad; |
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 /* 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
|
1832 if(pass > 1) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1833 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1834 /* 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
|
1835 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
|
1836 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1837 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
|
1838 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
|
1839 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
|
1840 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
|
1841 /* 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
|
1842 if(thisbox->items[z].type == TYPEBOX) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1843 { |
792
fc6a626a96cc
Initial groupbox support. Sizing of the content frame is not quite right yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
768
diff
changeset
|
1844 id box = thisbox->items[z].hwnd; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1845 Box *tmp = [box box]; |
650
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 if(tmp) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1848 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1849 if(*depth > 0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1850 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1851 float calcval; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1852 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1853 if(thisbox->type == DW_VERT) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1854 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1855 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
|
1856 if(calcval == 0.0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1857 tmp->xratio = thisbox->xratio; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1858 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1859 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
|
1860 tmp->width = thisbox->items[z].width; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1861 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1862 if(thisbox->type == DW_HORZ) |
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 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
|
1865 if(calcval == 0.0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1866 tmp->yratio = thisbox->yratio; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1867 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1868 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
|
1869 tmp->height = thisbox->items[z].height; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1870 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1871 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1872 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1873 (*depth)++; |
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 _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
|
1876 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1877 (*depth)--; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1878 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1879 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1880 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1881 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1882 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1883 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
|
1884 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1885 int height = thisbox->items[z].height; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1886 int width = thisbox->items[z].width; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1887 int pad = thisbox->items[z].pad; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1888 NSView *handle = thisbox->items[z].hwnd; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1889 NSPoint point; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1890 NSSize size; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1891 int vectorx, vectory; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1892 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1893 /* 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
|
1894 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
|
1895 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
|
1896 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1897 if(width > 0 && height > 0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1898 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1899 /* 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
|
1900 if(*depth == 0) |
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 vectorx++; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1903 vectory++; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1904 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1905 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1906 /* 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
|
1907 if(thisbox->items[z].vsize != SIZEEXPAND) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1908 vectory = 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1909 if(thisbox->items[z].hsize != SIZEEXPAND) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1910 vectorx = 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1911 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1912 point.x = currentx + pad; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1913 point.y = currenty + pad; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1914 size.width = width + vectorx; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1915 size.height = height + vectory; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1916 [handle setFrameOrigin:point]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1917 [handle setFrameSize:size]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1918 |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1919 /* Special handling for notebook controls */ |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1920 if([handle isMemberOfClass:[DWNotebook class]]) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1921 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1922 DWNotebook *notebook = (DWNotebook *)handle; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1923 DWNotebookPage *notepage = (DWNotebookPage *)[notebook selectedTabViewItem]; |
792
fc6a626a96cc
Initial groupbox support. Sizing of the content frame is not quite right yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
768
diff
changeset
|
1924 id view = [notepage view]; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
1925 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1926 if(view != nil) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1927 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1928 Box *box = [view box]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1929 NSSize size = [view frame].size; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1930 _do_resize(box, size.width, size.height); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1931 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1932 } |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1933 /* 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
|
1934 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
|
1935 { |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1936 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
|
1937 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
|
1938 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
|
1939 [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
|
1940 [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
|
1941 [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
|
1942 [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
|
1943 } |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1944 else if([handle isMemberOfClass:[DWRender class]]) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1945 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1946 _event_handler(handle, nil, 1); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1947 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1948 else if([handle isMemberOfClass:[DWSplitBar class]] && size.width > 20 && size.height > 20) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1949 { |
677
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
1950 DWSplitBar *split = (DWSplitBar *)handle; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1951 float percent = [split percent]; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
1952 |
677
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
1953 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
|
1954 { |
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
1955 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
|
1956 [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
|
1957 } |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1958 } |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
1959 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1960 if(thisbox->type == DW_HORZ) |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1961 currentx += width + vectorx + (pad * 2); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1962 if(thisbox->type == DW_VERT) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1963 currenty += height + vectory + (pad * 2); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1964 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1965 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1966 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1967 return 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1968 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1969 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1970 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
|
1971 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1972 if(x != 0 && y != 0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1973 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1974 if(thisbox) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1975 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1976 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
|
1977 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1978 _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
|
1979 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1980 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
|
1981 return; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1982 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1983 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
|
1984 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
|
1985 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1986 usedx = usedy = usedpadx = usedpady = depth = 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1987 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1988 _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
|
1989 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1990 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1991 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1992 |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
1993 NSMenu *_generate_main_menu() |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
1994 { |
751
eba6ab48c952
Runtime Snow Leopard checks where possible and visual fix for Leopard status text.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
749
diff
changeset
|
1995 NSString *applicationName = nil; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
1996 |
751
eba6ab48c952
Runtime Snow Leopard checks where possible and visual fix for Leopard status text.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
749
diff
changeset
|
1997 /* 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
|
1998 #ifdef BUILDING_FOR_SNOW_LEOPARD |
751
eba6ab48c952
Runtime Snow Leopard checks where possible and visual fix for Leopard status text.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
749
diff
changeset
|
1999 applicationName = [[NSRunningApplication currentApplication] localizedName]; |
717
17923b931393
Fixes for building for MacOS 10.5 and PPC
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
715
diff
changeset
|
2000 #endif |
751
eba6ab48c952
Runtime Snow Leopard checks where possible and visual fix for Leopard status text.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
749
diff
changeset
|
2001 if(applicationName == nil) |
eba6ab48c952
Runtime Snow Leopard checks where possible and visual fix for Leopard status text.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
749
diff
changeset
|
2002 { |
eba6ab48c952
Runtime Snow Leopard checks where possible and visual fix for Leopard status text.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
749
diff
changeset
|
2003 applicationName = [[NSProcessInfo processInfo] processName]; |
eba6ab48c952
Runtime Snow Leopard checks where possible and visual fix for Leopard status text.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
749
diff
changeset
|
2004 } |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
2005 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2006 /* Create the main menu */ |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2007 NSMenu * mainMenu = [[[NSMenu alloc] initWithTitle:@"MainMenu"] autorelease]; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
2008 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2009 NSMenuItem * mitem = [mainMenu addItemWithTitle:@"Apple" action:NULL keyEquivalent:@""]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2010 NSMenu * menu = [[[NSMenu alloc] initWithTitle:@"Apple"] autorelease]; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
2011 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2012 [DWApp performSelector:@selector(setAppleMenu:) withObject:menu]; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
2013 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2014 /* Setup the Application menu */ |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2015 NSMenuItem * item = [menu addItemWithTitle:[NSString stringWithFormat:@"%@ %@", NSLocalizedString(@"About", nil), applicationName] |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2016 action:@selector(orderFrontStandardAboutPanel:) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2017 keyEquivalent:@""]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2018 [item setTarget:DWApp]; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
2019 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2020 [menu addItem:[NSMenuItem separatorItem]]; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
2021 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2022 item = [menu addItemWithTitle:NSLocalizedString(@"Services", nil) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2023 action:NULL |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2024 keyEquivalent:@""]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2025 NSMenu * servicesMenu = [[[NSMenu alloc] initWithTitle:@"Services"] autorelease]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2026 [menu setSubmenu:servicesMenu forItem:item]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2027 [DWApp setServicesMenu:servicesMenu]; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
2028 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2029 [menu addItem:[NSMenuItem separatorItem]]; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
2030 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2031 item = [menu addItemWithTitle:[NSString stringWithFormat:@"%@ %@", NSLocalizedString(@"Hide", nil), applicationName] |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2032 action:@selector(hide:) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2033 keyEquivalent:@"h"]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2034 [item setTarget:DWApp]; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
2035 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2036 item = [menu addItemWithTitle:NSLocalizedString(@"Hide Others", nil) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2037 action:@selector(hideOtherApplications:) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2038 keyEquivalent:@"h"]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2039 [item setKeyEquivalentModifierMask:NSCommandKeyMask | NSAlternateKeyMask]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2040 [item setTarget:DWApp]; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
2041 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2042 item = [menu addItemWithTitle:NSLocalizedString(@"Show All", nil) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2043 action:@selector(unhideAllApplications:) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2044 keyEquivalent:@""]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2045 [item setTarget:DWApp]; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
2046 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2047 [menu addItem:[NSMenuItem separatorItem]]; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
2048 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2049 item = [menu addItemWithTitle:[NSString stringWithFormat:@"%@ %@", NSLocalizedString(@"Quit", nil), applicationName] |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2050 action:@selector(terminate:) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2051 keyEquivalent:@"q"]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2052 [item setTarget:DWApp]; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
2053 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2054 [mainMenu setSubmenu:menu forItem:mitem]; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
2055 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2056 return mainMenu; |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
2057 } |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
2058 |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
2059 /* |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2060 * 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
|
2061 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2062 void API dw_main(void) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2063 { |
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
|
2064 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
|
2065 DWThread = dw_thread_id(); |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2066 [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
|
2067 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
|
2068 dw_mutex_unlock(DWRunMutex); |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2069 } |
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 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2072 * 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
|
2073 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2074 * 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
|
2075 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2076 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
|
2077 { |
694
130ca42c4ae3
Reimplementation of dw_main_iteration and dw_main_sleep that actually work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
693
diff
changeset
|
2078 DWTID curr = pthread_self(); |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2079 |
694
130ca42c4ae3
Reimplementation of dw_main_iteration and dw_main_sleep that actually work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
693
diff
changeset
|
2080 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
|
2081 { |
130ca42c4ae3
Reimplementation of dw_main_iteration and dw_main_sleep that actually work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
693
diff
changeset
|
2082 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
|
2083 NSDate *until = [NSDate dateWithTimeIntervalSinceNow:(milliseconds/1000.0)]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2084 |
695
3b17111499bf
Minor updates to the last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
694
diff
changeset
|
2085 if(orig == (DWTID)-1) |
3b17111499bf
Minor updates to the last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
694
diff
changeset
|
2086 { |
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
|
2087 dw_mutex_lock(DWRunMutex); |
695
3b17111499bf
Minor updates to the last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
694
diff
changeset
|
2088 DWThread = curr; |
3b17111499bf
Minor updates to the last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
694
diff
changeset
|
2089 } |
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
|
2090 /* 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
|
2091 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
|
2092 { |
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
|
2093 /* Just loop */ |
695
3b17111499bf
Minor updates to the last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
694
diff
changeset
|
2094 } |
3b17111499bf
Minor updates to the last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
694
diff
changeset
|
2095 if(orig == (DWTID)-1) |
3b17111499bf
Minor updates to the last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
694
diff
changeset
|
2096 { |
3b17111499bf
Minor updates to the last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
694
diff
changeset
|
2097 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
|
2098 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
|
2099 } |
130ca42c4ae3
Reimplementation of dw_main_iteration and dw_main_sleep that actually work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
693
diff
changeset
|
2100 } |
130ca42c4ae3
Reimplementation of dw_main_iteration and dw_main_sleep that actually work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
693
diff
changeset
|
2101 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
|
2102 { |
694
130ca42c4ae3
Reimplementation of dw_main_iteration and dw_main_sleep that actually work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
693
diff
changeset
|
2103 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
|
2104 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2105 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2106 |
700
7953f0471e4d
Some cleanups for the run loop iteration and thread system.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
699
diff
changeset
|
2107 /* 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
|
2108 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
|
2109 { |
694
130ca42c4ae3
Reimplementation of dw_main_iteration and dw_main_sleep that actually work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
693
diff
changeset
|
2110 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
|
2111 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
|
2112 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
|
2113 dequeue:YES]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2114 if(event) |
694
130ca42c4ae3
Reimplementation of dw_main_iteration and dw_main_sleep that actually work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
693
diff
changeset
|
2115 { |
130ca42c4ae3
Reimplementation of dw_main_iteration and dw_main_sleep that actually work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
693
diff
changeset
|
2116 [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
|
2117 [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
|
2118 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
|
2119 } |
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
|
2120 return 0; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2121 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2122 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2123 /* |
700
7953f0471e4d
Some cleanups for the run loop iteration and thread system.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
699
diff
changeset
|
2124 * 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
|
2125 */ |
7953f0471e4d
Some cleanups for the run loop iteration and thread system.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
699
diff
changeset
|
2126 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
|
2127 { |
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
|
2128 DWTID curr = pthread_self(); |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2129 |
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
|
2130 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
|
2131 { |
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
|
2132 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
|
2133 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
|
2134 _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
|
2135 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
|
2136 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
|
2137 } |
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
|
2138 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
|
2139 { |
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
|
2140 _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
|
2141 } |
700
7953f0471e4d
Some cleanups for the run loop iteration and thread system.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
699
diff
changeset
|
2142 } |
7953f0471e4d
Some cleanups for the run loop iteration and thread system.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
699
diff
changeset
|
2143 |
7953f0471e4d
Some cleanups for the run loop iteration and thread system.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
699
diff
changeset
|
2144 /* |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2145 * 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
|
2146 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2147 * 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
|
2148 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2149 void API dw_exit(int exitcode) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2150 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2151 exit(exitcode); |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2152 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2153 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2154 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2155 * 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
|
2156 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2157 * ptr: Pointer to dynamic windows allocated |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2158 * memory to be free()'d. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2159 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2160 void API dw_free(void *ptr) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2161 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2162 free(ptr); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2163 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2164 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2165 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2166 * 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
|
2167 * 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
|
2168 * OS/2 and Windows). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2169 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2170 char *dw_user_dir(void) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2171 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2172 static char _user_dir[1024] = ""; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
2173 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2174 if(!_user_dir[0]) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2175 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2176 char *home = getenv("HOME"); |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
2177 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2178 if(home) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2179 strcpy(_user_dir, home); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2180 else |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2181 strcpy(_user_dir, "/"); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2182 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2183 return _user_dir; |
650
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 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2186 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2187 * 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
|
2188 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2189 * 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
|
2190 * 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
|
2191 * format: printf style format string. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2192 * ...: 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
|
2193 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2194 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
|
2195 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2196 int iResponse; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2197 NSString *button1 = @"OK"; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2198 NSString *button2 = nil; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2199 NSString *button3 = nil; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2200 va_list args; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2201 char outbuf[1000]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2202 |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2203 va_start(args, format); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2204 vsprintf(outbuf, format, args); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2205 va_end(args); |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
2206 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2207 if(flags & DW_MB_OKCANCEL) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2208 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2209 button2 = @"Cancel"; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2210 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2211 else if(flags & DW_MB_YESNO) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2212 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2213 button1 = @"Yes"; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2214 button2 = @"No"; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2215 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2216 else if(flags & DW_MB_YESNOCANCEL) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2217 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2218 button1 = @"Yes"; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2219 button2 = @"No"; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2220 button3 = @"Cancel"; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2221 } |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
2222 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2223 if(flags & DW_MB_ERROR) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2224 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2225 iResponse = (int) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2226 NSRunCriticalAlertPanel([ NSString stringWithUTF8String:title ], |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2227 [ NSString stringWithUTF8String:outbuf ], |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2228 button1, button2, button3); } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2229 else |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2230 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2231 iResponse = (int) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2232 NSRunAlertPanel([ NSString stringWithUTF8String:title ], |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2233 [ NSString stringWithUTF8String:outbuf ], |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2234 button1, button2, button3); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2235 } |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
2236 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2237 switch(iResponse) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2238 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2239 case NSAlertDefaultReturn: /* user pressed OK */ |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2240 if(flags & DW_MB_YESNO || flags & DW_MB_YESNOCANCEL) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2241 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2242 return DW_MB_RETURN_YES; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2243 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2244 return DW_MB_RETURN_OK; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2245 case NSAlertAlternateReturn: /* user pressed Cancel */ |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2246 if(flags & DW_MB_OKCANCEL) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2247 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2248 return DW_MB_RETURN_CANCEL; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2249 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2250 return DW_MB_RETURN_NO; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2251 case NSAlertOtherReturn: /* user pressed the third button */ |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2252 return DW_MB_RETURN_CANCEL; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2253 case NSAlertErrorReturn: /* an error occurred */ |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2254 break; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2255 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2256 return 0; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2257 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2258 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2259 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2260 * 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
|
2261 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2262 * title: Title bar text for dialog. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2263 * 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
|
2264 * ext: Default file extention. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2265 * 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
|
2266 * Returns: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2267 * 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
|
2268 * the file path on success. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2269 * |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2270 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2271 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
|
2272 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2273 if(flags == DW_FILE_OPEN) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2274 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2275 /* Create the File Open Dialog class. */ |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2276 NSOpenPanel* openDlg = [NSOpenPanel openPanel]; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
2277 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2278 /* Enable the selection of files in the dialog. */ |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2279 [openDlg setCanChooseFiles:YES]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2280 [openDlg setCanChooseDirectories:NO]; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
2281 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2282 /* Disable multiple selection */ |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2283 [openDlg setAllowsMultipleSelection:NO]; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
2284 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2285 /* Display the dialog. If the OK button was pressed, |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2286 * process the files. |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2287 */ |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2288 if([openDlg runModal] == NSOKButton) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2289 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2290 /* Get an array containing the full filenames of all |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2291 * files and directories selected. |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2292 */ |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2293 NSArray* files = [openDlg filenames]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2294 NSString* fileName = [files objectAtIndex:0]; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
2295 return strdup([ fileName UTF8String ]); |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2296 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2297 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2298 else |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2299 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2300 /* Create the File Save Dialog class. */ |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2301 NSSavePanel* saveDlg = [NSSavePanel savePanel]; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
2302 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2303 /* Enable the creation of directories in the dialog. */ |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2304 [saveDlg setCanCreateDirectories:YES]; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
2305 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2306 /* Display the dialog. If the OK button was pressed, |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2307 * process the files. |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2308 */ |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2309 if([saveDlg runModal] == NSFileHandlingPanelOKButton) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2310 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2311 /* Get an array containing the full filenames of all |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2312 * files and directories selected. |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2313 */ |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2314 NSString* fileName = [saveDlg filename]; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
2315 return strdup([ fileName UTF8String ]); |
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
2316 } |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2317 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2318 |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2319 return NULL; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2320 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2321 |
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 * 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
|
2324 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2325 * None. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2326 * Returns: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2327 * 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
|
2328 * be converted to text. |
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 char *dw_clipboard_get_text() |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2331 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2332 NSPasteboard *pasteboard = [NSPasteboard generalPasteboard]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2333 NSString *str = [pasteboard stringForType:NSStringPboardType]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2334 if(str != nil) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2335 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2336 return strdup([ str UTF8String ]); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2337 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2338 return NULL; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2339 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2340 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2341 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2342 * 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
|
2343 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2344 * Text. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2345 */ |
651
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2346 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
|
2347 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2348 NSPasteboard *pasteboard = [NSPasteboard generalPasteboard]; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
2349 |
751
eba6ab48c952
Runtime Snow Leopard checks where possible and visual fix for Leopard status text.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
749
diff
changeset
|
2350 /* Only in Snow Leopard */ |
eba6ab48c952
Runtime Snow Leopard checks where possible and visual fix for Leopard status text.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
749
diff
changeset
|
2351 if(DWOSMinor > 5) |
eba6ab48c952
Runtime Snow Leopard checks where possible and visual fix for Leopard status text.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
749
diff
changeset
|
2352 { |
eba6ab48c952
Runtime Snow Leopard checks where possible and visual fix for Leopard status text.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
749
diff
changeset
|
2353 [pasteboard clearContents]; |
eba6ab48c952
Runtime Snow Leopard checks where possible and visual fix for Leopard status text.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
749
diff
changeset
|
2354 } |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
2355 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2356 [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
|
2357 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2358 |
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 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2361 * Allocates and initializes a dialog struct. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2362 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2363 * 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
|
2364 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2365 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
|
2366 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2367 DWDialog *tmp = malloc(sizeof(DWDialog)); |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
2368 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2369 if(tmp) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2370 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2371 tmp->eve = dw_event_new(); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2372 dw_event_reset(tmp->eve); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2373 tmp->data = data; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2374 tmp->done = FALSE; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2375 tmp->result = NULL; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2376 } |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
2377 return tmp; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2378 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2379 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2380 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2381 * 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
|
2382 * initial called of dw_dialog_wait(). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2383 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2384 * 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
|
2385 * 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
|
2386 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2387 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
|
2388 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2389 dialog->result = result; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2390 dw_event_post(dialog->eve); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2391 dialog->done = TRUE; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2392 return 0; |
650
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 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2396 * 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
|
2397 * 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
|
2398 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2399 * 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
|
2400 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2401 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
|
2402 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2403 void *tmp; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
2404 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2405 while(!dialog->done) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2406 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2407 _dw_main_iteration([NSDate dateWithTimeIntervalSinceNow:0.01]); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2408 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2409 dw_event_close(&dialog->eve); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2410 tmp = dialog->result; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2411 free(dialog); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2412 return tmp; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2413 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2414 |
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 * 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
|
2417 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2418 * 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
|
2419 * 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
|
2420 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2421 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
|
2422 { |
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
|
2423 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
|
2424 DW_MUTEX_LOCK; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2425 DWBox *view = [[DWBox alloc] init]; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2426 Box *newbox = [view box]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2427 memset(newbox, 0, sizeof(Box)); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2428 newbox->pad = pad; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2429 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
|
2430 DW_MUTEX_UNLOCK; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2431 return view; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2432 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2433 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2434 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2435 * 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
|
2436 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2437 * 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
|
2438 * 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
|
2439 * 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
|
2440 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2441 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
|
2442 { |
792
fc6a626a96cc
Initial groupbox support. Sizing of the content frame is not quite right yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
768
diff
changeset
|
2443 NSBox *groupbox = [[DWGroupBox alloc] init]; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2444 DWBox *box = dw_box_new(type, pad); |
792
fc6a626a96cc
Initial groupbox support. Sizing of the content frame is not quite right yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
768
diff
changeset
|
2445 [groupbox setBorderType:NSBezelBorder]; |
fc6a626a96cc
Initial groupbox support. Sizing of the content frame is not quite right yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
768
diff
changeset
|
2446 [groupbox setTitle:[NSString stringWithUTF8String:title]]; |
fc6a626a96cc
Initial groupbox support. Sizing of the content frame is not quite right yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
768
diff
changeset
|
2447 [groupbox setContentView:box]; |
fc6a626a96cc
Initial groupbox support. Sizing of the content frame is not quite right yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
768
diff
changeset
|
2448 return groupbox; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2449 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2450 |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2451 #ifndef INCOMPLETE |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2452 /* |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2453 * Create a new scrollable Box to be packed. |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2454 * Parameters: |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2455 * type: Either DW_VERT (vertical) or DW_HORZ (horizontal). |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2456 * pad: Number of pixels to pad around the box. |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2457 * This works fine under GTK+, but is incomplete on other platforms |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2458 */ |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2459 HWND dw_scrollbox_new( int type, int pad ) |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2460 { |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2461 DWBox *box = dw_box_new(type, pad); |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2462 [box setFocusRingType:NSFocusRingTypeExterior]; |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2463 NSLog(@"dw_scrollbox_new() unimplemented\n"); |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2464 return box; |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2465 } |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2466 |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2467 /* |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2468 * Returns the position of the scrollbar in the scrollbox |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2469 * Parameters: |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2470 * handle: Handle to the scrollbox to be queried. |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2471 * orient: The vertical or horizontal scrollbar. |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2472 */ |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2473 int dw_scrollbox_get_pos(HWND handle, int orient) |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2474 { |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2475 int val = -1; |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2476 NSLog(@"dw_scrollbox_get_pos() unimplemented\n"); |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2477 return val; |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2478 } |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2479 |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2480 /* |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2481 * Gets the range for the scrollbar in the scrollbox. |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2482 * Parameters: |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2483 * handle: Handle to the scrollbox to be queried. |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2484 * orient: The vertical or horizontal scrollbar. |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2485 */ |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2486 int API dw_scrollbox_get_range(HWND handle, int orient) |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2487 { |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2488 int val = -1; |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2489 NSLog(@"dw_scrollbox_get_range() unimplemented\n"); |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2490 return val; |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2491 } |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2492 #endif |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2493 |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2494 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2495 * 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
|
2496 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2497 * 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
|
2498 * 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
|
2499 * 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
|
2500 * 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
|
2501 * 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
|
2502 * 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
|
2503 * 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
|
2504 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2505 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
|
2506 { |
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
|
2507 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
|
2508 DW_MUTEX_LOCK; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2509 NSObject *object = box; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2510 DWBox *view = box; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2511 DWBox *this = item; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2512 Box *thisbox; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2513 int z; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2514 Item *tmpitem, *thisitem; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2515 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2516 /* Query the objects */ |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2517 if([ object isKindOfClass:[ NSWindow class ] ]) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2518 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2519 NSWindow *window = box; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2520 view = [window contentView]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2521 } |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
2522 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2523 thisbox = [view box]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2524 thisitem = thisbox->items; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2525 object = item; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2526 |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2527 /* Query the objects */ |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2528 if([ object isKindOfClass:[ DWContainer class ] ]) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2529 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2530 DWContainer *cont = item; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2531 this = item = [cont scrollview]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2532 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2533 else if([ object isKindOfClass:[ DWTree class ] ]) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2534 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2535 DWTree *tree = item; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2536 this = item = [tree scrollview]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2537 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2538 |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2539 /* 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
|
2540 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
|
2541 |
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
2542 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
|
2543 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2544 tmpitem[z+1] = thisitem[z]; |
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 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2547 /* Sanity checks */ |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2548 if(vsize && !height) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2549 height = 1; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2550 if(hsize && !width) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2551 width = 1; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2552 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2553 /* Fill in the item data appropriately */ |
792
fc6a626a96cc
Initial groupbox support. Sizing of the content frame is not quite right yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
768
diff
changeset
|
2554 if([object isKindOfClass:[DWBox class]] || [object isMemberOfClass:[DWGroupBox class]]) |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2555 tmpitem[0].type = TYPEBOX; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2556 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2557 tmpitem[0].type = TYPEITEM; |
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 tmpitem[0].hwnd = item; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2560 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
|
2561 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
|
2562 tmpitem[0].pad = pad; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2563 if(hsize) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2564 tmpitem[0].hsize = SIZEEXPAND; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2565 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2566 tmpitem[0].hsize = SIZESTATIC; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2567 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2568 if(vsize) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2569 tmpitem[0].vsize = SIZEEXPAND; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2570 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2571 tmpitem[0].vsize = SIZESTATIC; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2572 |
666
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
2573 thisbox->items = tmpitem; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2574 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2575 /* 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
|
2576 thisbox->count++; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2577 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2578 /* Add the item to the box */ |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2579 [view addSubview:this]; |
793
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
2580 /* If we are packing a button... */ |
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
2581 if([this isMemberOfClass:[DWButton class]]) |
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
2582 { |
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
2583 DWButton *button = (DWButton *)this; |
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
2584 |
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
2585 /* Save the parent box so radio |
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
2586 * buttons can use it later. |
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
2587 */ |
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
2588 [button setParent:view]; |
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
2589 } |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
2590 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2591 /* 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
|
2592 if(thisbox->count) |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2593 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
|
2594 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2595 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2596 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2597 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2598 * 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
|
2599 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2600 * 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
|
2601 * 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
|
2602 * 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
|
2603 * 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
|
2604 * 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
|
2605 * 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
|
2606 * 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
|
2607 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2608 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
|
2609 { |
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
|
2610 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
|
2611 DW_MUTEX_LOCK; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2612 NSObject *object = box; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2613 DWBox *view = box; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2614 DWBox *this = item; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2615 Box *thisbox; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2616 int z; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2617 Item *tmpitem, *thisitem; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2618 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2619 /* Query the objects */ |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2620 if([ object isKindOfClass:[ NSWindow class ] ]) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2621 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2622 NSWindow *window = box; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2623 view = [window contentView]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2624 } |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
2625 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2626 thisbox = [view box]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2627 thisitem = thisbox->items; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2628 object = item; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2629 |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2630 /* Query the objects */ |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2631 if([ object isKindOfClass:[ DWContainer class ] ]) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2632 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2633 DWContainer *cont = item; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2634 this = item = [cont scrollview]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2635 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2636 else if([ object isKindOfClass:[ DWTree class ] ]) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2637 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2638 DWTree *tree = item; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2639 this = item = [tree scrollview]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2640 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2641 |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2642 /* 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
|
2643 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
|
2644 |
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
2645 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
|
2646 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2647 tmpitem[z] = thisitem[z]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2648 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2649 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2650 /* Sanity checks */ |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2651 if(vsize && !height) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2652 height = 1; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2653 if(hsize && !width) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2654 width = 1; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2655 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2656 /* Fill in the item data appropriately */ |
792
fc6a626a96cc
Initial groupbox support. Sizing of the content frame is not quite right yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
768
diff
changeset
|
2657 if([object isKindOfClass:[DWBox class]] || [object isMemberOfClass:[DWGroupBox 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
|
2658 tmpitem[thisbox->count].type = TYPEBOX; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2659 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
|
2660 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
|
2661 |
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
2662 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
|
2663 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
|
2664 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
|
2665 tmpitem[thisbox->count].pad = pad; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2666 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
|
2667 tmpitem[thisbox->count].hsize = SIZEEXPAND; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2668 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
|
2669 tmpitem[thisbox->count].hsize = SIZESTATIC; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2670 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2671 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
|
2672 tmpitem[thisbox->count].vsize = SIZEEXPAND; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2673 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
|
2674 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
|
2675 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2676 thisbox->items = tmpitem; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2677 |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2678 /* 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
|
2679 thisbox->count++; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2680 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2681 /* Add the item to the box */ |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2682 [view addSubview:this]; |
793
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
2683 /* If we are packing a button... */ |
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
2684 if([this isMemberOfClass:[DWButton class]]) |
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
2685 { |
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
2686 DWButton *button = (DWButton *)this; |
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
2687 |
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
2688 /* Save the parent box so radio |
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
2689 * buttons can use it later. |
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
2690 */ |
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
2691 [button setParent:view]; |
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
2692 } |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
2693 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2694 /* 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
|
2695 if(thisbox->count) |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2696 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
|
2697 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2698 } |
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 _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
|
2701 { |
744
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
2702 DWButton *button = [[DWButton alloc] init]; |
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
2703 if(text && *text) |
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
2704 { |
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
2705 [button setTitle:[ NSString stringWithUTF8String:text ]]; |
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
2706 } |
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
2707 [button setTarget:button]; |
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
2708 [button setAction:@selector(buttonClicked:)]; |
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
2709 [button setTag:cid]; |
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
2710 [button setButtonType:NSMomentaryPushInButton]; |
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
2711 [button setBezelStyle:NSThickerSquareBezelStyle]; |
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
2712 if(DWDefaultFont) |
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
2713 { |
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
2714 [[button cell] setFont:DWDefaultFont]; |
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
2715 } |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2716 return button; |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2717 } |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2718 |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2719 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2720 * 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
|
2721 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2722 * 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
|
2723 * 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
|
2724 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
2725 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
|
2726 { |
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
2727 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
|
2728 [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
|
2729 [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
|
2730 [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
|
2731 [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
|
2732 [[button cell] setControlTint:NSBlueControlTint]; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2733 return button; |
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 Entryfield 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 * 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
|
2740 * 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
|
2741 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
2742 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
|
2743 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2744 DWEntryField *entry = [[DWEntryField alloc] init]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2745 [entry setStringValue:[ NSString stringWithUTF8String:text ]]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2746 [entry setTag:cid]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2747 return entry; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2748 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2749 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2750 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2751 * 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
|
2752 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2753 * 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
|
2754 * 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
|
2755 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
2756 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
|
2757 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2758 DWEntryFieldPassword *entry = [[DWEntryFieldPassword alloc] init]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2759 [entry setStringValue:[ NSString stringWithUTF8String:text ]]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2760 [entry setTag:cid]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2761 return entry; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2762 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2763 |
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 * Sets the entryfield character limit. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2766 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2767 * 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
|
2768 * 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
|
2769 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2770 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
|
2771 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2772 NSLog(@"dw_entryfield_set_limit() unimplemented\n"); |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2773 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2774 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2775 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2776 * 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
|
2777 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2778 * 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
|
2779 * 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
|
2780 */ |
670
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
2781 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
|
2782 { |
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
2783 NSBundle *bundle = [NSBundle mainBundle]; |
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
2784 NSString *respath = [bundle resourcePath]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2785 NSString *filepath = [respath stringByAppendingFormat:@"/%u.png", resid]; |
749 | 2786 NSImage *image = [[NSImage alloc] initWithContentsOfFile:filepath]; |
2787 DWButton *button = _button_new("", resid); | |
748
f39745844175
Added tooltips to bitmap buttons... and made a change to the look when the image is present...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
747
diff
changeset
|
2788 if(image) |
f39745844175
Added tooltips to bitmap buttons... and made a change to the look when the image is present...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
747
diff
changeset
|
2789 { |
f39745844175
Added tooltips to bitmap buttons... and made a change to the look when the image is present...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
747
diff
changeset
|
2790 [button setImage:image]; |
f39745844175
Added tooltips to bitmap buttons... and made a change to the look when the image is present...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
747
diff
changeset
|
2791 } |
f39745844175
Added tooltips to bitmap buttons... and made a change to the look when the image is present...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
747
diff
changeset
|
2792 [button setToolTip:[NSString stringWithUTF8String:text]]; |
670
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
2793 [image release]; |
749 | 2794 return button; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2795 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2796 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2797 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2798 * 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
|
2799 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2800 * 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
|
2801 * 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
|
2802 * 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
|
2803 * DW pick the appropriate file extension. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2804 * (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
|
2805 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
2806 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
|
2807 { |
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
|
2808 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
|
2809 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
|
2810 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
|
2811 { |
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
|
2812 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
|
2813 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
|
2814 } |
749 | 2815 DWButton *button = _button_new("", cid); |
748
f39745844175
Added tooltips to bitmap buttons... and made a change to the look when the image is present...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
747
diff
changeset
|
2816 if(image) |
f39745844175
Added tooltips to bitmap buttons... and made a change to the look when the image is present...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
747
diff
changeset
|
2817 { |
f39745844175
Added tooltips to bitmap buttons... and made a change to the look when the image is present...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
747
diff
changeset
|
2818 [button setImage:image]; |
f39745844175
Added tooltips to bitmap buttons... and made a change to the look when the image is present...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
747
diff
changeset
|
2819 } |
f39745844175
Added tooltips to bitmap buttons... and made a change to the look when the image is present...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
747
diff
changeset
|
2820 [button setToolTip:[NSString stringWithUTF8String:text]]; |
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
|
2821 [image release]; |
749 | 2822 return button; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2823 } |
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 * 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
|
2827 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2828 * 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
|
2829 * 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
|
2830 * data: The contents of the image |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2831 * (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
|
2832 * len: length of str |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2833 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
2834 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
|
2835 { |
760
2fb17622a455
Possible fix for exception in dw_bitmapbutton_new_from_data()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
755
diff
changeset
|
2836 NSData *thisdata = [NSData dataWithBytes:data length:len]; |
749 | 2837 NSImage *image = [[NSImage alloc] initWithData:thisdata]; |
2838 DWButton *button = _button_new("", cid); | |
748
f39745844175
Added tooltips to bitmap buttons... and made a change to the look when the image is present...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
747
diff
changeset
|
2839 if(image) |
f39745844175
Added tooltips to bitmap buttons... and made a change to the look when the image is present...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
747
diff
changeset
|
2840 { |
f39745844175
Added tooltips to bitmap buttons... and made a change to the look when the image is present...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
747
diff
changeset
|
2841 [button setImage:image]; |
f39745844175
Added tooltips to bitmap buttons... and made a change to the look when the image is present...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
747
diff
changeset
|
2842 } |
f39745844175
Added tooltips to bitmap buttons... and made a change to the look when the image is present...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
747
diff
changeset
|
2843 [button setToolTip:[NSString stringWithUTF8String:text]]; |
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
|
2844 [image release]; |
749 | 2845 return button; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2846 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2847 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2848 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2849 * 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
|
2850 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2851 * 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
|
2852 * 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
|
2853 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
2854 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
|
2855 { |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
2856 DWSpinButton *spinbutton = [[DWSpinButton alloc] init]; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2857 NSStepper *stepper = [spinbutton stepper]; |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
2858 [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
|
2859 [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
|
2860 return spinbutton; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2861 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2862 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2863 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2864 * Sets the spinbutton value. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2865 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2866 * 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
|
2867 * position: Current value of the spinbutton. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2868 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2869 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
|
2870 { |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
2871 DWSpinButton *spinbutton = handle; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2872 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
|
2873 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
|
2874 [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
|
2875 [textfield takeIntValueFrom:stepper]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2876 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2877 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2878 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2879 * Sets the spinbutton limits. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2880 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2881 * 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
|
2882 * upper: Upper limit. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2883 * lower: Lower limit. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2884 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2885 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
|
2886 { |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
2887 DWSpinButton *spinbutton = handle; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2888 NSStepper *stepper = [spinbutton stepper]; |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
2889 [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
|
2890 [stepper setMaxValue:(double)upper]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2891 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2892 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2893 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2894 * 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
|
2895 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2896 * 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
|
2897 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2898 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
|
2899 { |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
2900 DWSpinButton *spinbutton = handle; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2901 NSStepper *stepper = [spinbutton stepper]; |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
2902 return (long)[stepper integerValue]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2903 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2904 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2905 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2906 * 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
|
2907 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2908 * 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
|
2909 * 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
|
2910 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
2911 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
|
2912 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2913 DWButton *button = _button_new(text, cid); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2914 [button setButtonType:NSRadioButton]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2915 return button; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2916 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2917 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2918 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2919 * 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
|
2920 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2921 * 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
|
2922 * increments: Number of increments available. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2923 * 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
|
2924 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
2925 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
|
2926 { |
704
336800e9e648
Fixes to the slider control so events happen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
703
diff
changeset
|
2927 DWSlider *slider = [[DWSlider alloc] init]; |
336800e9e648
Fixes to the slider control so events happen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
703
diff
changeset
|
2928 [slider setMaxValue:(double)increments]; |
336800e9e648
Fixes to the slider control so events happen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
703
diff
changeset
|
2929 [slider setMinValue:0]; |
336800e9e648
Fixes to the slider control so events happen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
703
diff
changeset
|
2930 [slider setContinuous:YES]; |
336800e9e648
Fixes to the slider control so events happen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
703
diff
changeset
|
2931 [slider setTarget:slider]; |
336800e9e648
Fixes to the slider control so events happen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
703
diff
changeset
|
2932 [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
|
2933 [slider setTag:cid]; |
704
336800e9e648
Fixes to the slider control so events happen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
703
diff
changeset
|
2934 return slider; |
650
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 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2937 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2938 * Returns the position of the slider. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2939 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2940 * 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
|
2941 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2942 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
|
2943 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2944 DWSlider *slider = handle; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2945 double val = [slider doubleValue]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2946 return (int)val; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2947 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2948 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2949 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2950 * Sets the slider position. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2951 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2952 * 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
|
2953 * 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
|
2954 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2955 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
|
2956 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2957 DWSlider *slider = handle; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2958 [slider setDoubleValue:(double)position]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2959 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2960 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2961 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2962 * 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
|
2963 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2964 * 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
|
2965 * increments: Number of increments available. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2966 * 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
|
2967 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
2968 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
|
2969 { |
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
|
2970 DWScrollbar *scrollbar; |
689
4199730e9889
Fixed errors creating scrollbars.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
688
diff
changeset
|
2971 if(vertical) |
4199730e9889
Fixed errors creating scrollbars.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
688
diff
changeset
|
2972 { |
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
|
2973 scrollbar = [[DWScrollbar alloc] init]; |
689
4199730e9889
Fixed errors creating scrollbars.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
688
diff
changeset
|
2974 } |
4199730e9889
Fixed errors creating scrollbars.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
688
diff
changeset
|
2975 else |
4199730e9889
Fixed errors creating scrollbars.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
688
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 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
|
2978 } |
4199730e9889
Fixed errors creating scrollbars.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
688
diff
changeset
|
2979 [scrollbar setArrowsPosition:NSScrollerArrowsDefaultSetting]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2980 [scrollbar setTarget:scrollbar]; |
689
4199730e9889
Fixed errors creating scrollbars.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
688
diff
changeset
|
2981 [scrollbar setAction:@selector(changed:)]; |
4199730e9889
Fixed errors creating scrollbars.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
688
diff
changeset
|
2982 [scrollbar setRange:0.0 andVisible:0.0]; |
4199730e9889
Fixed errors creating scrollbars.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
688
diff
changeset
|
2983 [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
|
2984 [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
|
2985 [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
|
2986 [scrollbar setTag:cid]; |
689
4199730e9889
Fixed errors creating scrollbars.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
688
diff
changeset
|
2987 [scrollbar setEnabled:YES]; |
4199730e9889
Fixed errors creating scrollbars.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
688
diff
changeset
|
2988 return scrollbar; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2989 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2990 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2991 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2992 * Returns the position of the scrollbar. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2993 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2994 * 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
|
2995 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2996 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
|
2997 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2998 DWScrollbar *scrollbar = handle; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2999 float range = [scrollbar range]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3000 float fresult = [scrollbar doubleValue] * range; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3001 return (int)fresult; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3002 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3003 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3004 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3005 * Sets the scrollbar position. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3006 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3007 * 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
|
3008 * 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
|
3009 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3010 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
|
3011 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3012 DWScrollbar *scrollbar = handle; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3013 double range = (double)[scrollbar range]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3014 double newpos = (double)position/range; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3015 [scrollbar setDoubleValue:newpos]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3016 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3017 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3018 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3019 * Sets the scrollbar range. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3020 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3021 * 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
|
3022 * range: Maximum range value. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3023 * 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
|
3024 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3025 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
|
3026 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3027 DWScrollbar *scrollbar = handle; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3028 float knob = (float)visible/(float)range; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3029 [scrollbar setRange:(float)range andVisible:(float)visible]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3030 [scrollbar setKnobProportion:knob]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3031 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3032 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3033 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3034 * 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
|
3035 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3036 * 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
|
3037 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
3038 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
|
3039 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3040 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
|
3041 [percent setStyle:NSProgressIndicatorBarStyle]; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3042 [percent setBezeled:YES]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3043 [percent setMaxValue:100]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3044 [percent setMinValue:0]; |
714
cf6246f86c04
Fixed the percent/progress indicators from always being indeterminate.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
713
diff
changeset
|
3045 [percent incrementBy:1]; |
cf6246f86c04
Fixed the percent/progress indicators from always being indeterminate.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
713
diff
changeset
|
3046 [percent setIndeterminate:NO]; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3047 /*[percent setTag:cid]; Why doesn't this work? */ |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3048 return percent; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3049 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3050 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3051 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3052 * Sets the percent bar position. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3053 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3054 * 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
|
3055 * 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
|
3056 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3057 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
|
3058 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3059 DWPercent *percent = handle; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3060 [percent setDoubleValue:(double)position]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3061 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3062 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3063 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3064 * 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
|
3065 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3066 * 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
|
3067 * 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
|
3068 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
3069 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
|
3070 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3071 DWButton *button = _button_new(text, cid); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3072 [button setButtonType:NSSwitchButton]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3073 [button setBezelStyle:NSRegularSquareBezelStyle]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3074 return button; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3075 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3076 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3077 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3078 * Returns the state of the checkbox. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3079 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3080 * 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
|
3081 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3082 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
|
3083 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3084 DWButton *button = handle; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3085 if([button state]) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3086 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3087 return TRUE; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3088 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3089 return FALSE; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3090 } |
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 * Sets the state of the checkbox. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3094 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3095 * 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
|
3096 * 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
|
3097 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3098 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
|
3099 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3100 DWButton *button = handle; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3101 if(value) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3102 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3103 [button setState:NSOnState]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3104 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3105 else |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3106 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3107 [button setState:NSOffState]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3108 } |
656
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3109 |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3110 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3111 |
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
|
3112 /* 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
|
3113 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
|
3114 { |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
3115 NSScrollView *scrollview = [[NSScrollView alloc] init]; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3116 DWContainer *cont = [[DWContainer alloc] init]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
3117 |
668
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
3118 [cont setScrollview:scrollview]; |
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
3119 [scrollview setBorderType:NSBezelBorder]; |
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
3120 [scrollview setHasVerticalScroller:YES]; |
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
3121 [scrollview setAutohidesScrollers:YES]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
3122 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3123 if(multi) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3124 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3125 [cont setAllowsMultipleSelection:YES]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3126 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3127 else |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3128 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3129 [cont setAllowsMultipleSelection:NO]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3130 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3131 [cont setDataSource:cont]; |
668
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
3132 [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
|
3133 [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
|
3134 [scrollview release]; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3135 return cont; |
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
|
3136 } |
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
3137 |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3138 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3139 * 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
|
3140 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3141 * 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
|
3142 * multi: Multiple select TRUE or FALSE. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3143 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
3144 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
|
3145 { |
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
|
3146 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
|
3147 DW_MUTEX_LOCK; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3148 DWContainer *cont = _cont_new(cid, multi); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3149 [cont setHeaderView:nil]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3150 int type = DW_CFA_STRING; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3151 [cont setup]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3152 NSTableColumn *column = [[NSTableColumn alloc] init]; |
795
f23cad02cfb3
Make listbox, container and tree cells uneditable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
794
diff
changeset
|
3153 [column setEditable:NO]; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3154 [cont addTableColumn:column]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3155 [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
|
3156 [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
|
3157 DW_MUTEX_UNLOCK; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3158 return cont; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3159 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3160 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3161 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3162 * 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
|
3163 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3164 * 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
|
3165 * text: Text to append into listbox. |
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 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
|
3168 { |
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
|
3169 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
|
3170 DW_MUTEX_LOCK; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3171 id object = handle; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
3172 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3173 if([object isMemberOfClass:[DWComboBox class]]) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3174 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3175 DWComboBox *combo = handle; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
3176 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3177 [combo addItemWithObjectValue:[ NSString stringWithUTF8String:text ]]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3178 } |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3179 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
|
3180 { |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3181 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
|
3182 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
|
3183 NSArray *newrow = [NSArray arrayWithObject:nstr]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
3184 |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3185 [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
|
3186 /*[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
|
3187 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
|
3188 waitUntilDone:YES];*/ |
670
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
3189 [cont reloadData]; |
794
e9bc14c5c72d
Test fix for containers (and probably listboxes) not showing their content changes immediately.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
793
diff
changeset
|
3190 [cont setNeedsDisplay:YES]; |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3191 } |
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
|
3192 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3193 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3194 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3195 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3196 * 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
|
3197 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3198 * 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
|
3199 * text: Text to insert into listbox. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3200 * 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
|
3201 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3202 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
|
3203 { |
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
|
3204 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
|
3205 DW_MUTEX_LOCK; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3206 id object = handle; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
3207 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3208 if([object isMemberOfClass:[DWComboBox class]]) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3209 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3210 DWComboBox *combo = handle; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
3211 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3212 [combo insertItemWithObjectValue:[ NSString stringWithUTF8String:text ] atIndex:pos]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3213 } |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3214 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
|
3215 { |
687
5dde8d34bc69
Implemented dw_listbox_insert for containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
686
diff
changeset
|
3216 DWContainer *cont = handle; |
5dde8d34bc69
Implemented dw_listbox_insert for containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
686
diff
changeset
|
3217 NSString *nstr = [ NSString stringWithUTF8String:text ]; |
5dde8d34bc69
Implemented dw_listbox_insert for containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
686
diff
changeset
|
3218 NSArray *newrow = [NSArray arrayWithObject:nstr]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
3219 |
687
5dde8d34bc69
Implemented dw_listbox_insert for containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
686
diff
changeset
|
3220 [cont insertRow:newrow at:pos]; |
5dde8d34bc69
Implemented dw_listbox_insert for containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
686
diff
changeset
|
3221 [cont reloadData]; |
794
e9bc14c5c72d
Test fix for containers (and probably listboxes) not showing their content changes immediately.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
793
diff
changeset
|
3222 [cont setNeedsDisplay:YES]; |
669
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 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3225 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3226 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3227 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3228 * 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
|
3229 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3230 * 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
|
3231 * 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
|
3232 * 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
|
3233 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3234 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
|
3235 { |
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
|
3236 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
|
3237 DW_MUTEX_LOCK; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3238 id object = handle; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
3239 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3240 if([object isMemberOfClass:[DWComboBox class]]) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3241 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3242 DWComboBox *combo = handle; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3243 int z; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
3244 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3245 for(z=0;z<count;z++) |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
3246 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3247 [combo addItemWithObjectValue:[ NSString stringWithUTF8String:text[z] ]]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3248 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3249 } |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3250 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
|
3251 { |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3252 DWContainer *cont = handle; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3253 int z; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
3254 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3255 for(z=0;z<count;z++) |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
3256 { |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3257 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
|
3258 NSArray *newrow = [[NSArray alloc] arrayWithObject:nstr]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
3259 |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3260 [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
|
3261 } |
670
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
3262 [cont reloadData]; |
794
e9bc14c5c72d
Test fix for containers (and probably listboxes) not showing their content changes immediately.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
793
diff
changeset
|
3263 [cont setNeedsDisplay:YES]; |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3264 } |
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
|
3265 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3266 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3267 |
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 * 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
|
3270 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3271 * 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
|
3272 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3273 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
|
3274 { |
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
|
3275 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
|
3276 DW_MUTEX_LOCK; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3277 id object = handle; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
3278 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3279 if([object isMemberOfClass:[DWComboBox class]]) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3280 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3281 DWComboBox *combo = handle; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
3282 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3283 [combo removeAllItems]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3284 } |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3285 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
|
3286 { |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3287 DWContainer *cont = handle; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
3288 |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3289 [cont clear]; |
670
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
3290 [cont reloadData]; |
794
e9bc14c5c72d
Test fix for containers (and probably listboxes) not showing their content changes immediately.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
793
diff
changeset
|
3291 [cont setNeedsDisplay:YES]; |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3292 } |
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
|
3293 DW_MUTEX_UNLOCK; |
650
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 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3296 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3297 * Returns the listbox's item count. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3298 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3299 * 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
|
3300 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3301 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
|
3302 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3303 id object = handle; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
3304 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3305 if([object isMemberOfClass:[DWComboBox class]]) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3306 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3307 DWComboBox *combo = handle; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
3308 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3309 return (int)[combo numberOfItems]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3310 } |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3311 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
|
3312 { |
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
|
3313 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
|
3314 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
|
3315 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
|
3316 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
|
3317 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
|
3318 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
|
3319 } |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3320 return 0; |
650
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 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3324 * 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
|
3325 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3326 * 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
|
3327 * top: Index to the top item. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3328 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3329 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
|
3330 { |
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
|
3331 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
|
3332 DW_MUTEX_LOCK; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3333 id object = handle; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
3334 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3335 if([object isMemberOfClass:[DWComboBox class]]) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3336 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3337 DWComboBox *combo = handle; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
3338 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3339 [combo scrollItemAtIndexToTop:top]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3340 } |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3341 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
|
3342 { |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3343 DWContainer *cont = handle; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
3344 |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3345 [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
|
3346 } |
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
|
3347 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3348 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3349 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3350 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3351 * 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
|
3352 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3353 * 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
|
3354 * 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
|
3355 * 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
|
3356 * 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
|
3357 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3358 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
|
3359 { |
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
|
3360 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
|
3361 DW_MUTEX_LOCK; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3362 id object = handle; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
3363 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3364 if([object isMemberOfClass:[DWComboBox class]]) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3365 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3366 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
|
3367 int count = (int)[combo numberOfItems]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
3368 |
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
|
3369 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
|
3370 { |
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
|
3371 *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
|
3372 } |
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
|
3373 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
|
3374 { |
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
|
3375 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
|
3376 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
|
3377 } |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3378 } |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3379 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
|
3380 { |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3381 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
|
3382 int count = (int)[cont numberOfRowsInTableView:cont]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
3383 |
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
|
3384 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
|
3385 { |
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
|
3386 *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
|
3387 } |
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
|
3388 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
|
3389 { |
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
|
3390 NSString *nstr = [cont getRow:index and:0]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
3391 |
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
|
3392 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
|
3393 } |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3394 } |
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
|
3395 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3396 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3397 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3398 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3399 * 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
|
3400 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3401 * 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
|
3402 * 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
|
3403 * 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
|
3404 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3405 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
|
3406 { |
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
|
3407 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
|
3408 DW_MUTEX_LOCK; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3409 id object = handle; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
3410 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3411 if([object isMemberOfClass:[DWComboBox class]]) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3412 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3413 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
|
3414 int count = (int)[combo numberOfItems]; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
3415 |
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
|
3416 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
|
3417 { |
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
|
3418 [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
|
3419 [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
|
3420 } |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3421 } |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3422 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
|
3423 { |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3424 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
|
3425 int count = (int)[cont numberOfRowsInTableView:cont]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
3426 |
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
|
3427 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
|
3428 { |
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
|
3429 NSString *nstr = [ NSString stringWithUTF8String:buffer ]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
3430 |
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
|
3431 [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
|
3432 [cont reloadData]; |
794
e9bc14c5c72d
Test fix for containers (and probably listboxes) not showing their content changes immediately.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
793
diff
changeset
|
3433 [cont setNeedsDisplay:YES]; |
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
|
3434 } |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3435 } |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
3436 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3437 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3438 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3439 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3440 * 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
|
3441 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3442 * 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
|
3443 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3444 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
|
3445 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3446 id object = handle; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
3447 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3448 if([object isMemberOfClass:[DWComboBox class]]) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3449 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3450 DWComboBox *combo = handle; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3451 return (int)[combo indexOfSelectedItem]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3452 } |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3453 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
|
3454 { |
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
|
3455 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
|
3456 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
|
3457 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
|
3458 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
|
3459 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
|
3460 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
|
3461 } |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3462 return -1; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3463 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3464 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3465 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3466 * 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
|
3467 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3468 * 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
|
3469 * 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
|
3470 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3471 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
|
3472 { |
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
|
3473 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
|
3474 DW_MUTEX_LOCK; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3475 id object = handle; |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3476 int retval = -1; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
3477 |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3478 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
|
3479 { |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3480 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
|
3481 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
|
3482 NSUInteger result = [selected indexGreaterThanIndex:where]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
3483 |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3484 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
|
3485 { |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3486 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
|
3487 } |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
3488 } |
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
|
3489 DW_MUTEX_UNLOCK; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3490 return retval; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3491 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3492 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3493 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3494 * 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
|
3495 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3496 * 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
|
3497 * index: Item index. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3498 * 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
|
3499 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3500 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
|
3501 { |
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
|
3502 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
|
3503 DW_MUTEX_LOCK; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3504 id object = handle; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
3505 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3506 if([object isMemberOfClass:[DWComboBox class]]) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3507 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3508 DWComboBox *combo = handle; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3509 if(state) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3510 [combo selectItemAtIndex:index]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3511 else |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3512 [combo deselectItemAtIndex:index]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3513 } |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3514 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
|
3515 { |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3516 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
|
3517 NSIndexSet *selected = [[NSIndexSet alloc] initWithIndex:(NSUInteger)index]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
3518 |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3519 [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
|
3520 [selected release]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
3521 } |
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
|
3522 DW_MUTEX_UNLOCK; |
650
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 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3525 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3526 * 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
|
3527 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3528 * 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
|
3529 * index: Item index. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3530 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3531 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
|
3532 { |
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
|
3533 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
|
3534 DW_MUTEX_LOCK; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3535 id object = handle; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
3536 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3537 if([object isMemberOfClass:[DWComboBox class]]) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3538 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3539 DWComboBox *combo = handle; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
3540 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3541 [combo removeItemAtIndex:index]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3542 } |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3543 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
|
3544 { |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3545 DWContainer *cont = handle; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
3546 |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3547 [cont removeRow:index]; |
670
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
3548 [cont reloadData]; |
794
e9bc14c5c72d
Test fix for containers (and probably listboxes) not showing their content changes immediately.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
793
diff
changeset
|
3549 [cont setNeedsDisplay:YES]; |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3550 } |
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
|
3551 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3552 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3553 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3554 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3555 * 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
|
3556 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3557 * 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
|
3558 * 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
|
3559 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
3560 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
|
3561 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3562 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
|
3563 [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
|
3564 [combo setTag:cid]; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3565 return combo; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3566 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3567 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3568 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3569 * 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
|
3570 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3571 * 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
|
3572 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
3573 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
|
3574 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3575 DWMLE *mle = [[DWMLE alloc] init]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
3576 NSScrollView *scrollview = [[NSScrollView alloc] init]; |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
3577 |
676
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
3578 [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
|
3579 [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
|
3580 [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
|
3581 [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
|
3582 [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
|
3583 [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
|
3584 /* [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
|
3585 [mle release]; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3586 return scrollview; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
3587 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3588 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3589 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3590 * 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
|
3591 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3592 * 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
|
3593 * buffer: Text buffer to be imported. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3594 * startpoint: Point to start entering text. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3595 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3596 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
|
3597 { |
676
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
3598 NSScrollView *sv = handle; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3599 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
|
3600 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
|
3601 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
|
3602 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
|
3603 [ms insertString:nstr atIndex:(startpoint+1)]; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3604 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
|
3605 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3606 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3607 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3608 * Grabs text from an MLE box. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3609 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3610 * 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
|
3611 * buffer: Text buffer to be exported. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3612 * startpoint: Point to start grabbing text. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3613 * 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
|
3614 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3615 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
|
3616 { |
676
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
3617 NSScrollView *sv = handle; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3618 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
|
3619 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
|
3620 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
|
3621 strncpy(buffer, [ms UTF8String], length); |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3622 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3623 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3624 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3625 * Obtains information about an MLE box. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3626 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3627 * 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
|
3628 * 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
|
3629 * 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
|
3630 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3631 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
|
3632 { |
676
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
3633 NSScrollView *sv = handle; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3634 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
|
3635 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
|
3636 NSMutableString *ms = [ts mutableString]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
3637 |
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
|
3638 *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
|
3639 *lines = 0; /* TODO: Line count */ |
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 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3643 * Deletes text from an MLE box. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3644 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3645 * 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
|
3646 * startpoint: Point to start deleting text. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3647 * 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
|
3648 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3649 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
|
3650 { |
676
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
3651 NSScrollView *sv = handle; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3652 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
|
3653 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
|
3654 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
|
3655 [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
|
3656 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3657 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3658 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3659 * 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
|
3660 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3661 * 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
|
3662 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3663 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
|
3664 { |
676
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
3665 NSScrollView *sv = handle; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3666 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
|
3667 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
|
3668 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
|
3669 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
|
3670 [ms deleteCharactersInRange:NSMakeRange(0, length)]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3671 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3672 |
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 * 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
|
3675 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3676 * 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
|
3677 * line: Line to be visible. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3678 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3679 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
|
3680 { |
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
|
3681 /*NSScrollView *sv = handle; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3682 DWMLE *mle = [sv documentView]; |
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
|
3683 [mle scrollrangeToVisible:NSMakeRange(0,13)];*/ |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3684 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
|
3685 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3686 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3687 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3688 * 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
|
3689 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3690 * handle: Handle to the MLE. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3691 * 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
|
3692 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3693 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
|
3694 { |
676
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
3695 NSScrollView *sv = handle; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3696 DWMLE *mle = [sv documentView]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3697 if(state) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3698 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3699 [mle setEditable:YES]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3700 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3701 else |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3702 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3703 [mle setEditable:NO]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3704 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3705 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3706 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3707 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3708 * 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
|
3709 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3710 * handle: Handle to the MLE. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3711 * 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
|
3712 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3713 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
|
3714 { |
676
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
3715 NSScrollView *sv = handle; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3716 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
|
3717 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
|
3718 { |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
3719 [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
|
3720 } |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
3721 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
|
3722 { |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
3723 [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
|
3724 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3725 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3726 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3727 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3728 * 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
|
3729 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3730 * 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
|
3731 * point: Point to position cursor. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3732 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3733 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
|
3734 { |
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
|
3735 NSScrollView *sv = handle; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3736 DWMLE *mle = [sv documentView]; |
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
|
3737 [mle setSelectedRange: NSMakeRange(point,point)]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3738 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3739 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3740 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3741 * Finds text in an MLE box. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3742 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3743 * 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
|
3744 * text: Text to search for. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3745 * point: Start point of search. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3746 * flags: Search specific flags. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3747 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3748 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
|
3749 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3750 NSLog(@"dw_mle_search() unimplemented\n"); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3751 return 0; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3752 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3753 |
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 * Stops redrawing of an MLE box. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3756 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3757 * 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
|
3758 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3759 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
|
3760 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3761 /* 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
|
3762 } |
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 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3765 * Resumes redrawing of an MLE box. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3766 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3767 * 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
|
3768 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3769 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
|
3770 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3771 /* 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
|
3772 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3773 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3774 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3775 * 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
|
3776 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3777 * 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
|
3778 * 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
|
3779 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
3780 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
|
3781 { |
751
eba6ab48c952
Runtime Snow Leopard checks where possible and visual fix for Leopard status text.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
749
diff
changeset
|
3782 NSTextField *textfield = dw_text_new(text, cid); |
eba6ab48c952
Runtime Snow Leopard checks where possible and visual fix for Leopard status text.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
749
diff
changeset
|
3783 [textfield setBordered:YES]; |
eba6ab48c952
Runtime Snow Leopard checks where possible and visual fix for Leopard status text.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
749
diff
changeset
|
3784 if(DWOSMinor > 5) |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3785 { |
751
eba6ab48c952
Runtime Snow Leopard checks where possible and visual fix for Leopard status text.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
749
diff
changeset
|
3786 [textfield setBezeled:YES]; |
eba6ab48c952
Runtime Snow Leopard checks where possible and visual fix for Leopard status text.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
749
diff
changeset
|
3787 [textfield setBezelStyle:NSTextFieldSquareBezel]; |
eba6ab48c952
Runtime Snow Leopard checks where possible and visual fix for Leopard status text.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
749
diff
changeset
|
3788 } |
eba6ab48c952
Runtime Snow Leopard checks where possible and visual fix for Leopard status text.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
749
diff
changeset
|
3789 [textfield setBackgroundColor:[NSColor clearColor]]; |
673
6d0f0dc7ff7c
Some minor font fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
672
diff
changeset
|
3790 [textfield setDrawsBackground:NO]; |
751
eba6ab48c952
Runtime Snow Leopard checks where possible and visual fix for Leopard status text.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
749
diff
changeset
|
3791 return textfield; |
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 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3795 * 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
|
3796 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3797 * 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
|
3798 * 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
|
3799 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
3800 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
|
3801 { |
744
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
3802 NSTextField *textfield = [[NSTextField alloc] init]; |
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
3803 [textfield setEditable:NO]; |
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
3804 [textfield setSelectable:NO]; |
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
3805 [textfield setBordered:NO]; |
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
3806 [textfield setDrawsBackground:NO]; |
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
3807 [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
|
3808 [textfield setTag:cid]; |
744
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
3809 if(DWDefaultFont) |
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
3810 { |
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
3811 [[textfield cell] setFont:DWDefaultFont]; |
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
3812 } |
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
3813 return textfield; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3814 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3815 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3816 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3817 * 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
|
3818 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3819 * 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
|
3820 * Returns: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3821 * 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
|
3822 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
3823 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
|
3824 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3825 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
|
3826 /* [render setTag:cid]; Why doesn't this work? */ |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3827 return render; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3828 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3829 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3830 /* Sets the current foreground drawing color. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3831 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3832 * red: red value. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3833 * green: green value. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3834 * blue: blue value. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3835 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3836 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
|
3837 { |
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
|
3838 /* This may need to be thread specific */ |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3839 _foreground = _get_color(value); |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3840 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3841 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3842 /* Sets the current background drawing color. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3843 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3844 * red: red value. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3845 * green: green value. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3846 * blue: blue value. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3847 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3848 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
|
3849 { |
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
|
3850 /* This may need to be thread specific */ |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3851 _background = _get_color(value); |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3852 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3853 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3854 /* 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
|
3855 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3856 * value: current color |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3857 * Returns: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3858 * 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
|
3859 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3860 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
|
3861 { |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
3862 NSColor *color = [[NSColor colorWithDeviceRed: DW_RED_VALUE(value)/255.0 green: DW_GREEN_VALUE(value)/255.0 blue: DW_BLUE_VALUE(value)/255.0 alpha: 1] retain]; |
732
db3a173e487e
Fixes for the color chooser... it now works a single time. However...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
731
diff
changeset
|
3863 /* Create the Color Chooser Dialog class. */ |
733
8d5e5b89725f
Fixed the crashing issue with dw_color_choose() it now functions properly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
732
diff
changeset
|
3864 static DWColorChoose *colorDlg = nil; |
732
db3a173e487e
Fixes for the color chooser... it now works a single time. However...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
731
diff
changeset
|
3865 DWDialog *dialog; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
3866 |
733
8d5e5b89725f
Fixed the crashing issue with dw_color_choose() it now functions properly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
732
diff
changeset
|
3867 if(colorDlg) |
732
db3a173e487e
Fixes for the color chooser... it now works a single time. However...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
731
diff
changeset
|
3868 { |
db3a173e487e
Fixes for the color chooser... it now works a single time. However...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
731
diff
changeset
|
3869 dialog = [colorDlg dialog]; |
733
8d5e5b89725f
Fixed the crashing issue with dw_color_choose() it now functions properly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
732
diff
changeset
|
3870 /* If someone is already waiting just return */ |
8d5e5b89725f
Fixed the crashing issue with dw_color_choose() it now functions properly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
732
diff
changeset
|
3871 if(dialog) |
8d5e5b89725f
Fixed the crashing issue with dw_color_choose() it now functions properly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
732
diff
changeset
|
3872 { |
8d5e5b89725f
Fixed the crashing issue with dw_color_choose() it now functions properly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
732
diff
changeset
|
3873 return value; |
8d5e5b89725f
Fixed the crashing issue with dw_color_choose() it now functions properly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
732
diff
changeset
|
3874 } |
732
db3a173e487e
Fixes for the color chooser... it now works a single time. However...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
731
diff
changeset
|
3875 } |
db3a173e487e
Fixes for the color chooser... it now works a single time. However...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
731
diff
changeset
|
3876 else |
db3a173e487e
Fixes for the color chooser... it now works a single time. However...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
731
diff
changeset
|
3877 { |
733
8d5e5b89725f
Fixed the crashing issue with dw_color_choose() it now functions properly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
732
diff
changeset
|
3878 colorDlg = (DWColorChoose *)[DWColorChoose sharedColorPanel]; |
732
db3a173e487e
Fixes for the color chooser... it now works a single time. However...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
731
diff
changeset
|
3879 /* Set defaults for the dialog. */ |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
3880 [colorDlg setContinuous:NO]; |
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
3881 [colorDlg setTarget:colorDlg]; |
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
3882 [colorDlg setAction:@selector(changeColor:)]; |
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
3883 } |
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
3884 |
733
8d5e5b89725f
Fixed the crashing issue with dw_color_choose() it now functions properly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
732
diff
changeset
|
3885 dialog = dw_dialog_new(colorDlg); |
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
|
3886 [colorDlg setColor:color]; |
733
8d5e5b89725f
Fixed the crashing issue with dw_color_choose() it now functions properly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
732
diff
changeset
|
3887 [colorDlg setDialog:dialog]; |
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
|
3888 [colorDlg makeKeyAndOrderFront:nil]; |
733
8d5e5b89725f
Fixed the crashing issue with dw_color_choose() it now functions properly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
732
diff
changeset
|
3889 |
732
db3a173e487e
Fixes for the color chooser... it now works a single time. However...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
731
diff
changeset
|
3890 /* Wait for them to pick a color */ |
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
|
3891 color = (NSColor *)dw_dialog_wait(dialog); |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
3892 |
732
db3a173e487e
Fixes for the color chooser... it now works a single time. However...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
731
diff
changeset
|
3893 /* Figure out the value of what they returned */ |
734
668a88a0b930
Fixed a minor 64/32 bit issue and fixed my having blue and red values reversed in the color table.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
733
diff
changeset
|
3894 CGFloat red, green, blue; |
732
db3a173e487e
Fixes for the color chooser... it now works a single time. However...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
731
diff
changeset
|
3895 [color getRed:&red green:&green blue:&blue alpha:NULL]; |
db3a173e487e
Fixes for the color chooser... it now works a single time. However...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
731
diff
changeset
|
3896 value = DW_RGB((int)(red * 255), (int)(green *255), (int)(blue *255)); |
db3a173e487e
Fixes for the color chooser... it now works a single time. However...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
731
diff
changeset
|
3897 return value; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3898 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3899 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3900 /* 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
|
3901 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3902 * handle: Handle to the window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3903 * 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
|
3904 * x: X coordinate. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3905 * y: Y coordinate. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3906 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3907 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
|
3908 { |
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
|
3909 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
|
3910 DW_MUTEX_LOCK; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3911 id image = handle; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3912 if(pixmap) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3913 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3914 image = (id)pixmap->image; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3915 [image lockFocus]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3916 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3917 else |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3918 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3919 if([image lockFocusIfCanDraw] == NO) |
747
a4f99795ff26
Abort drawing functions if we fail to lock focus on a render control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
745
diff
changeset
|
3920 { |
a4f99795ff26
Abort drawing functions if we fail to lock focus on a render control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
745
diff
changeset
|
3921 DW_MUTEX_UNLOCK; |
a4f99795ff26
Abort drawing functions if we fail to lock focus on a render control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
745
diff
changeset
|
3922 return; |
a4f99795ff26
Abort drawing functions if we fail to lock focus on a render control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
745
diff
changeset
|
3923 } |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3924 _DWLastDrawable = handle; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3925 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3926 NSBezierPath* aPath = [NSBezierPath bezierPath]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3927 [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
|
3928 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
|
3929 [color set]; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
3930 |
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
3931 [aPath moveToPoint:NSMakePoint(x, y)]; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3932 [aPath stroke]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3933 [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
|
3934 DW_MUTEX_UNLOCK; |
650
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 /* 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
|
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 window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3940 * 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
|
3941 * x1: First X coordinate. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3942 * y1: First Y coordinate. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3943 * x2: Second X coordinate. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3944 * y2: Second Y coordinate. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3945 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3946 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
|
3947 { |
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
|
3948 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
|
3949 DW_MUTEX_LOCK; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3950 id image = handle; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3951 if(pixmap) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3952 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3953 image = (id)pixmap->image; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3954 [image lockFocus]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3955 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3956 else |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3957 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3958 if([image lockFocusIfCanDraw] == NO) |
747
a4f99795ff26
Abort drawing functions if we fail to lock focus on a render control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
745
diff
changeset
|
3959 { |
a4f99795ff26
Abort drawing functions if we fail to lock focus on a render control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
745
diff
changeset
|
3960 DW_MUTEX_UNLOCK; |
a4f99795ff26
Abort drawing functions if we fail to lock focus on a render control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
745
diff
changeset
|
3961 return; |
a4f99795ff26
Abort drawing functions if we fail to lock focus on a render control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
745
diff
changeset
|
3962 } |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3963 _DWLastDrawable = handle; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3964 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3965 NSBezierPath* aPath = [NSBezierPath bezierPath]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3966 [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
|
3967 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
|
3968 [color set]; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
3969 |
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
3970 [aPath moveToPoint:NSMakePoint(x1, y1)]; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3971 [aPath lineToPoint:NSMakePoint(x2, y2)]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3972 [aPath stroke]; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
3973 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3974 [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
|
3975 DW_MUTEX_UNLOCK; |
650
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 /* 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
|
3979 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3980 * handle: Handle to the window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3981 * 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
|
3982 * x: X coordinate. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3983 * y: Y coordinate. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3984 * text: Text to be displayed. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3985 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3986 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
|
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; |
745
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
3990 id image = handle; |
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
3991 NSString *nstr = [ NSString stringWithUTF8String:text ]; |
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
3992 if(image) |
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
3993 { |
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
3994 if([image isMemberOfClass:[DWRender class]]) |
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
3995 { |
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
3996 DWRender *render = handle; |
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
3997 NSFont *font = [render font]; |
747
a4f99795ff26
Abort drawing functions if we fail to lock focus on a render control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
745
diff
changeset
|
3998 if([image lockFocusIfCanDraw] == NO) |
a4f99795ff26
Abort drawing functions if we fail to lock focus on a render control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
745
diff
changeset
|
3999 { |
a4f99795ff26
Abort drawing functions if we fail to lock focus on a render control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
745
diff
changeset
|
4000 DW_MUTEX_UNLOCK; |
a4f99795ff26
Abort drawing functions if we fail to lock focus on a render control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
745
diff
changeset
|
4001 return; |
a4f99795ff26
Abort drawing functions if we fail to lock focus on a render control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
745
diff
changeset
|
4002 } |
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
|
4003 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]; |
745
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
4004 NSMutableDictionary *dict = [[NSMutableDictionary alloc] initWithObjectsAndKeys:color, NSForegroundColorAttributeName, nil]; |
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
4005 if(font) |
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
4006 { |
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
4007 [dict setValue:font forKey:NSFontAttributeName]; |
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
4008 } |
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
4009 [nstr drawAtPoint:NSMakePoint(x, y) withAttributes:dict]; |
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
4010 [image unlockFocus]; |
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
4011 } |
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
4012 _DWLastDrawable = handle; |
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
4013 } |
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
4014 if(pixmap) |
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
4015 { |
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
4016 NSFont *font = nil; |
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
4017 DWRender *render = pixmap->handle; |
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
4018 if([render isMemberOfClass:[DWRender class]]) |
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
4019 { |
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
4020 font = [render font]; |
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
4021 } |
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
4022 image = (id)pixmap->image; |
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
4023 [image lockFocus]; |
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
4024 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]; |
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
4025 NSMutableDictionary *dict = [[NSMutableDictionary alloc] initWithObjectsAndKeys:color, NSForegroundColorAttributeName, nil]; |
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
4026 if(font) |
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
4027 { |
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
4028 [dict setValue:font forKey:NSFontAttributeName]; |
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
4029 } |
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
4030 [nstr drawAtPoint:NSMakePoint(x, y) withAttributes:dict]; |
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
4031 [image unlockFocus]; |
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
4032 } |
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
|
4033 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4034 } |
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 /* 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
|
4037 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4038 * handle: Handle to the window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4039 * 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
|
4040 * text: Text to be queried. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4041 * 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
|
4042 * 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
|
4043 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4044 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
|
4045 { |
745
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
4046 id image = handle; |
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
4047 id object = handle; |
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
4048 NSString *nstr = [NSString stringWithUTF8String:text]; |
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
4049 if(pixmap) |
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
4050 { |
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
4051 image = (id)pixmap->image; |
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
4052 object = pixmap->handle; |
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
4053 } |
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
4054 NSMutableDictionary *dict = [[NSMutableDictionary alloc] init]; |
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
4055 if([object isMemberOfClass:[DWRender class]]) |
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
4056 { |
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
4057 NSFont *font = [object font]; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
4058 |
745
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
4059 if(font) |
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
4060 { |
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
4061 [dict setValue:font forKey:NSFontAttributeName]; |
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
4062 } |
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
4063 } |
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
4064 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
|
4065 [dict release]; |
745
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
4066 if(width) |
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
4067 { |
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
4068 *width = size.width; |
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
4069 } |
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
4070 if(height) |
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
4071 { |
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
4072 *height = size.height; |
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
4073 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4074 } |
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 /* 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
|
4077 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4078 * handle: Handle to the window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4079 * 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
|
4080 * fill: Fill box TRUE or FALSE. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4081 * x: X coordinate. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4082 * y: Y coordinate. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4083 * width: Width of rectangle. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4084 * height: Height of rectangle. |
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 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
|
4087 { |
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
|
4088 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
|
4089 DW_MUTEX_LOCK; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4090 id image = handle; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4091 int z; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4092 if(pixmap) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4093 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4094 image = (id)pixmap->image; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4095 [image lockFocus]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4096 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4097 else |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4098 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4099 if([image lockFocusIfCanDraw] == NO) |
747
a4f99795ff26
Abort drawing functions if we fail to lock focus on a render control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
745
diff
changeset
|
4100 { |
a4f99795ff26
Abort drawing functions if we fail to lock focus on a render control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
745
diff
changeset
|
4101 DW_MUTEX_UNLOCK; |
a4f99795ff26
Abort drawing functions if we fail to lock focus on a render control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
745
diff
changeset
|
4102 return; |
a4f99795ff26
Abort drawing functions if we fail to lock focus on a render control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
745
diff
changeset
|
4103 } |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4104 _DWLastDrawable = handle; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4105 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4106 NSBezierPath* aPath = [NSBezierPath bezierPath]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4107 [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
|
4108 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
|
4109 [color set]; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
4110 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4111 [aPath moveToPoint:NSMakePoint(*x, *y)]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4112 for(z=1;z<npoints;z++) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4113 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4114 [aPath lineToPoint:NSMakePoint(x[z], y[z])]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4115 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4116 [aPath closePath]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4117 if(fill) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4118 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4119 [aPath fill]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4120 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4121 [aPath stroke]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4122 [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
|
4123 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4124 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4125 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4126 /* 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
|
4127 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4128 * handle: Handle to the window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4129 * 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
|
4130 * fill: Fill box TRUE or FALSE. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4131 * x: X coordinate. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4132 * y: Y coordinate. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4133 * width: Width of rectangle. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4134 * height: Height of rectangle. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4135 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4136 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
|
4137 { |
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
|
4138 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
|
4139 DW_MUTEX_LOCK; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4140 id image = handle; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4141 if(pixmap) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4142 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4143 image = (id)pixmap->image; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4144 [image lockFocus]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4145 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4146 else |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4147 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4148 if([image lockFocusIfCanDraw] == NO) |
747
a4f99795ff26
Abort drawing functions if we fail to lock focus on a render control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
745
diff
changeset
|
4149 { |
a4f99795ff26
Abort drawing functions if we fail to lock focus on a render control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
745
diff
changeset
|
4150 DW_MUTEX_UNLOCK; |
a4f99795ff26
Abort drawing functions if we fail to lock focus on a render control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
745
diff
changeset
|
4151 return; |
a4f99795ff26
Abort drawing functions if we fail to lock focus on a render control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
745
diff
changeset
|
4152 } |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4153 _DWLastDrawable = handle; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4154 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4155 NSBezierPath* aPath = [NSBezierPath bezierPath]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4156 [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
|
4157 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
|
4158 [color set]; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
4159 |
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
4160 [aPath moveToPoint:NSMakePoint(x, y)]; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4161 [aPath lineToPoint:NSMakePoint(x, y + height)]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4162 [aPath lineToPoint:NSMakePoint(x + width, y + height)]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4163 [aPath lineToPoint:NSMakePoint(x + width, y)]; |
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
|
4164 [aPath closePath]; |
767
9b0c22b58447
Don't fill a rectangle unless requested to
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
766
diff
changeset
|
4165 if(fill) |
9b0c22b58447
Don't fill a rectangle unless requested to
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
766
diff
changeset
|
4166 [aPath fill]; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4167 [aPath stroke]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4168 [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
|
4169 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4170 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4171 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4172 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4173 * 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
|
4174 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4175 * 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
|
4176 * resource file. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4177 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
4178 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
|
4179 { |
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
|
4180 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
|
4181 DW_MUTEX_LOCK; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
4182 NSScrollView *scrollview = [[NSScrollView alloc] init]; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4183 DWTree *tree = [[DWTree alloc] init]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
4184 |
680
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
4185 [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
|
4186 [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
|
4187 [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
|
4188 [scrollview setAutohidesScrollers:YES]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
4189 |
680
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
4190 [tree setAllowsMultipleSelection:NO]; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4191 [tree setDataSource:tree]; |
680
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
4192 [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
|
4193 [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
|
4194 [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
|
4195 [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
|
4196 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
|
4197 return tree; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4198 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4199 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4200 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4201 * 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
|
4202 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4203 * 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
|
4204 * 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
|
4205 * 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
|
4206 * icon: Handle to coresponding icon. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4207 * 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
|
4208 * itemdata: Item specific data. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4209 */ |
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
|
4210 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
|
4211 { |
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
|
4212 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
|
4213 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
|
4214 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
|
4215 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
|
4216 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
|
4217 [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
|
4218 [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
|
4219 [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
|
4220 [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
|
4221 [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
|
4222 [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
|
4223 DW_MUTEX_UNLOCK; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4224 return treenode; |
650
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 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4227 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4228 * 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
|
4229 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4230 * 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
|
4231 * 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
|
4232 * icon: Handle to coresponding icon. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4233 * 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
|
4234 * itemdata: Item specific data. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4235 */ |
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
|
4236 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
|
4237 { |
680
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
4238 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
|
4239 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4240 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4241 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4242 * 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
|
4243 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4244 * 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
|
4245 * 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
|
4246 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4247 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
|
4248 { |
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
|
4249 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
|
4250 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
|
4251 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
|
4252 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
|
4253 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
|
4254 return strdup([nstr UTF8String]); |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4255 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4256 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4257 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4258 * 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
|
4259 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4260 * 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
|
4261 * 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
|
4262 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4263 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
|
4264 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4265 NSLog(@"dw_tree_get_parent() unimplemented\n"); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4266 return HWND_DESKTOP; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4267 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4268 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4269 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4270 * 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
|
4271 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4272 * 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
|
4273 * 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
|
4274 * 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
|
4275 * icon: Handle to coresponding icon. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4276 */ |
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
|
4277 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
|
4278 { |
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
|
4279 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
|
4280 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
|
4281 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
|
4282 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
|
4283 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
|
4284 { |
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
|
4285 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
|
4286 [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
|
4287 } |
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
|
4288 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
|
4289 { |
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
|
4290 [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
|
4291 } |
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
|
4292 [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
|
4293 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4294 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4295 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4296 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4297 * 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
|
4298 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4299 * 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
|
4300 * 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
|
4301 * 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
|
4302 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4303 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
|
4304 { |
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
|
4305 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
|
4306 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
|
4307 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
|
4308 [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
|
4309 DW_MUTEX_UNLOCK; |
650
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 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4312 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4313 * 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
|
4314 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4315 * 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
|
4316 * 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
|
4317 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4318 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
|
4319 { |
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
|
4320 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
|
4321 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
|
4322 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
|
4323 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
|
4324 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
|
4325 return result; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4326 } |
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 * 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
|
4330 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4331 * 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
|
4332 * 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
|
4333 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4334 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
|
4335 { |
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
|
4336 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
|
4337 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
|
4338 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
|
4339 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
|
4340 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
|
4341 { |
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
|
4342 [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
|
4343 } |
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
|
4344 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4345 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4346 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4347 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4348 * Removes all nodes from a tree. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4349 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4350 * 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
|
4351 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4352 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
|
4353 { |
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
|
4354 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
|
4355 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
|
4356 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
|
4357 [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
|
4358 DW_MUTEX_UNLOCK; |
650
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 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4361 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4362 * Expands a node on a tree. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4363 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4364 * 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
|
4365 * 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
|
4366 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4367 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
|
4368 { |
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
|
4369 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
|
4370 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
|
4371 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
|
4372 [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
|
4373 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4374 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4375 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4376 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4377 * Collapses a node on a tree. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4378 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4379 * 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
|
4380 * 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
|
4381 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4382 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
|
4383 { |
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
|
4384 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
|
4385 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
|
4386 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
|
4387 [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
|
4388 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4389 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4390 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4391 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4392 * Removes a node from a tree. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4393 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4394 * 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
|
4395 * 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
|
4396 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4397 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
|
4398 { |
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
|
4399 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
|
4400 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
|
4401 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
|
4402 [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
|
4403 [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
|
4404 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4405 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4406 |
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 * 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
|
4409 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4410 * 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
|
4411 * resource file. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4412 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
4413 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
|
4414 { |
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
|
4415 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
|
4416 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
|
4417 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
|
4418 NSScrollView *scrollview = [cont scrollview]; |
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
4419 [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
|
4420 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
|
4421 [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
|
4422 [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
|
4423 [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
|
4424 [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
|
4425 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
|
4426 return cont; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4427 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4428 |
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 * Sets up the container columns. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4431 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4432 * 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
|
4433 * 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
|
4434 * 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
|
4435 * 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
|
4436 * 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
|
4437 * (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
|
4438 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4439 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
|
4440 { |
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
|
4441 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
|
4442 DW_MUTEX_LOCK; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4443 int z; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4444 DWContainer *cont = handle; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
4445 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4446 [cont setup]; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
4447 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4448 for(z=0;z<count;z++) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4449 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4450 NSTableColumn *column = [[NSTableColumn alloc] init]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4451 [[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
|
4452 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
|
4453 { |
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
|
4454 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
|
4455 [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
|
4456 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
|
4457 { |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4458 [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
|
4459 [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
|
4460 } |
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
|
4461 [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
|
4462 } |
795
f23cad02cfb3
Make listbox, container and tree cells uneditable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
794
diff
changeset
|
4463 [column setEditable:NO]; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4464 [cont addTableColumn:column]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4465 [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
|
4466 [column release]; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
4467 } |
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
|
4468 DW_MUTEX_UNLOCK; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4469 return TRUE; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4470 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4471 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4472 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4473 * 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
|
4474 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4475 * 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
|
4476 * 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
|
4477 * 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
|
4478 * 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
|
4479 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4480 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
|
4481 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4482 char **newtitles = malloc(sizeof(char *) * (count + 2)); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4483 unsigned long *newflags = malloc(sizeof(unsigned long) * (count + 2)); |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
4484 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4485 newtitles[0] = "Icon"; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4486 newtitles[1] = "Filename"; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
4487 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4488 newflags[0] = DW_CFA_BITMAPORICON | DW_CFA_LEFT | DW_CFA_HORZSEPARATOR; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
4489 newflags[1] = DW_CFA_STRING | DW_CFA_LEFT | DW_CFA_HORZSEPARATOR; |
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
4490 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4491 memcpy(&newtitles[2], titles, sizeof(char *) * count); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4492 memcpy(&newflags[2], flags, sizeof(unsigned long) * count); |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
4493 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4494 dw_container_setup(handle, newflags, newtitles, count + 2, 0); |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
4495 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4496 free(newtitles); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4497 free(newflags); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4498 return TRUE; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4499 } |
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 * 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
|
4503 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4504 * 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
|
4505 * 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
|
4506 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4507 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
|
4508 { |
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
|
4509 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
|
4510 DW_MUTEX_LOCK; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4511 DWContainer *cont = handle; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4512 [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
|
4513 DW_MUTEX_UNLOCK; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4514 return cont; |
650
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 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4517 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4518 * 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
|
4519 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4520 * 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
|
4521 * 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
|
4522 * 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
|
4523 * 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
|
4524 * 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
|
4525 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4526 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
|
4527 { |
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
|
4528 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
|
4529 DW_MUTEX_LOCK; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4530 DWContainer *cont = handle; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4531 id object = nil; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4532 int type = [cont cellType:column]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4533 int lastadd = [cont lastAddPoint]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
4534 |
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
|
4535 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
|
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; |
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
|
4538 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
|
4539 } |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4540 if(type & DW_CFA_BITMAPORICON) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4541 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4542 object = *((NSImage **)data); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4543 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4544 else if(type & DW_CFA_STRING) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4545 { |
726
ecf47778caff
Possible fix for container string columns not showing correctly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
725
diff
changeset
|
4546 char *str = *((char **)data); |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4547 object = [ NSString stringWithUTF8String:str ]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4548 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4549 else |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4550 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4551 char textbuffer[100]; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
4552 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4553 if(type & DW_CFA_ULONG) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4554 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4555 ULONG tmp = *((ULONG *)data); |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
4556 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4557 sprintf(textbuffer, "%lu", tmp); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4558 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4559 else if(type & DW_CFA_DATE) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4560 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4561 struct tm curtm; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4562 CDATE cdate = *((CDATE *)data); |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
4563 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4564 memset( &curtm, 0, sizeof(curtm) ); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4565 curtm.tm_mday = cdate.day; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4566 curtm.tm_mon = cdate.month - 1; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4567 curtm.tm_year = cdate.year - 1900; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
4568 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4569 strftime(textbuffer, 100, "%x", &curtm); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4570 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4571 else if(type & DW_CFA_TIME) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4572 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4573 struct tm curtm; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4574 CTIME ctime = *((CTIME *)data); |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
4575 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4576 memset( &curtm, 0, sizeof(curtm) ); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4577 curtm.tm_hour = ctime.hours; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4578 curtm.tm_min = ctime.minutes; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4579 curtm.tm_sec = ctime.seconds; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
4580 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4581 strftime(textbuffer, 100, "%X", &curtm); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4582 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4583 else |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4584 { |
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
|
4585 DW_MUTEX_UNLOCK; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4586 return; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4587 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4588 object = [ NSString stringWithUTF8String:textbuffer ]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4589 } |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
4590 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4591 [cont editCell:object at:(row+lastadd) and:column]; |
794
e9bc14c5c72d
Test fix for containers (and probably listboxes) not showing their content changes immediately.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
793
diff
changeset
|
4592 [cont setNeedsDisplay:YES]; |
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
|
4593 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4594 } |
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 * 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
|
4598 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4599 * 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
|
4600 * 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
|
4601 * 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
|
4602 * 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
|
4603 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4604 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
|
4605 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4606 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
|
4607 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4608 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4609 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4610 * 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
|
4611 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4612 * 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
|
4613 * 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
|
4614 * 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
|
4615 * 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
|
4616 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4617 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
|
4618 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4619 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
|
4620 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4621 |
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 * 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
|
4624 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4625 * 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
|
4626 * 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
|
4627 * 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
|
4628 * 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
|
4629 * 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
|
4630 */ |
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
|
4631 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
|
4632 { |
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
|
4633 dw_container_change_item(handle, 0, row, &icon); |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4634 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
|
4635 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4636 |
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 * 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
|
4639 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4640 * 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
|
4641 * 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
|
4642 * 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
|
4643 * 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
|
4644 * 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
|
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_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
|
4647 { |
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
|
4648 dw_container_set_item(handle, pointer, 0, row, &icon); |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4649 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
|
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 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4653 * 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
|
4654 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4655 * 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
|
4656 * 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
|
4657 * 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
|
4658 * 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
|
4659 * 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
|
4660 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4661 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
|
4662 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4663 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
|
4664 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4665 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4666 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4667 * 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
|
4668 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4669 * 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
|
4670 * column: Zero based column. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4671 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4672 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
|
4673 { |
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
|
4674 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
|
4675 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
|
4676 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
|
4677 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
|
4678 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
|
4679 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
|
4680 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
|
4681 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
|
4682 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
|
4683 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
|
4684 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
|
4685 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
|
4686 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
|
4687 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
|
4688 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
|
4689 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
|
4690 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
|
4691 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
|
4692 return rc; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4693 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4694 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4695 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4696 * 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
|
4697 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4698 * 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
|
4699 * column: Zero based column. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4700 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4701 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
|
4702 { |
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
|
4703 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
|
4704 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4705 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4706 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4707 * 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
|
4708 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4709 * 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
|
4710 * 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
|
4711 * width: Width of column in pixels. |
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 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
|
4714 { |
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
|
4715 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
|
4716 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
|
4717 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
|
4718 NSTableColumn *col = [cont getColumn:column]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
4719 |
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
|
4720 [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
|
4721 DW_MUTEX_UNLOCK; |
650
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 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4725 * 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
|
4726 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4727 * 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
|
4728 * 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
|
4729 * title: String title of the item. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4730 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4731 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
|
4732 { |
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
|
4733 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
|
4734 DW_MUTEX_LOCK; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4735 DWContainer *cont = pointer; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4736 [cont setRow:row title:title]; |
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
|
4737 DW_MUTEX_UNLOCK; |
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 * 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
|
4742 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4743 * 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
|
4744 * 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
|
4745 * 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
|
4746 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4747 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
|
4748 { |
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
|
4749 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
|
4750 DW_MUTEX_LOCK; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4751 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
|
4752 [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
|
4753 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4754 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4755 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4756 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4757 * Removes all rows from a container. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4758 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4759 * 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
|
4760 * 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
|
4761 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4762 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
|
4763 { |
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
|
4764 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
|
4765 DW_MUTEX_LOCK; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4766 DWContainer *cont = handle; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4767 [cont clear]; |
670
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
4768 if(redraw) |
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
4769 { |
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
4770 [cont reloadData]; |
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
4771 } |
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
|
4772 DW_MUTEX_UNLOCK; |
650
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 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4776 * 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
|
4777 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4778 * 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
|
4779 * 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
|
4780 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4781 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
|
4782 { |
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
|
4783 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
|
4784 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
|
4785 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
|
4786 int x; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
4787 |
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
|
4788 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
|
4789 { |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4790 [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
|
4791 } |
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
|
4792 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4793 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4794 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4795 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4796 * Scrolls container up or down. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4797 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4798 * 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
|
4799 * 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
|
4800 * 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
|
4801 * 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
|
4802 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4803 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
|
4804 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4805 NSLog(@"dw_container_scroll() unimplemented\n"); |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4806 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4807 |
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 * 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
|
4810 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4811 * 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
|
4812 * 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
|
4813 * 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
|
4814 * 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
|
4815 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4816 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
|
4817 { |
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
|
4818 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
|
4819 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
|
4820 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
|
4821 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
|
4822 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
|
4823 char *retval = NULL; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
4824 |
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
|
4825 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
|
4826 { |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4827 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
|
4828 [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
|
4829 } |
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
|
4830 DW_MUTEX_UNLOCK; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4831 return retval; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4832 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4833 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4834 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4835 * 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
|
4836 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4837 * 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
|
4838 * 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
|
4839 * 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
|
4840 * 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
|
4841 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4842 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
|
4843 { |
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
|
4844 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
|
4845 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
|
4846 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
|
4847 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
|
4848 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
|
4849 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
|
4850 char *retval = NULL; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
4851 |
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
|
4852 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
|
4853 { |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4854 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
|
4855 [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
|
4856 } |
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
|
4857 DW_MUTEX_UNLOCK; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4858 return retval; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4859 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4860 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4861 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4862 * 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
|
4863 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4864 * 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
|
4865 * 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
|
4866 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4867 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
|
4868 { |
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
|
4869 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
|
4870 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
|
4871 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
|
4872 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
|
4873 int x, count = (int)[cont numberOfRowsInTableView:cont]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
4874 |
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
|
4875 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
|
4876 { |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4877 thistext = [cont getRowTitle:x]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
4878 |
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
|
4879 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
|
4880 { |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4881 NSIndexSet *selected = [[NSIndexSet alloc] initWithIndex:(NSUInteger)x]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
4882 |
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
|
4883 [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
|
4884 [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
|
4885 } |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4886 } |
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
|
4887 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4888 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4889 |
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 * 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
|
4892 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4893 * handle: Handle to the window (widget). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4894 * 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
|
4895 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4896 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
|
4897 { |
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
|
4898 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
|
4899 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
|
4900 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
|
4901 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
|
4902 int x, count = (int)[cont numberOfRowsInTableView:cont]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
4903 |
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
|
4904 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
|
4905 { |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4906 thistext = [cont getRowTitle:x]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
4907 |
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
|
4908 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
|
4909 { |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4910 [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
|
4911 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
|
4912 } |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4913 } |
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
|
4914 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4915 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4916 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4917 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4918 * 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
|
4919 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4920 * 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
|
4921 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4922 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
|
4923 { |
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
|
4924 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
|
4925 DW_MUTEX_LOCK; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4926 DWContainer *cont = handle; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4927 /*[cont sizeToFit];*/ |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4928 [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
|
4929 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4930 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4931 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4932 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4933 * Inserts an icon into the taskbar. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4934 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4935 * 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
|
4936 * 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
|
4937 * 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
|
4938 */ |
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
|
4939 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
|
4940 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4941 NSLog(@"dw_taskbar_insert() unimplemented\n"); |
650
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 * Deletes an icon from the taskbar. |
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 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
|
4948 * 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
|
4949 */ |
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
|
4950 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
|
4951 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4952 NSLog(@"dw_taskbar_delete() unimplemented\n"); |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4953 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4954 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4955 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4956 * 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
|
4957 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4958 * 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
|
4959 * 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
|
4960 * 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
|
4961 * to an embedded XPM. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4962 */ |
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
|
4963 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
|
4964 { |
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
|
4965 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
|
4966 NSString *respath = [bundle resourcePath]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
4967 NSString *filepath = [respath stringByAppendingFormat:@"/%u.png", resid]; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4968 NSImage *image = [[NSImage alloc] initWithContentsOfFile:filepath]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4969 return image; |
650
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 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4973 * Obtains an icon from a file. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4974 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4975 * 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
|
4976 * DW pick the appropriate file extension. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4977 * (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
|
4978 */ |
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
|
4979 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
|
4980 { |
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
|
4981 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
|
4982 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
|
4983 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
|
4984 { |
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
|
4985 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
|
4986 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
|
4987 } |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4988 return image; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4989 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4990 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4991 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4992 * Obtains an icon from data |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4993 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4994 * 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
|
4995 * DW pick the appropriate file extension. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4996 * (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
|
4997 */ |
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
|
4998 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
|
4999 { |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
5000 NSData *thisdata = [NSData dataWithBytes:data length:len]; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5001 NSImage *image = [[NSImage alloc] initWithData:thisdata]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5002 return image; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5003 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5004 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5005 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5006 * 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
|
5007 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5008 * 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
|
5009 */ |
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
|
5010 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
|
5011 { |
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
|
5012 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
|
5013 [image release]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5014 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5015 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5016 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5017 * 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
|
5018 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5019 * 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
|
5020 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
5021 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
|
5022 { |
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
|
5023 /* 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
|
5024 * 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
|
5025 * when the application is deactivated to simulate |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
5026 * similar behavior. |
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
|
5027 */ |
014b02436c1f
Added MDI simulation code... the MDI "window" will just be a box for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
683
diff
changeset
|
5028 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
|
5029 /* [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
|
5030 return mdi; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5031 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5032 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5033 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5034 * 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
|
5035 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5036 * 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
|
5037 * 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
|
5038 * 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
|
5039 * Returns: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5040 * 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
|
5041 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
5042 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
|
5043 { |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
5044 HWND tmpbox = dw_box_new(DW_VERT, 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
|
5045 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
|
5046 DW_MUTEX_LOCK; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5047 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
|
5048 [split setDelegate:split]; |
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
5049 dw_box_pack_start(tmpbox, topleft, 0, 0, TRUE, TRUE, 0); |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5050 [split addSubview:tmpbox]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
5051 tmpbox = dw_box_new(DW_VERT, 0); |
668
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
5052 dw_box_pack_start(tmpbox, bottomright, 0, 0, TRUE, TRUE, 0); |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5053 [split addSubview:tmpbox]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5054 if(type == DW_VERT) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5055 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5056 [split setVertical:NO]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5057 } |
668
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
5058 else |
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
5059 { |
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
5060 [split setVertical:YES]; |
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
5061 } |
753
590eebc9b61f
Preset the splitbar percent to 50% since Leopard doesn't set it automatically.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
752
diff
changeset
|
5062 /* Set the default percent to 50% split */ |
590eebc9b61f
Preset the splitbar percent to 50% since Leopard doesn't set it automatically.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
752
diff
changeset
|
5063 [split setPercent:50.0]; |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
5064 /* [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
|
5065 DW_MUTEX_UNLOCK; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5066 return split; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5067 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5068 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5069 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5070 * 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
|
5071 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5072 * 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
|
5073 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5074 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
|
5075 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5076 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
|
5077 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
|
5078 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
|
5079 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
|
5080 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
|
5081 /* 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
|
5082 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
|
5083 { |
677
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
5084 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
|
5085 } |
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
5086 else |
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
5087 { |
676
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
5088 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
|
5089 } |
677
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
5090 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
|
5091 { |
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
5092 [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
|
5093 } |
676
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
5094 else |
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
5095 { |
677
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
5096 /* If we have no size.. wait until the resize |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
5097 * event when we get an actual size to try |
677
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
5098 * 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
|
5099 */ |
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
5100 [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
|
5101 } |
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
|
5102 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5103 } |
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 * 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
|
5107 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5108 * 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
|
5109 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5110 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
|
5111 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5112 DWSplitBar *split = handle; |
676
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
5113 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
|
5114 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
|
5115 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
|
5116 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
|
5117 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
|
5118 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
|
5119 { |
677
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
5120 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
|
5121 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
|
5122 } |
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
5123 else |
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
5124 { |
677
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
5125 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
|
5126 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
|
5127 } |
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
5128 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
|
5129 { |
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
5130 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
|
5131 } |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5132 return retval; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5133 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5134 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5135 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5136 * 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
|
5137 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5138 * 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
|
5139 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
5140 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
|
5141 { |
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
|
5142 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
|
5143 DW_MUTEX_LOCK; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5144 NSImageView *bitmap = [[NSImageView alloc] init]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5145 [bitmap setImageFrameStyle:NSImageFrameNone]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5146 [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
|
5147 [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
|
5148 DW_MUTEX_UNLOCK; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5149 return bitmap; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5150 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5151 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5152 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5153 * Creates a pixmap with given parameters. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5154 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5155 * 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
|
5156 * 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
|
5157 * 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
|
5158 * depth: Color depth of the pixmap. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5159 * Returns: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5160 * 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
|
5161 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5162 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
|
5163 { |
745
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
5164 NSSize size = { (float)width, (float)height }; |
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
5165 HPIXMAP pixmap; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
5166 |
745
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
5167 if(!(pixmap = calloc(1,sizeof(struct _hpixmap)))) |
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
5168 return NULL; |
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
5169 pixmap->width = width; |
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
5170 pixmap->height = height; |
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
5171 pixmap->handle = handle; |
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
5172 NSImage *image = pixmap->image = [[NSImage alloc] initWithSize:size]; |
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
|
5173 [image setFlipped:YES]; |
745
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
5174 return pixmap; |
650
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 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5177 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5178 * Creates a pixmap from a file. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5179 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5180 * 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
|
5181 * 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
|
5182 * DW pick the appropriate file extension. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5183 * (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
|
5184 * Returns: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5185 * 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
|
5186 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5187 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
|
5188 { |
745
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
5189 HPIXMAP pixmap; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
5190 |
745
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
5191 if(!(pixmap = calloc(1,sizeof(struct _hpixmap)))) |
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
5192 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
|
5193 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
|
5194 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
|
5195 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
|
5196 { |
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
|
5197 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
|
5198 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
|
5199 } |
745
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
5200 NSSize size = [image size]; |
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
5201 pixmap->width = size.width; |
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
5202 pixmap->height = size.height; |
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
5203 pixmap->image = image; |
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
5204 pixmap->handle = handle; |
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
5205 [image setFlipped:YES]; |
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
5206 return pixmap; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5207 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5208 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5209 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5210 * Creates a pixmap from memory. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5211 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5212 * 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
|
5213 * data: Source of the image data |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5214 * (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
|
5215 * le: length of data |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5216 * Returns: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5217 * 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
|
5218 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5219 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
|
5220 { |
745
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
5221 HPIXMAP pixmap; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
5222 |
745
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
5223 if(!(pixmap = calloc(1,sizeof(struct _hpixmap)))) |
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
5224 return NULL; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
5225 NSData *thisdata = [NSData dataWithBytes:data length:len]; |
745
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
5226 NSImage *image = [[NSImage alloc] initWithData:thisdata]; |
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
5227 NSSize size = [image size]; |
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
5228 pixmap->width = size.width; |
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
5229 pixmap->height = size.height; |
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
5230 pixmap->image = image; |
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
5231 pixmap->handle = handle; |
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
5232 [image setFlipped:YES]; |
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
5233 return pixmap; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5234 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5235 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5236 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5237 * 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
|
5238 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5239 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
|
5240 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5241 NSLog(@"dw_pixmap_set_transparent_color() unimplemented\n"); |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5242 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5243 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5244 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5245 * 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
|
5246 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5247 * 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
|
5248 * 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
|
5249 * Returns: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5250 * 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
|
5251 */ |
670
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
5252 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
|
5253 { |
745
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
5254 HPIXMAP pixmap; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
5255 |
745
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
5256 if(!(pixmap = calloc(1,sizeof(struct _hpixmap)))) |
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
5257 return NULL; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
5258 |
670
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
5259 NSBundle *bundle = [NSBundle mainBundle]; |
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
5260 NSString *respath = [bundle resourcePath]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
5261 NSString *filepath = [respath stringByAppendingFormat:@"/%u.png", resid]; |
745
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
5262 NSImage *image = [[NSImage alloc] initWithContentsOfFile:filepath]; |
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
5263 NSSize size = [image size]; |
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
5264 pixmap->width = size.width; |
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
5265 pixmap->height = size.height; |
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
5266 pixmap->image = image; |
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
5267 pixmap->handle = handle; |
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
5268 [image setFlipped:YES]; |
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
5269 return pixmap; |
650
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 * Destroys an allocated pixmap. |
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 * 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
|
5276 * dw_pixmap_new.. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5277 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5278 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
|
5279 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5280 NSImage *image = (NSImage *)pixmap->image; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5281 [image dealloc]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5282 free(pixmap); |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5283 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5284 |
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 * Copies from one item to another. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5287 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5288 * dest: Destination window handle. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5289 * destp: Destination pixmap. (choose only one). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5290 * xdest: X coordinate of destination. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5291 * ydest: Y coordinate of destination. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5292 * width: Width of area to copy. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5293 * height: Height of area to copy. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5294 * src: Source window handle. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5295 * srcp: Source pixmap. (choose only one). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5296 * xsrc: X coordinate of source. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5297 * ysrc: Y coordinate of source. |
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 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
|
5300 { |
699
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
5301 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
|
5302 NSValue* bi = [NSValue valueWithPointer:bltinfo]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
5303 |
699
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
5304 /* 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
|
5305 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
|
5306 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
|
5307 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
|
5308 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
|
5309 bltinfo->width = width; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
5310 bltinfo->height = height; |
699
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
5311 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
|
5312 bltinfo->ysrc = ysrc; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
5313 |
699
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
5314 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
|
5315 { |
745
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
5316 bltinfo->dest = (id)destp->image; |
699
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
5317 } |
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
5318 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
|
5319 { |
745
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
5320 id object = bltinfo->src = (id)srcp->image; |
699
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
5321 [object retain]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
5322 } |
699
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
5323 [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
|
5324 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5325 |
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 * 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
|
5328 * Not available under OS/2, eCS |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5329 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5330 * 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
|
5331 * 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
|
5332 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
5333 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
|
5334 { |
729
6712e4211522
Switched to graphical calendar control style... and fixed date querying code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
728
diff
changeset
|
5335 DWCalendar *calendar = [[DWCalendar alloc] init]; |
6712e4211522
Switched to graphical calendar control style... and fixed date querying code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
728
diff
changeset
|
5336 [calendar setDatePickerMode:NSSingleDateMode]; |
6712e4211522
Switched to graphical calendar control style... and fixed date querying code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
728
diff
changeset
|
5337 [calendar setDatePickerStyle:NSClockAndCalendarDatePickerStyle]; |
6712e4211522
Switched to graphical calendar control style... and fixed date querying code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
728
diff
changeset
|
5338 [calendar setDatePickerElements:NSYearMonthDayDatePickerElementFlag]; |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
5339 [calendar setTag:cid]; |
729
6712e4211522
Switched to graphical calendar control style... and fixed date querying code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
728
diff
changeset
|
5340 return calendar; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5341 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5342 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5343 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5344 * 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
|
5345 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5346 * 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
|
5347 * year... |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5348 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5349 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
|
5350 { |
729
6712e4211522
Switched to graphical calendar control style... and fixed date querying code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
728
diff
changeset
|
5351 DWCalendar *calendar = handle; |
6712e4211522
Switched to graphical calendar control style... and fixed date querying code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
728
diff
changeset
|
5352 NSDate *date; |
6712e4211522
Switched to graphical calendar control style... and fixed date querying code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
728
diff
changeset
|
5353 char buffer[100]; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
5354 |
729
6712e4211522
Switched to graphical calendar control style... and fixed date querying code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
728
diff
changeset
|
5355 sprintf(buffer, "%04d-%02d-%02d 00:00:00 +0600", year, month, day); |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
5356 |
729
6712e4211522
Switched to graphical calendar control style... and fixed date querying code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
728
diff
changeset
|
5357 date = [[NSDate alloc] initWithString:[ NSString stringWithUTF8String:buffer ]]; |
6712e4211522
Switched to graphical calendar control style... and fixed date querying code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
728
diff
changeset
|
5358 [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
|
5359 [date release]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5360 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5361 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5362 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5363 * 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
|
5364 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5365 * 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
|
5366 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5367 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
|
5368 { |
729
6712e4211522
Switched to graphical calendar control style... and fixed date querying code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
728
diff
changeset
|
5369 DWCalendar *calendar = handle; |
6712e4211522
Switched to graphical calendar control style... and fixed date querying code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
728
diff
changeset
|
5370 NSDate *date = [calendar dateValue]; |
6712e4211522
Switched to graphical calendar control style... and fixed date querying code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
728
diff
changeset
|
5371 NSDateFormatter *df = [[NSDateFormatter alloc] init]; |
6712e4211522
Switched to graphical calendar control style... and fixed date querying code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
728
diff
changeset
|
5372 [df setDateStyle:NSDateFormatterShortStyle]; |
6712e4211522
Switched to graphical calendar control style... and fixed date querying code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
728
diff
changeset
|
5373 NSString *nstr = [df stringFromDate:date]; |
6712e4211522
Switched to graphical calendar control style... and fixed date querying code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
728
diff
changeset
|
5374 sscanf([ nstr UTF8String ], "%d/%d/%d", month, day, year); |
730
d3fb3613726a
Calendar control should return years with 4 digits not 2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
729
diff
changeset
|
5375 if(*year < 70) |
d3fb3613726a
Calendar control should return years with 4 digits not 2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
729
diff
changeset
|
5376 { |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
5377 *year += 2000; |
730
d3fb3613726a
Calendar control should return years with 4 digits not 2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
729
diff
changeset
|
5378 } |
d3fb3613726a
Calendar control should return years with 4 digits not 2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
729
diff
changeset
|
5379 else if(*year < 100) |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
5380 { |
730
d3fb3613726a
Calendar control should return years with 4 digits not 2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
729
diff
changeset
|
5381 *year += 1900; |
d3fb3613726a
Calendar control should return years with 4 digits not 2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
729
diff
changeset
|
5382 } |
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
|
5383 [df release]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5384 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5385 |
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 * 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
|
5388 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5389 * handle: Handle to the window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5390 * 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
|
5391 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5392 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
|
5393 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5394 WebView *html = handle; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5395 switch(action) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5396 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5397 case DW_HTML_GOBACK: |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5398 [html goBack]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5399 break; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5400 case DW_HTML_GOFORWARD: |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5401 [html goForward]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5402 break; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5403 case DW_HTML_GOHOME: |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5404 break; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5405 case DW_HTML_SEARCH: |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5406 break; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5407 case DW_HTML_RELOAD: |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5408 [html reload:html]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5409 break; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5410 case DW_HTML_STOP: |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5411 [html stopLoading:html]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5412 break; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5413 case DW_HTML_PRINT: |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5414 break; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5415 } |
650
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 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5418 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5419 * 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
|
5420 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5421 * handle: Handle to the window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5422 * 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
|
5423 * be rendered. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5424 * Returns: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5425 * 0 on success. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5426 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5427 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
|
5428 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5429 WebView *html = handle; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5430 [[html mainFrame] loadHTMLString:[ NSString stringWithUTF8String:string ] baseURL:nil]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5431 return 0; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5432 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5433 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5434 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5435 * 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
|
5436 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5437 * handle: Handle to the window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5438 * 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
|
5439 * file object to be rendered. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5440 * Returns: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5441 * 0 on success. |
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 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
|
5444 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5445 WebView *html = handle; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5446 [[html mainFrame] loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:[ NSString stringWithUTF8String:url ]]]]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5447 return 0; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5448 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5449 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5450 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5451 * 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
|
5452 * Not available under OS/2, eCS |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5453 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5454 * 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
|
5455 * 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
|
5456 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
5457 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
|
5458 { |
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
|
5459 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
|
5460 DW_MUTEX_LOCK; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5461 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
|
5462 /* [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
|
5463 DW_MUTEX_UNLOCK; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5464 return web; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5465 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5466 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5467 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5468 * 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
|
5469 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5470 * 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
|
5471 * 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
|
5472 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5473 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
|
5474 { |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
5475 NSPoint mouseLoc; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5476 mouseLoc = [NSEvent mouseLocation]; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5477 if(x) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5478 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5479 *x = mouseLoc.x; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5480 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5481 if(y) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5482 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5483 *y = mouseLoc.y; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5484 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5485 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5486 |
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 * 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
|
5489 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5490 * x: X coordinate. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5491 * y: Y coordinate. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5492 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5493 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
|
5494 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5495 /* 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
|
5496 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5497 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5498 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5499 * 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
|
5500 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5501 * 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
|
5502 * resource file. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5503 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
5504 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
|
5505 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5506 NSMenu *menu = [[[NSMenu alloc] init] autorelease]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5507 [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
|
5508 /* [menu setTag:cid]; Why doesn't this work? */ |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5509 return menu; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5510 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5511 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5512 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5513 * Create a menubar on a window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5514 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5515 * 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
|
5516 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5517 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
|
5518 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5519 NSWindow *window = location; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5520 NSMenu *windowmenu = _generate_main_menu(); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5521 [[window contentView] setMenu:windowmenu]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5522 return (HMENUI)windowmenu; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5523 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5524 |
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 * 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
|
5527 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5528 * menu: Handle of a menu. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5529 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5530 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
|
5531 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5532 NSMenu *thismenu = *menu; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5533 [thismenu release]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5534 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5535 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5536 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5537 * 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
|
5538 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5539 * 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
|
5540 * 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
|
5541 * x: X coordinate. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5542 * y: Y coordinate. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5543 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5544 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
|
5545 { |
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
|
5546 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
|
5547 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
|
5548 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
|
5549 NSWindow *window = [view window]; |
701
c91a1b345f2e
Fix for button press and context menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
700
diff
changeset
|
5550 NSEvent *event = [DWApp currentEvent]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
5551 NSEvent* fake = [NSEvent mouseEventWithType:NSRightMouseDown |
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
|
5552 location:[window convertScreenToBase:NSMakePoint(x, y)] |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
5553 modifierFlags:0 |
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
|
5554 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
|
5555 windowNumber:[window windowNumber] |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
5556 context:[NSGraphicsContext currentContext] |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
5557 eventNumber:1 |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
5558 clickCount:1 |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
5559 pressure:0.0]; |
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
|
5560 [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
|
5561 } |
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 char _removetilde(char *dest, char *src) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5564 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5565 int z, cur=0; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5566 char accel = '\0'; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
5567 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5568 for(z=0;z<strlen(src);z++) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5569 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5570 if(src[z] != '~') |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5571 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5572 dest[cur] = src[z]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5573 cur++; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5574 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5575 else |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5576 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5577 accel = src[z+1]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5578 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5579 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5580 dest[cur] = 0; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5581 return accel; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5582 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5583 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5584 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5585 * 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
|
5586 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5587 * 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
|
5588 * 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
|
5589 * 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
|
5590 * 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
|
5591 * 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
|
5592 * 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
|
5593 * 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
|
5594 * 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
|
5595 */ |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5596 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
|
5597 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5598 NSMenu *menu = menux; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5599 NSMenu *submenu = submenux; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5600 NSMenuItem *item = NULL; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5601 if(strlen(title) == 0) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5602 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5603 [menu addItem:[NSMenuItem separatorItem]]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5604 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5605 else |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5606 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5607 char accel[2]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5608 char *newtitle = malloc(strlen(title)+1); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5609 NSString *nstr; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
5610 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5611 accel[0] = _removetilde(newtitle, title); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5612 accel[1] = 0; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
5613 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5614 nstr = [ NSString stringWithUTF8String:newtitle ]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5615 free(newtitle); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5616 |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5617 item = [menu addItemWithTitle: nstr |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5618 action:@selector(menuHandler:) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5619 keyEquivalent:[ NSString stringWithUTF8String:accel ]]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5620 [item setTag:itemid]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5621 if(flags & DW_MIS_CHECKED) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5622 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5623 [item setState:NSOnState]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5624 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5625 if(flags & DW_MIS_DISABLED) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5626 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5627 [item setEnabled:NO]; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
5628 } |
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
5629 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5630 if(submenux) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5631 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5632 [submenu setTitle:nstr]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5633 [menu setSubmenu:submenu forItem:item]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5634 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5635 return item; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5636 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5637 return item; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5638 } |
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 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5641 * 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
|
5642 * 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
|
5643 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5644 * 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
|
5645 * id: Menuitem id. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5646 * 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
|
5647 */ |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5648 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
|
5649 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5650 id menu = menux; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5651 NSMenuItem *menuitem = (NSMenuItem *)[menu itemWithTag:itemid]; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
5652 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5653 if(menuitem != nil) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5654 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5655 if(check) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5656 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5657 [menuitem setState:NSOnState]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5658 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5659 else |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
5660 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5661 [menuitem setState:NSOffState]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5662 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5663 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5664 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5665 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5666 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5667 * 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
|
5668 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5669 * 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
|
5670 * id: Menuitem id. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5671 * 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
|
5672 * DW_MIS_CHECKED/DW_MIS_UNCHECKED |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5673 */ |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5674 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
|
5675 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5676 id menu = menux; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5677 NSMenuItem *menuitem = (NSMenuItem *)[menu itemWithTag:itemid]; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
5678 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5679 if(menuitem != nil) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5680 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5681 if(state & DW_MIS_CHECKED) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5682 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5683 [menuitem setState:NSOnState]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5684 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5685 else if(state & DW_MIS_UNCHECKED) |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
5686 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5687 [menuitem setState:NSOffState]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5688 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5689 if(state & DW_MIS_ENABLED) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5690 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5691 [menuitem setEnabled:YES]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5692 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5693 else if(state & DW_MIS_DISABLED) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5694 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5695 [menuitem setEnabled:NO]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5696 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5697 } |
650
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 |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5700 /* 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
|
5701 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
|
5702 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5703 NSArray *pages = [notebook tabViewItems]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5704 for(DWNotebookPage *notepage in pages) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5705 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5706 if([notepage pageid] == pageid) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5707 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5708 return notepage; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5709 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5710 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5711 return 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
|
5712 } |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5713 |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5714 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5715 * 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
|
5716 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5717 * 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
|
5718 * resource file. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5719 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
5720 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
|
5721 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5722 DWNotebook *notebook = [[DWNotebook alloc] init]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5723 [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
|
5724 /* [notebook setTag:cid]; Why doesn't this work? */ |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5725 return notebook; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5726 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5727 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5728 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5729 * 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
|
5730 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5731 * handle: Window (widget) handle. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5732 * flags: Any additional page creation flags. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5733 * 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
|
5734 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5735 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
|
5736 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5737 DWNotebook *notebook = handle; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5738 NSInteger page = [notebook pageid]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5739 DWNotebookPage *notepage = [[DWNotebookPage alloc] initWithIdentifier:nil]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5740 [notepage setPageid:(NSInteger)page]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5741 if(front) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5742 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5743 [notebook insertTabViewItem:notepage atIndex:(NSInteger)0]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5744 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5745 else |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5746 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5747 [notebook addTabViewItem:notepage]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5748 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5749 [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
|
5750 [notepage release]; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5751 return (unsigned long)page; |
650
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 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5755 * Remove a page from a notebook. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5756 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5757 * handle: Handle to the notebook widget. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5758 * 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
|
5759 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5760 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
|
5761 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5762 DWNotebook *notebook = handle; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5763 DWNotebookPage *notepage = _notepage_from_id(notebook, pageid); |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
5764 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5765 if(notepage != nil) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5766 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5767 [notebook removeTabViewItem:notepage]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5768 [notepage release]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5769 } |
650
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 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5772 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5773 * Queries the currently visible page ID. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5774 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5775 * handle: Handle to the notebook widget. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5776 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5777 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
|
5778 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5779 DWNotebook *notebook = handle; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5780 DWNotebookPage *notepage = (DWNotebookPage *)[notebook selectedTabViewItem]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5781 return [notepage pageid]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5782 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5783 |
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 * Sets the currently visibale page ID. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5786 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5787 * handle: Handle to the notebook widget. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5788 * 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
|
5789 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5790 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
|
5791 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5792 DWNotebook *notebook = handle; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5793 DWNotebookPage *notepage = _notepage_from_id(notebook, pageid); |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
5794 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5795 if(notepage != nil) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5796 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5797 [notebook selectTabViewItem:notepage]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5798 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5799 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5800 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5801 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5802 * 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
|
5803 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5804 * handle: Notebook handle. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5805 * 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
|
5806 * 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
|
5807 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5808 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
|
5809 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5810 DWNotebook *notebook = handle; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5811 DWNotebookPage *notepage = _notepage_from_id(notebook, pageid); |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
5812 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5813 if(notepage != nil) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5814 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5815 [notepage setLabel:[ NSString stringWithUTF8String:text ]]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5816 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5817 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5818 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5819 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5820 * 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
|
5821 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5822 * handle: Notebook handle. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5823 * 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
|
5824 * 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
|
5825 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5826 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
|
5827 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5828 /* Note supported here... do nothing */ |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5829 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5830 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5831 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5832 * 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
|
5833 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5834 * 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
|
5835 * 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
|
5836 * page: Box handle to be packed. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5837 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5838 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
|
5839 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5840 DWNotebook *notebook = handle; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5841 DWNotebookPage *notepage = _notepage_from_id(notebook, pageid); |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
5842 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5843 if(notepage != nil) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5844 { |
667
28727d9a835c
Fix for a rather serious notebook layout bug.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
666
diff
changeset
|
5845 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
|
5846 DWBox *box = tmpbox; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
5847 |
667
28727d9a835c
Fix for a rather serious notebook layout bug.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
666
diff
changeset
|
5848 dw_box_pack_start(tmpbox, page, 0, 0, TRUE, TRUE, 0); |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5849 [notepage setView:box]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5850 } |
650
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 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5853 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5854 * Create a new Window Frame. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5855 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5856 * 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
|
5857 * title: The Window title. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5858 * 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
|
5859 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5860 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
|
5861 { |
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
|
5862 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
|
5863 DW_MUTEX_LOCK; |
735
b75be4860279
Possible fix for initial window creation with 0 size... not sure if the size I picked is good or not...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
734
diff
changeset
|
5864 NSRect frame = NSMakeRect(1,1,1,1); |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5865 NSWindow *window = [[NSWindow alloc] |
735
b75be4860279
Possible fix for initial window creation with 0 size... not sure if the size I picked is good or not...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
734
diff
changeset
|
5866 initWithContentRect:frame |
b75be4860279
Possible fix for initial window creation with 0 size... not sure if the size I picked is good or not...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
734
diff
changeset
|
5867 styleMask:(flStyle | NSTexturedBackgroundWindowMask) |
b75be4860279
Possible fix for initial window creation with 0 size... not sure if the size I picked is good or not...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
734
diff
changeset
|
5868 backing:NSBackingStoreBuffered |
b75be4860279
Possible fix for initial window creation with 0 size... not sure if the size I picked is good or not...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
734
diff
changeset
|
5869 defer:false]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5870 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5871 [window setTitle:[ NSString stringWithUTF8String:title ]]; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
5872 |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5873 DWView *view = [[DWView alloc] init]; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
5874 |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5875 [window setContentView:view]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5876 [window setDelegate:view]; |
766
82cde14ec084
Enable recalculating the key view loop (keyboard focus list) automatically.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
763
diff
changeset
|
5877 [window setAutorecalculatesKeyViewLoop:YES]; |
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
|
5878 [view release]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
5879 |
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
|
5880 /* 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
|
5881 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
|
5882 { |
014b02436c1f
Added MDI simulation code... the MDI "window" will just be a box for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
683
diff
changeset
|
5883 id object = hwndOwner; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
5884 |
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
|
5885 /* 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
|
5886 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
|
5887 { |
014b02436c1f
Added MDI simulation code... the MDI "window" will just be a box for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
683
diff
changeset
|
5888 /* 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
|
5889 [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
|
5890 [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
|
5891 } |
014b02436c1f
Added MDI simulation code... the MDI "window" will just be a box for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
683
diff
changeset
|
5892 } |
735
b75be4860279
Possible fix for initial window creation with 0 size... not sure if the size I picked is good or not...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
734
diff
changeset
|
5893 DW_MUTEX_UNLOCK; |
b75be4860279
Possible fix for initial window creation with 0 size... not sure if the size I picked is good or not...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
734
diff
changeset
|
5894 return (HWND)window; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5895 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5896 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5897 /* |
651
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5898 * 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
|
5899 * Parameters: |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5900 * handle: Window handle of the widget. |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5901 * function: Function pointer to be called. |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5902 * 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
|
5903 */ |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5904 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
|
5905 { |
735
b75be4860279
Possible fix for initial window creation with 0 size... not sure if the size I picked is good or not...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
734
diff
changeset
|
5906 void **params = calloc(2, sizeof(void *)); |
b75be4860279
Possible fix for initial window creation with 0 size... not sure if the size I picked is good or not...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
734
diff
changeset
|
5907 NSValue *v = [NSValue valueWithPointer:params]; |
b75be4860279
Possible fix for initial window creation with 0 size... not sure if the size I picked is good or not...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
734
diff
changeset
|
5908 params[0] = function; |
b75be4860279
Possible fix for initial window creation with 0 size... not sure if the size I picked is good or not...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
734
diff
changeset
|
5909 params[1] = data; |
b75be4860279
Possible fix for initial window creation with 0 size... not sure if the size I picked is good or not...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
734
diff
changeset
|
5910 [DWObj performSelectorOnMainThread:@selector(doWindowFunc:) withObject:v waitUntilDone:YES]; |
b75be4860279
Possible fix for initial window creation with 0 size... not sure if the size I picked is good or not...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
734
diff
changeset
|
5911 free(params); |
651
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5912 } |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5913 |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5914 |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5915 /* |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5916 * 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
|
5917 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5918 * 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
|
5919 * 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
|
5920 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5921 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
|
5922 { |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
5923 id object = handle; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
5924 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5925 if([ object isKindOfClass:[ NSView class ] ]) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5926 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5927 NSView *view = handle; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
5928 |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
5929 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
|
5930 { |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
5931 [view discardCursorRects]; |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
5932 } |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
5933 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
|
5934 { |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
5935 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
|
5936 NSCursor *cursor = [NSCursor arrowCursor]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
5937 |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
5938 [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
|
5939 } |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
5940 /* 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
|
5941 } |
650
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 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5944 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5945 * Makes the window visible. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5946 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5947 * 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
|
5948 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5949 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
|
5950 { |
735
b75be4860279
Possible fix for initial window creation with 0 size... not sure if the size I picked is good or not...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
734
diff
changeset
|
5951 NSObject *object = handle; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
5952 |
735
b75be4860279
Possible fix for initial window creation with 0 size... not sure if the size I picked is good or not...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
734
diff
changeset
|
5953 if([ object isKindOfClass:[ NSWindow class ] ]) |
b75be4860279
Possible fix for initial window creation with 0 size... not sure if the size I picked is good or not...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
734
diff
changeset
|
5954 { |
b75be4860279
Possible fix for initial window creation with 0 size... not sure if the size I picked is good or not...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
734
diff
changeset
|
5955 NSWindow *window = handle; |
b75be4860279
Possible fix for initial window creation with 0 size... not sure if the size I picked is good or not...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
734
diff
changeset
|
5956 NSRect rect = [window frame]; |
b75be4860279
Possible fix for initial window creation with 0 size... not sure if the size I picked is good or not...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
734
diff
changeset
|
5957 if([window isMiniaturized]) |
b75be4860279
Possible fix for initial window creation with 0 size... not sure if the size I picked is good or not...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
734
diff
changeset
|
5958 { |
b75be4860279
Possible fix for initial window creation with 0 size... not sure if the size I picked is good or not...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
734
diff
changeset
|
5959 [window deminiaturize:nil]; |
b75be4860279
Possible fix for initial window creation with 0 size... not sure if the size I picked is good or not...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
734
diff
changeset
|
5960 } |
b75be4860279
Possible fix for initial window creation with 0 size... not sure if the size I picked is good or not...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
734
diff
changeset
|
5961 /* If we haven't been sized by a call.. */ |
737
680c7f365d0d
Slight change to the window initial size fix... still don't like this solution.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
736
diff
changeset
|
5962 if(rect.size.width < 5 || rect.size.height < 5) |
735
b75be4860279
Possible fix for initial window creation with 0 size... not sure if the size I picked is good or not...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
734
diff
changeset
|
5963 { |
b75be4860279
Possible fix for initial window creation with 0 size... not sure if the size I picked is good or not...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
734
diff
changeset
|
5964 /* Make a sane default size because MacOS won't automatically */ |
b75be4860279
Possible fix for initial window creation with 0 size... not sure if the size I picked is good or not...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
734
diff
changeset
|
5965 [window setContentSize:NSMakeSize(200,150)]; |
b75be4860279
Possible fix for initial window creation with 0 size... not sure if the size I picked is good or not...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
734
diff
changeset
|
5966 } |
b75be4860279
Possible fix for initial window creation with 0 size... not sure if the size I picked is good or not...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
734
diff
changeset
|
5967 [window makeKeyAndOrderFront:nil]; |
b75be4860279
Possible fix for initial window creation with 0 size... not sure if the size I picked is good or not...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
734
diff
changeset
|
5968 [[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
|
5969 [[window contentView] windowDidBecomeMain:nil]; |
735
b75be4860279
Possible fix for initial window creation with 0 size... not sure if the size I picked is good or not...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
734
diff
changeset
|
5970 } |
b75be4860279
Possible fix for initial window creation with 0 size... not sure if the size I picked is good or not...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
734
diff
changeset
|
5971 return 0; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5972 } |
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 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5975 * Makes the window invisible. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5976 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5977 * 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
|
5978 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5979 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
|
5980 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5981 NSObject *object = handle; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
5982 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5983 if([ object isKindOfClass:[ NSWindow class ] ]) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5984 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5985 NSWindow *window = handle; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
5986 |
733
8d5e5b89725f
Fixed the crashing issue with dw_color_choose() it now functions properly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
732
diff
changeset
|
5987 [window orderOut:nil]; |
8d5e5b89725f
Fixed the crashing issue with dw_color_choose() it now functions properly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
732
diff
changeset
|
5988 } |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5989 return 0; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5990 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5991 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5992 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5993 * 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
|
5994 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5995 * handle: The window (widget) handle. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5996 * 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
|
5997 * 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
|
5998 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5999 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
|
6000 { |
739
a0aec9a56914
Font and color improvements... including implementing dw_window_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
738
diff
changeset
|
6001 id object = handle; |
a0aec9a56914
Font and color improvements... including implementing dw_window_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
738
diff
changeset
|
6002 unsigned long _fore = _get_color(fore); |
a0aec9a56914
Font and color improvements... including implementing dw_window_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
738
diff
changeset
|
6003 unsigned long _back = _get_color(back); |
a0aec9a56914
Font and color improvements... including implementing dw_window_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
738
diff
changeset
|
6004 NSColor *fg = [NSColor colorWithDeviceRed: DW_RED_VALUE(_fore)/255.0 green: DW_GREEN_VALUE(_fore)/255.0 blue: DW_BLUE_VALUE(_fore)/255.0 alpha: 1]; |
a0aec9a56914
Font and color improvements... including implementing dw_window_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
738
diff
changeset
|
6005 NSColor *bg = [NSColor colorWithDeviceRed: DW_RED_VALUE(_back)/255.0 green: DW_GREEN_VALUE(_back)/255.0 blue: DW_BLUE_VALUE(_back)/255.0 alpha: 1]; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
6006 |
739
a0aec9a56914
Font and color improvements... including implementing dw_window_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
738
diff
changeset
|
6007 if([object isMemberOfClass:[NSTextFieldCell class]]) |
a0aec9a56914
Font and color improvements... including implementing dw_window_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
738
diff
changeset
|
6008 { |
a0aec9a56914
Font and color improvements... including implementing dw_window_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
738
diff
changeset
|
6009 NSTextFieldCell *text = object; |
a0aec9a56914
Font and color improvements... including implementing dw_window_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
738
diff
changeset
|
6010 [text setTextColor:fg]; |
a0aec9a56914
Font and color improvements... including implementing dw_window_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
738
diff
changeset
|
6011 } |
a0aec9a56914
Font and color improvements... including implementing dw_window_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
738
diff
changeset
|
6012 else if([object isMemberOfClass:[DWBox class]]) |
a0aec9a56914
Font and color improvements... including implementing dw_window_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
738
diff
changeset
|
6013 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6014 DWBox *box = object; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
6015 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6016 [box setColor:_back]; |
739
a0aec9a56914
Font and color improvements... including implementing dw_window_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
738
diff
changeset
|
6017 } |
a0aec9a56914
Font and color improvements... including implementing dw_window_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
738
diff
changeset
|
6018 else if([object isMemberOfClass:[DWButton class]]) |
a0aec9a56914
Font and color improvements... including implementing dw_window_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
738
diff
changeset
|
6019 { |
a0aec9a56914
Font and color improvements... including implementing dw_window_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
738
diff
changeset
|
6020 DWButton *button = object; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
6021 |
739
a0aec9a56914
Font and color improvements... including implementing dw_window_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
738
diff
changeset
|
6022 [[button cell] setBackgroundColor:bg]; |
a0aec9a56914
Font and color improvements... including implementing dw_window_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
738
diff
changeset
|
6023 } |
a0aec9a56914
Font and color improvements... including implementing dw_window_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
738
diff
changeset
|
6024 return 0; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6025 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6026 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6027 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6028 * 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
|
6029 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6030 * handle: The window (widget) handle. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6031 * 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
|
6032 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6033 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
|
6034 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6035 return 0; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6036 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6037 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6038 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6039 * 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
|
6040 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6041 * handle: Window (widget) handle. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6042 * width: New width in pixels. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6043 * height: New height in pixels. |
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 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
|
6046 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6047 id object = handle; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
6048 |
751
eba6ab48c952
Runtime Snow Leopard checks where possible and visual fix for Leopard status text.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
749
diff
changeset
|
6049 if(DWOSMinor > 5 && [object isMemberOfClass:[NSWindow class]]) |
eba6ab48c952
Runtime Snow Leopard checks where possible and visual fix for Leopard status text.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
749
diff
changeset
|
6050 { |
eba6ab48c952
Runtime Snow Leopard checks where possible and visual fix for Leopard status text.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
749
diff
changeset
|
6051 NSWindow *window = object; |
eba6ab48c952
Runtime Snow Leopard checks where possible and visual fix for Leopard status text.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
749
diff
changeset
|
6052 int currentstyle = (int)[window styleMask]; |
eba6ab48c952
Runtime Snow Leopard checks where possible and visual fix for Leopard status text.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
749
diff
changeset
|
6053 int tmp; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
6054 |
751
eba6ab48c952
Runtime Snow Leopard checks where possible and visual fix for Leopard status text.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
749
diff
changeset
|
6055 tmp = currentstyle | (int)mask; |
eba6ab48c952
Runtime Snow Leopard checks where possible and visual fix for Leopard status text.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
749
diff
changeset
|
6056 tmp ^= mask; |
eba6ab48c952
Runtime Snow Leopard checks where possible and visual fix for Leopard status text.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
749
diff
changeset
|
6057 tmp |= style; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
6058 |
751
eba6ab48c952
Runtime Snow Leopard checks where possible and visual fix for Leopard status text.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
749
diff
changeset
|
6059 [window setStyleMask:tmp]; |
eba6ab48c952
Runtime Snow Leopard checks where possible and visual fix for Leopard status text.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
749
diff
changeset
|
6060 } |
740
bb3b2d804f0e
Working on fonts some more.... setting a default label font that is smaller.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
739
diff
changeset
|
6061 else if([object isKindOfClass:[NSTextField class]]) |
bb3b2d804f0e
Working on fonts some more.... setting a default label font that is smaller.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
739
diff
changeset
|
6062 { |
bb3b2d804f0e
Working on fonts some more.... setting a default label font that is smaller.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
739
diff
changeset
|
6063 NSTextField *tf = object; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
6064 |
740
bb3b2d804f0e
Working on fonts some more.... setting a default label font that is smaller.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
739
diff
changeset
|
6065 /* TODO: See if we need to switch to a bitmask */ |
bb3b2d804f0e
Working on fonts some more.... setting a default label font that is smaller.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
739
diff
changeset
|
6066 [[tf cell] setAlignment:style]; |
bb3b2d804f0e
Working on fonts some more.... setting a default label font that is smaller.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
739
diff
changeset
|
6067 } |
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
|
6068 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
|
6069 { |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
6070 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
|
6071 [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
|
6072 } |
763
2cace4e6e69a
Added DW_BS_NOBORDER style which can be set on buttons with dw_window_set_style() to make them flat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
762
diff
changeset
|
6073 else if([object isMemberOfClass:[DWButton class]]) |
2cace4e6e69a
Added DW_BS_NOBORDER style which can be set on buttons with dw_window_set_style() to make them flat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
762
diff
changeset
|
6074 { |
2cace4e6e69a
Added DW_BS_NOBORDER style which can be set on buttons with dw_window_set_style() to make them flat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
762
diff
changeset
|
6075 DWButton *button = handle; |
2cace4e6e69a
Added DW_BS_NOBORDER style which can be set on buttons with dw_window_set_style() to make them flat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
762
diff
changeset
|
6076 |
2cace4e6e69a
Added DW_BS_NOBORDER style which can be set on buttons with dw_window_set_style() to make them flat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
762
diff
changeset
|
6077 if(mask & DW_BS_NOBORDER) |
2cace4e6e69a
Added DW_BS_NOBORDER style which can be set on buttons with dw_window_set_style() to make them flat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
762
diff
changeset
|
6078 { |
2cace4e6e69a
Added DW_BS_NOBORDER style which can be set on buttons with dw_window_set_style() to make them flat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
762
diff
changeset
|
6079 if(style & DW_BS_NOBORDER) |
2cace4e6e69a
Added DW_BS_NOBORDER style which can be set on buttons with dw_window_set_style() to make them flat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
762
diff
changeset
|
6080 { |
2cace4e6e69a
Added DW_BS_NOBORDER style which can be set on buttons with dw_window_set_style() to make them flat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
762
diff
changeset
|
6081 [button setButtonType:NSMomentaryLight]; |
2cace4e6e69a
Added DW_BS_NOBORDER style which can be set on buttons with dw_window_set_style() to make them flat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
762
diff
changeset
|
6082 [button setBordered:NO]; |
2cace4e6e69a
Added DW_BS_NOBORDER style which can be set on buttons with dw_window_set_style() to make them flat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
762
diff
changeset
|
6083 } |
2cace4e6e69a
Added DW_BS_NOBORDER style which can be set on buttons with dw_window_set_style() to make them flat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
762
diff
changeset
|
6084 else |
2cace4e6e69a
Added DW_BS_NOBORDER style which can be set on buttons with dw_window_set_style() to make them flat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
762
diff
changeset
|
6085 { |
2cace4e6e69a
Added DW_BS_NOBORDER style which can be set on buttons with dw_window_set_style() to make them flat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
762
diff
changeset
|
6086 [button setButtonType:NSMomentaryPushInButton]; |
2cace4e6e69a
Added DW_BS_NOBORDER style which can be set on buttons with dw_window_set_style() to make them flat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
762
diff
changeset
|
6087 [button setBordered:YES]; |
2cace4e6e69a
Added DW_BS_NOBORDER style which can be set on buttons with dw_window_set_style() to make them flat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
762
diff
changeset
|
6088 } |
2cace4e6e69a
Added DW_BS_NOBORDER style which can be set on buttons with dw_window_set_style() to make them flat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
762
diff
changeset
|
6089 } |
2cace4e6e69a
Added DW_BS_NOBORDER style which can be set on buttons with dw_window_set_style() to make them flat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
762
diff
changeset
|
6090 } |
650
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 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6093 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6094 * 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
|
6095 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6096 * window: Toplevel window or dialog. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6097 * 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
|
6098 */ |
766
82cde14ec084
Enable recalculating the key view loop (keyboard focus list) automatically.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
763
diff
changeset
|
6099 void API dw_window_default(HWND handle, HWND defaultitem) |
82cde14ec084
Enable recalculating the key view loop (keyboard focus list) automatically.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
763
diff
changeset
|
6100 { |
82cde14ec084
Enable recalculating the key view loop (keyboard focus list) automatically.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
763
diff
changeset
|
6101 NSWindow *window = handle; |
82cde14ec084
Enable recalculating the key view loop (keyboard focus list) automatically.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
763
diff
changeset
|
6102 |
82cde14ec084
Enable recalculating the key view loop (keyboard focus list) automatically.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
763
diff
changeset
|
6103 [window setInitialFirstResponder:defaultitem]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6104 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6105 |
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 * 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
|
6108 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6109 * 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
|
6110 * 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
|
6111 */ |
768
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
6112 void API dw_window_click_default(HWND handle, HWND next) |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
6113 { |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
6114 id object = handle; |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
6115 id control = next; |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
6116 |
792
fc6a626a96cc
Initial groupbox support. Sizing of the content frame is not quite right yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
768
diff
changeset
|
6117 if([object isMemberOfClass:[NSWindow class]]) |
fc6a626a96cc
Initial groupbox support. Sizing of the content frame is not quite right yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
768
diff
changeset
|
6118 { |
fc6a626a96cc
Initial groupbox support. Sizing of the content frame is not quite right yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
768
diff
changeset
|
6119 if([control isMemberOfClass:[DWButton class]]) |
fc6a626a96cc
Initial groupbox support. Sizing of the content frame is not quite right yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
768
diff
changeset
|
6120 { |
fc6a626a96cc
Initial groupbox support. Sizing of the content frame is not quite right yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
768
diff
changeset
|
6121 NSWindow *window = object; |
768
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
6122 |
792
fc6a626a96cc
Initial groupbox support. Sizing of the content frame is not quite right yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
768
diff
changeset
|
6123 [window setDefaultButtonCell:control]; |
fc6a626a96cc
Initial groupbox support. Sizing of the content frame is not quite right yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
768
diff
changeset
|
6124 } |
768
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
6125 } |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
6126 else |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
6127 { |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
6128 if([control isMemberOfClass:[DWSpinButton class]]) |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
6129 { |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
6130 control = [control textfield]; |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
6131 } |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
6132 else if([control isMemberOfClass:[DWComboBox class]]) |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
6133 { |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
6134 /* TODO: Figure out why the combobox can't be |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
6135 * focused using makeFirstResponder method. |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
6136 */ |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
6137 control = [control textfield]; |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
6138 } |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
6139 [object setClickDefault:control]; |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
6140 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6141 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6142 |
686
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
6143 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
|
6144 |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6145 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6146 * 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
|
6147 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6148 * handle: Handle to receive mouse input. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6149 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6150 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
|
6151 { |
686
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
6152 id object = handle; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
6153 |
686
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
6154 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
|
6155 { |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
6156 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
|
6157 } |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
6158 if(object) |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
6159 { |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
6160 [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
|
6161 _DWCapture = object; |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
6162 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6163 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6164 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6165 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6166 * Releases previous mouse capture. |
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 void API dw_window_release(void) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6169 { |
686
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
6170 if(_DWCapture) |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
6171 { |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
6172 [_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
|
6173 _DWCapture = nil; |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
6174 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6175 } |
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 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6178 * Tracks this window movement. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6179 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6180 * 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
|
6181 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6182 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
|
6183 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6184 NSLog(@"dw_window_track() unimplemented\n"); |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6185 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6186 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6187 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6188 * 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
|
6189 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6190 * handle: The window handle to destroy. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6191 * 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
|
6192 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6193 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
|
6194 { |
686
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
6195 id object = handle; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
6196 |
686
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
6197 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
|
6198 { |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
6199 /* 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
|
6200 * 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
|
6201 * 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
|
6202 */ |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
6203 NSWindow *window = handle; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
6204 |
686
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
6205 /* 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
|
6206 if(newparent) |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
6207 { |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
6208 object = newparent; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
6209 |
686
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
6210 /* 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
|
6211 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
|
6212 { |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
6213 /* 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
|
6214 [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
|
6215 [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
|
6216 return; |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
6217 } |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
6218 } |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
6219 /* 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
|
6220 [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
|
6221 [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
|
6222 } |
650
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 |
744
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
6225 NSFont *_dw_font_by_name(char *fontname) |
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
6226 { |
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
6227 char *fontcopy = strdup(fontname); |
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
6228 char *name = strchr(fontcopy, '.'); |
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
6229 NSFont *font = nil; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
6230 |
744
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
6231 if(name) |
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
6232 { |
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
6233 int size = atoi(fontcopy); |
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
6234 *name = 0; |
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
6235 name++; |
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
6236 font = [NSFont fontWithName:[ NSString stringWithUTF8String:name ] size:(float)size]; |
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
6237 } |
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
6238 free(fontcopy); |
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
6239 return font; |
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
6240 } |
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
6241 |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6242 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6243 * 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
|
6244 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6245 * handle: The window (widget) handle. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6246 * 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
|
6247 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6248 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
|
6249 { |
744
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
6250 NSFont *font = _dw_font_by_name(fontname); |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
6251 |
744
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
6252 if(font) |
740
bb3b2d804f0e
Working on fonts some more.... setting a default label font that is smaller.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
739
diff
changeset
|
6253 { |
744
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
6254 id object = handle; |
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
6255 if([object window]) |
673
6d0f0dc7ff7c
Some minor font fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
672
diff
changeset
|
6256 { |
744
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
6257 [object lockFocus]; |
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
6258 [font set]; |
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
6259 [object unlockFocus]; |
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
6260 } |
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
6261 if([object isKindOfClass:[NSControl class]]) |
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
6262 { |
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
6263 [object setFont:font]; |
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
6264 [[object cell] setFont:font]; |
673
6d0f0dc7ff7c
Some minor font fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
672
diff
changeset
|
6265 } |
745
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
6266 else if([object isMemberOfClass:[DWRender class]]) |
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
6267 { |
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
6268 DWRender *render = object; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
6269 |
745
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
6270 [render setFont:font]; |
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
6271 } |
740
bb3b2d804f0e
Working on fonts some more.... setting a default label font that is smaller.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
739
diff
changeset
|
6272 } |
bb3b2d804f0e
Working on fonts some more.... setting a default label font that is smaller.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
739
diff
changeset
|
6273 return 0; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6274 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6275 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6276 /* |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
6277 * Returns the current font for the specified window |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
6278 * Parameters: |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
6279 * handle: The window handle from which to obtain the font. |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
6280 */ |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
6281 char * API dw_window_get_font(HWND handle) |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
6282 { |
739
a0aec9a56914
Font and color improvements... including implementing dw_window_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
738
diff
changeset
|
6283 id object = handle; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
6284 |
745
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
6285 if([object isKindOfClass:[NSControl class]] || [object isMemberOfClass:[DWRender class]]) |
739
a0aec9a56914
Font and color improvements... including implementing dw_window_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
738
diff
changeset
|
6286 { |
745
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
6287 NSFont *font = [object font]; |
739
a0aec9a56914
Font and color improvements... including implementing dw_window_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
738
diff
changeset
|
6288 NSString *fontname = [font fontName]; |
a0aec9a56914
Font and color improvements... including implementing dw_window_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
738
diff
changeset
|
6289 NSString *output = [NSString stringWithFormat:@"%d.%s", (int)[font pointSize], [fontname UTF8String]]; |
a0aec9a56914
Font and color improvements... including implementing dw_window_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
738
diff
changeset
|
6290 return strdup([output UTF8String]); |
a0aec9a56914
Font and color improvements... including implementing dw_window_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
738
diff
changeset
|
6291 } |
a0aec9a56914
Font and color improvements... including implementing dw_window_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
738
diff
changeset
|
6292 return NULL; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
6293 } |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
6294 |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
6295 /* |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6296 * 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
|
6297 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6298 * handle: The window handle to destroy. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6299 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6300 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
|
6301 { |
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
|
6302 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
|
6303 DW_MUTEX_LOCK; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6304 NSObject *object = handle; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
6305 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6306 if([ object isKindOfClass:[ NSWindow class ] ]) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6307 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6308 NSWindow *window = handle; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6309 [window close]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6310 } |
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
|
6311 DW_MUTEX_UNLOCK; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6312 return 0; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6313 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6314 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6315 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6316 * 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
|
6317 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6318 * handle: Handle to the window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6319 * Returns: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6320 * 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
|
6321 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6322 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
|
6323 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6324 NSObject *object = handle; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
6325 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6326 if([ object isKindOfClass:[ NSControl class ] ]) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6327 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6328 NSControl *control = handle; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6329 NSString *nsstr = [ control stringValue]; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
6330 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6331 return strdup([ nsstr UTF8String ]); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6332 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6333 else if([ object isKindOfClass:[ NSWindow class ] ]) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6334 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6335 NSWindow *window = handle; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6336 NSString *nsstr = [ window title]; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
6337 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6338 return strdup([ nsstr UTF8String ]); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6339 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6340 return NULL; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6341 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6342 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6343 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6344 * 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
|
6345 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6346 * handle: Handle to the window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6347 * 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
|
6348 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6349 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
|
6350 { |
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
|
6351 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
|
6352 DW_MUTEX_LOCK; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6353 NSObject *object = handle; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
6354 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6355 if([ object isKindOfClass:[ NSControl class ] ]) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6356 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6357 NSControl *control = handle; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6358 [control setStringValue:[ NSString stringWithUTF8String:text ]]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6359 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6360 else if([ object isKindOfClass:[ NSWindow class ] ]) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6361 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6362 NSWindow *window = handle; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6363 [window setTitle:[ NSString stringWithUTF8String:text ]]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6364 } |
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
|
6365 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6366 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6367 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6368 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6369 * Disables given window (widget). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6370 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6371 * handle: Handle to the window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6372 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6373 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
|
6374 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6375 NSObject *object = handle; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6376 if([ object isKindOfClass:[ NSControl class ] ]) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6377 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6378 NSControl *control = handle; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6379 [control setEnabled:NO]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6380 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6381 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6382 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6383 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6384 * Enables given window (widget). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6385 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6386 * handle: Handle to the window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6387 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6388 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
|
6389 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6390 NSObject *object = handle; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6391 if([ object isKindOfClass:[ NSControl class ] ]) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6392 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6393 NSControl *control = handle; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6394 [control setEnabled:YES]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6395 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6396 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6397 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6398 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6399 * 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
|
6400 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6401 * handle: Handle to the window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6402 * 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
|
6403 * (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
|
6404 * 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
|
6405 * 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
|
6406 * 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
|
6407 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
6408 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
|
6409 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6410 NSObject *object = handle; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6411 if([ object isKindOfClass:[ NSImageView class ] ]) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6412 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6413 NSImageView *iv = handle; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
6414 NSData *thisdata = [NSData dataWithBytes:data length:len]; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6415 NSImage *pixmap = [[NSImage alloc] initWithData:thisdata]; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
6416 |
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
|
6417 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
|
6418 { |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
6419 [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
|
6420 } |
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
|
6421 [pixmap release]; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6422 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6423 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6424 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6425 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6426 * 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
|
6427 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6428 * handle: Handle to the window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6429 * 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
|
6430 * (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
|
6431 * 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
|
6432 * 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
|
6433 * 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
|
6434 */ |
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
|
6435 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
|
6436 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6437 NSObject *object = handle; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6438 if([ object isKindOfClass:[ NSImageView class ] ]) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6439 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6440 NSImageView *iv = handle; |
745
d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
744
diff
changeset
|
6441 NSImage *bitmap = nil; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
6442 |
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
|
6443 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
|
6444 { |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
6445 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
|
6446 } |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
6447 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
|
6448 { |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
6449 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
|
6450 } |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
6451 |
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
|
6452 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
|
6453 { |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
6454 [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
|
6455 } |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6456 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6457 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6458 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6459 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6460 * 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
|
6461 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6462 * handle: Handle to the window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6463 * 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
|
6464 */ |
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
|
6465 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
|
6466 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6467 /* 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
|
6468 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6469 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6470 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6471 * 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
|
6472 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6473 * handle: Handle to the parent window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6474 * id: Integer ID of the child. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6475 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
6476 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
|
6477 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6478 NSObject *object = handle; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6479 NSView *view = handle; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6480 if([ object isKindOfClass:[ NSWindow class ] ]) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6481 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6482 NSWindow *window = handle; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6483 view = [window contentView]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6484 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6485 return [view viewWithTag:cid]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6486 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6487 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6488 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6489 * 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
|
6490 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6491 * handle: The window handle to minimize. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6492 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6493 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
|
6494 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6495 NSWindow *window = handle; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6496 [window miniaturize:nil]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6497 return 0; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6498 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6499 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6500 /* 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
|
6501 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6502 * 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
|
6503 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6504 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
|
6505 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6506 NSWindow *window = handle; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6507 [window flushWindow]; |
650
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 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6510 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6511 * Makes the window topmost. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6512 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6513 * 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
|
6514 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6515 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
|
6516 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6517 NSWindow *window = handle; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6518 [window orderFront:nil]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6519 return 0; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6520 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6521 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6522 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6523 * Makes the window bottommost. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6524 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6525 * 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
|
6526 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6527 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
|
6528 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6529 NSWindow *window = handle; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6530 [window orderBack:nil]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6531 return 0; |
650
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 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6534 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6535 * 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
|
6536 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6537 * handle: Window (widget) handle. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6538 * width: New width in pixels. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6539 * height: New height in pixels. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6540 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6541 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
|
6542 { |
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
|
6543 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
|
6544 DW_MUTEX_LOCK; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6545 NSObject *object = handle; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6546 NSSize size; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6547 size.width = width; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6548 size.height = height; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
6549 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6550 if([ object isKindOfClass:[ NSWindow class ] ]) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6551 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6552 NSWindow *window = handle; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6553 [window setContentSize:size]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6554 } |
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
|
6555 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6556 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6557 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6558 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6559 * 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
|
6560 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6561 * handle: Window (widget) handle. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6562 * 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
|
6563 * 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
|
6564 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6565 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
|
6566 { |
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
|
6567 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
|
6568 DW_MUTEX_LOCK; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6569 NSObject *object = handle; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6570 NSPoint point; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6571 point.x = x; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6572 point.y = y; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
6573 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6574 if([ object isKindOfClass:[ NSWindow class ] ]) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6575 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6576 NSWindow *window = handle; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6577 [window setFrameOrigin:point]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6578 } |
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
|
6579 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6580 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6581 |
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 * 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
|
6584 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6585 * handle: Window (widget) handle. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6586 * 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
|
6587 * 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
|
6588 * width: Width of the widget. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6589 * height: Height of the widget. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6590 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6591 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
|
6592 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6593 dw_window_set_pos(handle, x, y); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6594 dw_window_set_size(handle, width, height); |
650
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 |
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 * 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
|
6599 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6600 * handle: Window (widget) handle. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6601 * 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
|
6602 * 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
|
6603 * width: Width of the widget. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6604 * height: Height of the widget. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6605 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6606 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
|
6607 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6608 NSObject *object = handle; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
6609 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6610 if([ object isKindOfClass:[ NSWindow class ] ]) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6611 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6612 NSWindow *window = handle; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6613 NSRect rect = [window frame]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6614 if(x) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6615 *x = rect.origin.x; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6616 if(y) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6617 *y = rect.origin.y; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6618 if(width) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6619 *width = rect.size.width; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6620 if(height) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6621 *height = rect.size.height; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6622 return; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6623 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6624 } |
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 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6627 * Returns the width of the screen. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6628 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6629 int API dw_screen_width(void) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6630 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6631 NSRect screenRect = [[NSScreen mainScreen] frame]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6632 return screenRect.size.width; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6633 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6634 |
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 * Returns the height of the screen. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6637 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6638 int API dw_screen_height(void) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6639 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6640 NSRect screenRect = [[NSScreen mainScreen] frame]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6641 return screenRect.size.height; |
650
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 /* 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
|
6645 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
|
6646 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6647 NSWindowDepth screenDepth = [[NSScreen mainScreen] depth]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6648 return NSBitsPerPixelFromDepth(screenDepth); |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6649 } |
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 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6652 * 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
|
6653 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6654 * env: Pointer to a DWEnv struct. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6655 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6656 void dw_environment_query(DWEnv *env) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6657 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6658 struct utsname name; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
6659 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6660 uname(&name); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6661 strcpy(env->osName, "MacOS"); |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
6662 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6663 strcpy(env->buildDate, __DATE__); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6664 strcpy(env->buildTime, __TIME__); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6665 env->DWMajorVersion = DW_MAJOR_VERSION; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6666 env->DWMinorVersion = DW_MINOR_VERSION; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6667 env->DWSubVersion = DW_SUB_VERSION; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
6668 |
751
eba6ab48c952
Runtime Snow Leopard checks where possible and visual fix for Leopard status text.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
749
diff
changeset
|
6669 env->MajorVersion = DWOSMajor; |
eba6ab48c952
Runtime Snow Leopard checks where possible and visual fix for Leopard status text.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
749
diff
changeset
|
6670 env->MinorVersion = DWOSMinor; |
eba6ab48c952
Runtime Snow Leopard checks where possible and visual fix for Leopard status text.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
749
diff
changeset
|
6671 env->MajorBuild = DWOSBuild; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6672 } |
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 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6675 * Emits a beep. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6676 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6677 * freq: Frequency. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6678 * dur: Duration. |
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 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
|
6681 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6682 NSBeep(); |
650
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 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6685 /* 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
|
6686 * anything you have drawn is visible. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6687 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6688 void API dw_flush(void) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6689 { |
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
|
6690 /* 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
|
6691 [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
|
6692 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6693 |
651
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6694 /* 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
|
6695 * 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
|
6696 * dw_window_get_data(). |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6697 */ |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6698 UserData *_find_userdata(UserData **root, char *varname) |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6699 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6700 UserData *tmp = *root; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
6701 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6702 while(tmp) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6703 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6704 if(strcasecmp(tmp->varname, varname) == 0) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6705 return tmp; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6706 tmp = tmp->next; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6707 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6708 return NULL; |
651
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6709 } |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6710 |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6711 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
|
6712 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6713 UserData *new = _find_userdata(root, varname); |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
6714 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6715 if(new) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6716 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6717 new->data = data; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6718 return TRUE; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6719 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6720 else |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6721 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6722 new = malloc(sizeof(UserData)); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6723 if(new) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6724 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6725 new->varname = strdup(varname); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6726 new->data = data; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
6727 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6728 new->next = NULL; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
6729 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6730 if (!*root) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6731 *root = new; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6732 else |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6733 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6734 UserData *prev = NULL, *tmp = *root; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6735 while(tmp) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6736 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6737 prev = tmp; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6738 tmp = tmp->next; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6739 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6740 if(prev) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6741 prev->next = new; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6742 else |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6743 *root = new; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6744 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6745 return TRUE; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6746 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6747 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6748 return FALSE; |
651
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6749 } |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6750 |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6751 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
|
6752 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6753 UserData *prev = NULL, *tmp = *root; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
6754 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6755 while(tmp) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6756 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6757 if(all || strcasecmp(tmp->varname, varname) == 0) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6758 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6759 if(!prev) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6760 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6761 *root = tmp->next; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6762 free(tmp->varname); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6763 free(tmp); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6764 if(!all) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6765 return 0; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6766 tmp = *root; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6767 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6768 else |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6769 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6770 /* If all is true we should |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6771 * never get here. |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6772 */ |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6773 prev->next = tmp->next; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6774 free(tmp->varname); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6775 free(tmp); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6776 return 0; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6777 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6778 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6779 else |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6780 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6781 prev = tmp; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6782 tmp = tmp->next; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6783 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6784 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6785 return 0; |
651
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6786 } |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6787 |
650
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 * 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
|
6790 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6791 * 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
|
6792 * 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
|
6793 * 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
|
6794 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6795 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
|
6796 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6797 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
|
6798 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
|
6799 { |
5fe12469c1fb
Fix for dw_window_set/get_data() on a top-level window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
680
diff
changeset
|
6800 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
|
6801 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
|
6802 } |
5fe12469c1fb
Fix for dw_window_set/get_data() on a top-level window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
680
diff
changeset
|
6803 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
|
6804 { |
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
6805 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
|
6806 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
|
6807 } |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6808 WindowData *blah = (WindowData *)[object userdata]; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
6809 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6810 if(!blah) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6811 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6812 if(!dataname) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6813 return; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
6814 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6815 blah = calloc(1, sizeof(WindowData)); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6816 [object setUserdata:blah]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6817 } |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
6818 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6819 if(data) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6820 _new_userdata(&(blah->root), dataname, data); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6821 else |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6822 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6823 if(dataname) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6824 _remove_userdata(&(blah->root), dataname, FALSE); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6825 else |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6826 _remove_userdata(&(blah->root), NULL, TRUE); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6827 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6828 } |
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 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6831 * 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
|
6832 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6833 * 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
|
6834 * 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
|
6835 * 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
|
6836 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6837 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
|
6838 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6839 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
|
6840 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
|
6841 { |
5fe12469c1fb
Fix for dw_window_set/get_data() on a top-level window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
680
diff
changeset
|
6842 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
|
6843 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
|
6844 } |
5fe12469c1fb
Fix for dw_window_set/get_data() on a top-level window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
680
diff
changeset
|
6845 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
|
6846 { |
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
6847 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
|
6848 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
|
6849 } |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6850 WindowData *blah = (WindowData *)[object userdata]; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
6851 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6852 if(blah && blah->root && dataname) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6853 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6854 UserData *ud = _find_userdata(&(blah->root), dataname); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6855 if(ud) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6856 return ud->data; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6857 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6858 return NULL; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6859 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6860 |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
6861 #define DW_TIMER_MAX 64 |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
6862 NSTimer *DWTimers[DW_TIMER_MAX]; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
6863 |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6864 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6865 * 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
|
6866 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6867 * interval: Milliseconds to delay between calls. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6868 * 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
|
6869 * 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
|
6870 * Returns: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6871 * 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
|
6872 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6873 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
|
6874 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6875 int z; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
6876 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6877 for(z=0;z<DW_TIMER_MAX;z++) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6878 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6879 if(!DWTimers[z]) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6880 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6881 break; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6882 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6883 } |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
6884 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6885 if(sigfunc && !DWTimers[z]) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6886 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6887 NSTimeInterval seconds = (double)interval / 1000.0; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6888 NSTimer *thistimer = DWTimers[z] = [NSTimer scheduledTimerWithTimeInterval:seconds target:DWHandler selector:@selector(runTimer:) userInfo:nil repeats:YES]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6889 _new_signal(0, thistimer, z+1, sigfunc, data); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6890 return z+1; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6891 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6892 return 0; |
650
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 |
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 * Removes timer callback. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6897 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6898 * 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
|
6899 */ |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
6900 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
|
6901 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6902 SignalHandler *prev = NULL, *tmp = Root; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6903 NSTimer *thistimer; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
6904 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6905 /* 0 is an invalid timer ID */ |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6906 if(timerid < 1 || !DWTimers[timerid-1]) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6907 return; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
6908 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6909 thistimer = DWTimers[timerid-1]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6910 DWTimers[timerid-1] = nil; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
6911 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6912 [thistimer invalidate]; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
6913 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6914 while(tmp) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6915 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6916 if(tmp->id == timerid && tmp->window == thistimer) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6917 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6918 if(prev) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6919 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6920 prev->next = tmp->next; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6921 free(tmp); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6922 tmp = prev->next; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6923 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6924 else |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6925 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6926 Root = tmp->next; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6927 free(tmp); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6928 tmp = Root; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6929 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6930 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6931 else |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6932 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6933 prev = tmp; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6934 tmp = tmp->next; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6935 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6936 } |
650
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 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6940 * 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
|
6941 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6942 * 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
|
6943 * 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
|
6944 * 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
|
6945 * 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
|
6946 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6947 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
|
6948 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6949 ULONG message = 0, msgid = 0; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6950 |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6951 if(window && signame && sigfunc) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6952 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6953 if((message = _findsigmessage(signame)) != 0) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6954 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6955 _new_signal(message, window, (int)msgid, sigfunc, data); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6956 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6957 } |
650
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 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6960 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6961 * 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
|
6962 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6963 * 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
|
6964 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6965 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
|
6966 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6967 SignalHandler *prev = NULL, *tmp = Root; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6968 ULONG message; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
6969 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6970 if(!window || !signame || (message = _findsigmessage(signame)) == 0) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6971 return; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
6972 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6973 while(tmp) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6974 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6975 if(tmp->window == window && tmp->message == message) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6976 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6977 if(prev) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6978 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6979 prev->next = tmp->next; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6980 free(tmp); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6981 tmp = prev->next; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6982 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6983 else |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6984 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6985 Root = tmp->next; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6986 free(tmp); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6987 tmp = Root; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6988 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6989 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6990 else |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6991 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6992 prev = tmp; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6993 tmp = tmp->next; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6994 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6995 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6996 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6997 |
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 * 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
|
7000 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7001 * 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
|
7002 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7003 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
|
7004 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7005 SignalHandler *prev = NULL, *tmp = Root; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
7006 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7007 while(tmp) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7008 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7009 if(tmp->window == window) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7010 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7011 if(prev) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7012 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7013 prev->next = tmp->next; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7014 free(tmp); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7015 tmp = prev->next; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7016 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7017 else |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7018 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7019 Root = tmp->next; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7020 free(tmp); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7021 tmp = Root; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7022 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7023 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7024 else |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7025 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7026 prev = tmp; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7027 tmp = tmp->next; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7028 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7029 } |
650
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 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7032 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7033 * 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
|
7034 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7035 * 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
|
7036 * 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
|
7037 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7038 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
|
7039 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7040 SignalHandler *prev = NULL, *tmp = Root; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
7041 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7042 while(tmp) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7043 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7044 if(tmp->window == window && tmp->data == data) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7045 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7046 if(prev) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7047 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7048 prev->next = tmp->next; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7049 free(tmp); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7050 tmp = prev->next; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7051 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7052 else |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7053 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7054 Root = tmp->next; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7055 free(tmp); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7056 tmp = Root; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7057 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7058 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7059 else |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7060 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7061 prev = tmp; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7062 tmp = tmp->next; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7063 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7064 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7065 } |
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 void _my_strlwr(char *buf) |
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 int z, len = strlen(buf); |
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 for(z=0;z<len;z++) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7072 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7073 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
|
7074 buf[z] -= 'A' - 'a'; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7075 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7076 } |
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 /* 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
|
7079 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7080 * 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
|
7081 * handle: Pointer to a module handle, |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7082 * 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
|
7083 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7084 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
|
7085 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7086 int len; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7087 char *newname; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7088 char errorbuf[1024]; |
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 if(!handle) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7092 return -1; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7093 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7094 if((len = strlen(name)) == 0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7095 return -1; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7096 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7097 /* Lenth + "lib" + ".dylib" + NULL */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7098 newname = malloc(len + 10); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7099 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7100 if(!newname) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7101 return -1; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7102 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7103 sprintf(newname, "lib%s.dylib", name); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7104 _my_strlwr(newname); |
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 *handle = dlopen(newname, RTLD_NOW); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7107 if(*handle == 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 strncpy(errorbuf, dlerror(), 1024); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7110 printf("%s\n", errorbuf); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7111 sprintf(newname, "lib%s.dylib", name); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7112 *handle = dlopen(newname, RTLD_NOW); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7113 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7114 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7115 free(newname); |
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 return (NULL == *handle) ? -1 : 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7118 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7119 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7120 /* 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
|
7121 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7122 * 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
|
7123 * 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
|
7124 * 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
|
7125 * the address. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7126 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7127 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
|
7128 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7129 if(!func || !name) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7130 return -1; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7131 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7132 if(strlen(name) == 0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7133 return -1; |
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 *func = (void*)dlsym(handle, name); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7136 return (NULL == *func); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7137 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7138 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7139 /* Frees the shared library previously opened. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7140 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7141 * 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
|
7142 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7143 int dw_module_close(HMOD handle) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7144 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7145 if(handle) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7146 return dlclose(handle); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7147 return 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7148 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7149 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7150 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7151 * 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
|
7152 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7153 HMTX dw_mutex_new(void) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7154 { |
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
|
7155 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
|
7156 |
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
|
7157 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
|
7158 return mutex; |
650
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 |
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 * 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
|
7163 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7164 * 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
|
7165 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7166 void dw_mutex_close(HMTX mutex) |
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 if(mutex) |
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 pthread_mutex_destroy(mutex); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7171 free(mutex); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7172 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7173 } |
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 * 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
|
7177 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7178 * 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
|
7179 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7180 void dw_mutex_lock(HMTX mutex) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7181 { |
693
2f21ee9d7c7b
Experimental change for locking on the main thread... will be committing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
692
diff
changeset
|
7182 /* We need to handle locks from the main thread differently... |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
7183 * since we can't stop message processing... otherwise we |
693
2f21ee9d7c7b
Experimental change for locking on the main thread... will be committing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
692
diff
changeset
|
7184 * 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
|
7185 * 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
|
7186 */ |
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
|
7187 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
|
7188 { |
693
2f21ee9d7c7b
Experimental change for locking on the main thread... will be committing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
692
diff
changeset
|
7189 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
|
7190 { |
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
|
7191 /* 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
|
7192 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
|
7193 { |
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
|
7194 /* 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
|
7195 } |
693
2f21ee9d7c7b
Experimental change for locking on the main thread... will be committing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
692
diff
changeset
|
7196 } |
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
|
7197 } |
693
2f21ee9d7c7b
Experimental change for locking on the main thread... will be committing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
692
diff
changeset
|
7198 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
|
7199 { |
693
2f21ee9d7c7b
Experimental change for locking on the main thread... will be committing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
692
diff
changeset
|
7200 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
|
7201 } |
650
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 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7205 * Reliquishes the access to the semaphore. |
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 * 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
|
7208 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7209 void dw_mutex_unlock(HMTX mutex) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7210 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7211 pthread_mutex_unlock(mutex); |
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 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7214 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7215 * 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
|
7216 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7217 HEV dw_event_new(void) |
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 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
|
7220 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7221 if(!eve) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7222 return NULL; |
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 /* 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
|
7225 * 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
|
7226 * 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
|
7227 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7228 pthread_mutex_init (&(eve->mutex), NULL); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7229 pthread_mutex_lock (&(eve->mutex)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7230 pthread_cond_init (&(eve->event), NULL); |
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 pthread_mutex_unlock (&(eve->mutex)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7233 eve->alive = 1; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7234 eve->posted = 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7235 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7236 return eve; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7237 } |
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 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7240 * 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
|
7241 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7242 * 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
|
7243 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7244 int dw_event_reset (HEV eve) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7245 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7246 if(!eve) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7247 return FALSE; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7248 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7249 pthread_mutex_lock (&(eve->mutex)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7250 pthread_cond_broadcast (&(eve->event)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7251 pthread_cond_init (&(eve->event), NULL); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7252 eve->posted = 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7253 pthread_mutex_unlock (&(eve->mutex)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7254 return 0; |
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 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7257 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7258 * 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
|
7259 * 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
|
7260 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7261 * 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
|
7262 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7263 int dw_event_post (HEV eve) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7264 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7265 if(!eve) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7266 return FALSE; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7267 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7268 pthread_mutex_lock (&(eve->mutex)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7269 pthread_cond_broadcast (&(eve->event)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7270 eve->posted = 1; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7271 pthread_mutex_unlock (&(eve->mutex)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7272 return 0; |
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 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7275 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7276 * 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
|
7277 * 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
|
7278 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7279 * 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
|
7280 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7281 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
|
7282 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7283 int rc; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7284 struct timeval now; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7285 struct timespec timeo; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7286 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7287 if(!eve) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7288 return FALSE; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7289 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7290 if(eve->posted) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7291 return 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7292 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7293 pthread_mutex_lock (&(eve->mutex)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7294 gettimeofday(&now, 0); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7295 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
|
7296 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
|
7297 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
|
7298 pthread_mutex_unlock (&(eve->mutex)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7299 if(!rc) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7300 return 1; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7301 if(rc == ETIMEDOUT) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7302 return -1; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7303 return 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7304 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7305 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7306 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7307 * 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
|
7308 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7309 * 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
|
7310 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7311 int dw_event_close(HEV *eve) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7312 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7313 if(!eve || !(*eve)) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7314 return FALSE; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7315 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7316 pthread_mutex_lock (&((*eve)->mutex)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7317 pthread_cond_destroy (&((*eve)->event)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7318 pthread_mutex_unlock (&((*eve)->mutex)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7319 pthread_mutex_destroy (&((*eve)->mutex)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7320 free(*eve); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7321 *eve = NULL; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7322 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7323 return TRUE; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7324 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7325 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7326 struct _seminfo { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7327 int fd; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7328 int waiting; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7329 }; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7330 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7331 static void _handle_sem(int *tmpsock) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7332 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7333 fd_set rd; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7334 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
|
7335 int listenfd = tmpsock[0]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7336 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
|
7337 char command; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7338 sigset_t mask; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7339 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7340 sigfillset(&mask); /* Mask all allowed signals */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7341 pthread_sigmask(SIG_BLOCK, &mask, NULL); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7342 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7343 /* problems */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7344 if(tmpsock[1] == -1) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7345 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7346 free(array); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7347 return; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7348 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7349 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7350 array[0].fd = tmpsock[1]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7351 array[0].waiting = 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7352 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7353 /* 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
|
7354 free(tmpsock); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7355 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7356 while(1) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7357 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7358 FD_ZERO(&rd); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7359 FD_SET(listenfd, &rd); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7360 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7361 maxfd = listenfd; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7362 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7363 /* 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
|
7364 for(z=0;z<connectcount;z++) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7365 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7366 if(array[z].fd > maxfd) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7367 maxfd = array[z].fd; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7368 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7369 FD_SET(array[z].fd, &rd); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7370 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7371 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7372 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
|
7373 return; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7374 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7375 if(FD_ISSET(listenfd, &rd)) |
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 struct _seminfo *newarray; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7378 int newfd = accept(listenfd, 0, 0); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7379 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7380 if(newfd > -1) |
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 /* Add new connections to the set */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7383 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
|
7384 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
|
7385 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7386 newarray[connectcount].fd = newfd; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7387 newarray[connectcount].waiting = 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7388 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7389 connectcount++; |
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 /* Replace old array with new one */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7392 free(array); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7393 array = newarray; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7394 } |
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 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7397 /* 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
|
7398 for(z=0;z<connectcount;z++) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7399 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7400 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
|
7401 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7402 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
|
7403 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7404 struct _seminfo *newarray; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7405 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7406 /* Remove this connection from the set */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7407 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
|
7408 if(!z) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7409 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
|
7410 else |
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 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
|
7413 if(z!=(connectcount-1)) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7414 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
|
7415 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7416 connectcount--; |
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 /* Replace old array with new one */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7419 free(array); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7420 array = newarray; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7421 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7422 else if(bytesread == 1) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7423 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7424 switch(command) |
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 case 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 /* Reset */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7429 posted = 0; |
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 break; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7432 case 1: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7433 /* Post */ |
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 int s; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7436 char tmp = (char)0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7437 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7438 posted = 1; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7439 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7440 for(s=0;s<connectcount;s++) |
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 /* The semaphore has been posted so |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7443 * 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
|
7444 * continue. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7445 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7446 if(array[s].waiting) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7447 write(array[s].fd, &tmp, 1); |
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 break; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7451 case 2: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7452 /* Wait */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7453 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7454 char tmp = (char)0; |
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 array[z].waiting = 1; |
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 /* If we are posted exit immeditately */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7459 if(posted) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7460 write(array[z].fd, &tmp, 1); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7461 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7462 break; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7463 case 3: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7464 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7465 /* Done Waiting */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7466 array[z].waiting = 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7467 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7468 break; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7469 } |
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 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7472 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7473 |
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 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7476 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7477 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7478 /* 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
|
7479 /* 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
|
7480 * opened from other processes. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7481 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7482 * 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
|
7483 * 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
|
7484 * by other processes. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7485 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7486 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
|
7487 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7488 struct sockaddr_un un; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7489 int ev, *tmpsock = (int *)malloc(sizeof(int)*2); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7490 HEV eve; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7491 DWTID dwthread; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7492 |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7493 if(!tmpsock) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7494 return NULL; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7495 |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7496 eve = (HEV)malloc(sizeof(struct _dw_unix_event)); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7497 |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7498 if(!eve) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7499 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7500 free(tmpsock); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7501 return NULL; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7502 } |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
7503 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7504 tmpsock[0] = socket(AF_UNIX, SOCK_STREAM, 0); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7505 ev = socket(AF_UNIX, SOCK_STREAM, 0); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7506 memset(&un, 0, sizeof(un)); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7507 un.sun_family=AF_UNIX; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7508 mkdir("/tmp/.dw", S_IWGRP|S_IWOTH); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7509 strcpy(un.sun_path, "/tmp/.dw/"); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7510 strcat(un.sun_path, name); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7511 |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7512 /* just to be safe, this should be changed |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7513 * to support multiple instances. |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7514 */ |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7515 remove(un.sun_path); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7516 |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7517 bind(tmpsock[0], (struct sockaddr *)&un, sizeof(un)); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7518 listen(tmpsock[0], 0); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7519 connect(ev, (struct sockaddr *)&un, sizeof(un)); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7520 tmpsock[1] = accept(tmpsock[0], 0, 0); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7521 |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7522 if(tmpsock[0] < 0 || tmpsock[1] < 0 || ev < 0) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7523 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7524 if(tmpsock[0] > -1) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7525 close(tmpsock[0]); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7526 if(tmpsock[1] > -1) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7527 close(tmpsock[1]); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7528 if(ev > -1) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7529 close(ev); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7530 free(tmpsock); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7531 free(eve); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7532 return NULL; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7533 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7534 |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7535 /* Create a thread to handle this event semaphore */ |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7536 pthread_create(&dwthread, NULL, (void *)_handle_sem, (void *)tmpsock); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7537 eve->alive = ev; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7538 return eve; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7539 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7540 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7541 /* 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
|
7542 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7543 * 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
|
7544 * 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
|
7545 * by other processes. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7546 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7547 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
|
7548 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7549 struct sockaddr_un un; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7550 HEV eve; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7551 int ev = socket(AF_UNIX, SOCK_STREAM, 0); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7552 if(ev < 0) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7553 return NULL; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7554 |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7555 eve = (HEV)malloc(sizeof(struct _dw_unix_event)); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7556 |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7557 if(!eve) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7558 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7559 close(ev); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7560 return NULL; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7561 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7562 |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7563 un.sun_family=AF_UNIX; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7564 mkdir("/tmp/.dw", S_IWGRP|S_IWOTH); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7565 strcpy(un.sun_path, "/tmp/.dw/"); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7566 strcat(un.sun_path, name); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7567 connect(ev, (struct sockaddr *)&un, sizeof(un)); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7568 eve->alive = ev; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7569 return eve; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7570 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7571 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7572 /* 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
|
7573 * on this semaphore will block. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7574 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7575 * 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
|
7576 * an open or create call. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7577 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7578 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
|
7579 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7580 /* signal reset */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7581 char tmp = (char)0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7582 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7583 if(!eve || eve->alive < 0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7584 return 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7585 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7586 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
|
7587 return 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7588 return 1; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7589 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7590 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7591 /* 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
|
7592 * 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
|
7593 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7594 * 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
|
7595 * an open or create call. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7596 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7597 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
|
7598 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7599 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7600 /* signal post */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7601 char tmp = (char)1; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7602 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7603 if(!eve || eve->alive < 0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7604 return 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7605 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7606 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
|
7607 return 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7608 return 1; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7609 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7610 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7611 /* 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
|
7612 * 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
|
7613 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7614 * 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
|
7615 * an open or create call. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7616 * 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
|
7617 * or -1 if indefinite. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7618 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7619 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
|
7620 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7621 fd_set rd; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7622 struct timeval tv, *useme; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7623 int retval = 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7624 char tmp; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7625 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7626 if(!eve || eve->alive < 0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7627 return DW_ERROR_NON_INIT; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7628 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7629 /* Set the timout or infinite */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7630 if(timeout == -1) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7631 useme = NULL; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7632 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7633 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7634 tv.tv_sec = timeout / 1000; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7635 tv.tv_usec = timeout % 1000; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7636 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7637 useme = &tv; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7638 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7639 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7640 FD_ZERO(&rd); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7641 FD_SET(eve->alive, &rd); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7642 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7643 /* Signal wait */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7644 tmp = (char)2; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7645 write(eve->alive, &tmp, 1); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7646 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7647 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
|
7648 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7649 /* Signal done waiting. */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7650 tmp = (char)3; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7651 write(eve->alive, &tmp, 1); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7652 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7653 if(retval == 0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7654 return DW_ERROR_TIMEOUT; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7655 else if(retval == -1) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7656 return DW_ERROR_INTERRUPT; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7657 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7658 /* 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
|
7659 * we don't loop endlessly. :) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7660 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7661 read(eve->alive, &tmp, 1); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7662 return 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7663 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7664 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7665 /* 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
|
7666 * 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
|
7667 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7668 * 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
|
7669 * an open or create call. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7670 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7671 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
|
7672 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7673 /* Finally close the domain socket, |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7674 * cleanup will continue in _handle_sem. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7675 */ |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7676 if(eve) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7677 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7678 close(eve->alive); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7679 free(eve); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7680 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7681 return 0; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7682 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7683 |
697
830e1f3672b9
Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
696
diff
changeset
|
7684 #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
|
7685 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
|
7686 #endif |
830e1f3672b9
Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
696
diff
changeset
|
7687 |
830e1f3672b9
Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
696
diff
changeset
|
7688 /* 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
|
7689 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
|
7690 { |
830e1f3672b9
Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
696
diff
changeset
|
7691 #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
|
7692 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
|
7693 [pool drain]; |
698
e19f69a78f21
Fix for pool being removed and not just drained.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
697
diff
changeset
|
7694 pool = [[NSAutoreleasePool alloc] init]; |
e19f69a78f21
Fix for pool being removed and not just drained.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
697
diff
changeset
|
7695 pthread_setspecific(_dw_pool_key, pool); |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
7696 #endif |
697
830e1f3672b9
Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
696
diff
changeset
|
7697 } |
830e1f3672b9
Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
696
diff
changeset
|
7698 |
830e1f3672b9
Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
696
diff
changeset
|
7699 /* |
830e1f3672b9
Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
696
diff
changeset
|
7700 * Setup thread independent pools. |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7701 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7702 void _dwthreadstart(void *data) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7703 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7704 void (*threadfunc)(void *) = NULL; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7705 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
|
7706 /* 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
|
7707 #if !defined(GARBAGE_COLLECT) |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7708 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
|
7709 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
|
7710 #endif |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
7711 |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7712 threadfunc = (void (*)(void *))tmp[0]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7713 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7714 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
|
7715 /* 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
|
7716 #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
|
7717 pool = pthread_getspecific(_dw_pool_key); |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7718 [pool drain]; |
666
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
7719 #endif |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7720 free(tmp); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7721 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7722 |
744
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
7723 void _dw_default_font(char *fontname) |
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
7724 { |
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
7725 if(DWDefaultFont) |
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
7726 { |
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
7727 [DWDefaultFont release]; |
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
7728 } |
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
7729 DWDefaultFont = _dw_font_by_name(fontname); |
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
7730 [DWDefaultFont retain]; |
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
7731 } |
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
7732 |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7733 /* |
697
830e1f3672b9
Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
696
diff
changeset
|
7734 * 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
|
7735 * Parameters: |
830e1f3672b9
Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
696
diff
changeset
|
7736 * 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
|
7737 * 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
|
7738 */ |
830e1f3672b9
Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
696
diff
changeset
|
7739 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
|
7740 { |
751
eba6ab48c952
Runtime Snow Leopard checks where possible and visual fix for Leopard status text.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
749
diff
changeset
|
7741 /* Get the operating system version */ |
eba6ab48c952
Runtime Snow Leopard checks where possible and visual fix for Leopard status text.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
749
diff
changeset
|
7742 Gestalt(gestaltSystemVersionMajor, &DWOSMajor); |
eba6ab48c952
Runtime Snow Leopard checks where possible and visual fix for Leopard status text.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
749
diff
changeset
|
7743 Gestalt(gestaltSystemVersionMinor, &DWOSMinor); |
eba6ab48c952
Runtime Snow Leopard checks where possible and visual fix for Leopard status text.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
749
diff
changeset
|
7744 Gestalt(gestaltSystemVersionBugFix, &DWOSBuild); |
736
5b48519a7fb2
Added retains to the window menus so they don't get autoreleased when switching between
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
735
diff
changeset
|
7745 /* Create the application object */ |
5b48519a7fb2
Added retains to the window menus so they don't get autoreleased when switching between
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
735
diff
changeset
|
7746 DWApp = [NSApplication sharedApplication]; |
5b48519a7fb2
Added retains to the window menus so they don't get autoreleased when switching between
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
735
diff
changeset
|
7747 /* Create object for handling timers */ |
5b48519a7fb2
Added retains to the window menus so they don't get autoreleased when switching between
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
735
diff
changeset
|
7748 DWHandler = [[DWTimerHandler 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
|
7749 /* 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
|
7750 #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
|
7751 pthread_key_create(&_dw_pool_key, NULL); |
736
5b48519a7fb2
Added retains to the window menus so they don't get autoreleased when switching between
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
735
diff
changeset
|
7752 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
|
7753 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
|
7754 #endif |
830e1f3672b9
Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
696
diff
changeset
|
7755 /* Create a default main menu, with just the application menu */ |
736
5b48519a7fb2
Added retains to the window menus so they don't get autoreleased when switching between
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
735
diff
changeset
|
7756 DWMainMenu = _generate_main_menu(); |
5b48519a7fb2
Added retains to the window menus so they don't get autoreleased when switching between
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
735
diff
changeset
|
7757 [DWMainMenu retain]; |
5b48519a7fb2
Added retains to the window menus so they don't get autoreleased when switching between
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
735
diff
changeset
|
7758 [DWApp setMainMenu:DWMainMenu]; |
5b48519a7fb2
Added retains to the window menus so they don't get autoreleased when switching between
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
735
diff
changeset
|
7759 DWObj = [[DWObject alloc] init]; |
744
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
7760 DWDefaultFont = nil; |
697
830e1f3672b9
Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
696
diff
changeset
|
7761 /* 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
|
7762 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
|
7763 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
|
7764 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
|
7765 /* Use NSThread to start a dummy thread to initialize the threading subsystem */ |
736
5b48519a7fb2
Added retains to the window menus so they don't get autoreleased when switching between
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
735
diff
changeset
|
7766 NSThread *thread = [[ NSThread alloc] initWithTarget:DWObj selector:@selector(uselessThread:) object:nil]; |
5b48519a7fb2
Added retains to the window menus so they don't get autoreleased when switching between
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
735
diff
changeset
|
7767 [thread start]; |
697
830e1f3672b9
Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
696
diff
changeset
|
7768 [thread release]; |
736
5b48519a7fb2
Added retains to the window menus so they don't get autoreleased when switching between
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
735
diff
changeset
|
7769 return 0; |
697
830e1f3672b9
Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
696
diff
changeset
|
7770 } |
830e1f3672b9
Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
696
diff
changeset
|
7771 |
830e1f3672b9
Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
696
diff
changeset
|
7772 /* |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7773 * 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
|
7774 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7775 * 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
|
7776 * 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
|
7777 * 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
|
7778 * 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
|
7779 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7780 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
|
7781 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7782 char namebuf[1024]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7783 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
|
7784 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7785 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
|
7786 sprintf(namebuf, "/tmp/.dw/%s", name); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7787 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7788 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
|
7789 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7790 free(handle); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7791 return NULL; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7792 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7793 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7794 ftruncate(handle->fd, size); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7795 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7796 /* 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
|
7797 *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
|
7798 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7799 if(*dest == MAP_FAILED) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7800 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7801 close(handle->fd); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7802 *dest = NULL; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7803 free(handle); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7804 return NULL; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7805 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7806 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7807 handle->size = size; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7808 handle->sid = getsid(0); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7809 handle->path = strdup(namebuf); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7810 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7811 return handle; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7812 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7813 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7814 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7815 * 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
|
7816 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7817 * 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
|
7818 * 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
|
7819 * 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
|
7820 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7821 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
|
7822 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7823 char namebuf[1024]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7824 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
|
7825 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7826 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
|
7827 sprintf(namebuf, "/tmp/.dw/%s", name); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7828 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7829 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
|
7830 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7831 free(handle); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7832 return NULL; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7833 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7834 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7835 /* 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
|
7836 *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
|
7837 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7838 if(*dest == MAP_FAILED) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7839 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7840 close(handle->fd); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7841 *dest = NULL; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7842 free(handle); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7843 return NULL; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7844 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7845 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7846 handle->size = size; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7847 handle->sid = -1; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7848 handle->path = NULL; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7849 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7850 return handle; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7851 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7852 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7853 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7854 * 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
|
7855 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7856 * 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
|
7857 * 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
|
7858 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7859 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
|
7860 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7861 struct _dw_unix_shm *h = handle; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7862 int rc = munmap(ptr, h->size); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7863 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7864 close(h->fd); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7865 if(h->path) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7866 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7867 /* 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
|
7868 * creator of the file. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7869 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7870 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
|
7871 remove(h->path); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7872 free(h->path); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7873 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7874 return rc; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7875 } |
697
830e1f3672b9
Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
696
diff
changeset
|
7876 |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7877 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7878 * 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
|
7879 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7880 * 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
|
7881 * 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
|
7882 * 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
|
7883 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7884 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
|
7885 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7886 DWTID thread; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7887 void **tmp = malloc(sizeof(void *) * 2); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7888 int rc; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7889 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7890 tmp[0] = func; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7891 tmp[1] = data; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7892 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7893 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
|
7894 if(rc == 0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7895 return thread; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7896 return (DWTID)-1; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7897 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7898 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7899 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7900 * Ends execution of current thread immediately. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7901 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7902 void dw_thread_end(void) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7903 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7904 pthread_exit(NULL); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7905 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7906 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7907 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7908 * Returns the current thread's ID. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7909 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7910 DWTID dw_thread_id(void) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7911 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7912 return (DWTID)pthread_self(); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7913 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7914 |
661
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7915 /* |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7916 * 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
|
7917 * Parameters: |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7918 * program: Program name with optional path. |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7919 * 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
|
7920 * 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
|
7921 * Returns: |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7922 * -1 on error. |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7923 */ |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7924 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
|
7925 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7926 int ret = -1; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
7927 |
738
52d5ed00f892
Use NSWorkplace to launch GUI applications instead of fork() and exec().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
737
diff
changeset
|
7928 if(type == DW_EXEC_GUI) |
52d5ed00f892
Use NSWorkplace to launch GUI applications instead of fork() and exec().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
737
diff
changeset
|
7929 { |
52d5ed00f892
Use NSWorkplace to launch GUI applications instead of fork() and exec().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
737
diff
changeset
|
7930 if(params && params[0] && params[1]) |
52d5ed00f892
Use NSWorkplace to launch GUI applications instead of fork() and exec().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
737
diff
changeset
|
7931 { |
52d5ed00f892
Use NSWorkplace to launch GUI applications instead of fork() and exec().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
737
diff
changeset
|
7932 [[NSWorkspace sharedWorkspace] openFile:[NSString stringWithUTF8String:params[1]] |
52d5ed00f892
Use NSWorkplace to launch GUI applications instead of fork() and exec().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
737
diff
changeset
|
7933 withApplication:[NSString stringWithUTF8String:program]]; |
52d5ed00f892
Use NSWorkplace to launch GUI applications instead of fork() and exec().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
737
diff
changeset
|
7934 } |
52d5ed00f892
Use NSWorkplace to launch GUI applications instead of fork() and exec().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
737
diff
changeset
|
7935 else |
52d5ed00f892
Use NSWorkplace to launch GUI applications instead of fork() and exec().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
737
diff
changeset
|
7936 { |
52d5ed00f892
Use NSWorkplace to launch GUI applications instead of fork() and exec().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
737
diff
changeset
|
7937 [[NSWorkspace sharedWorkspace] launchApplication:[NSString stringWithUTF8String:program]]; |
52d5ed00f892
Use NSWorkplace to launch GUI applications instead of fork() and exec().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
737
diff
changeset
|
7938 } |
52d5ed00f892
Use NSWorkplace to launch GUI applications instead of fork() and exec().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
737
diff
changeset
|
7939 return 0; |
52d5ed00f892
Use NSWorkplace to launch GUI applications instead of fork() and exec().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
737
diff
changeset
|
7940 } |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
7941 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7942 if((ret = fork()) == 0) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7943 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7944 int i; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
7945 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7946 for (i = 3; i < 256; i++) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7947 close(i); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7948 setsid(); |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
7949 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7950 if(type == DW_EXEC_CON) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7951 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7952 char **tmpargs; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
7953 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7954 if(!params) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7955 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7956 tmpargs = malloc(sizeof(char *)); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7957 tmpargs[0] = NULL; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7958 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7959 else |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7960 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7961 int z = 0; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
7962 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7963 while(params[z]) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7964 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7965 z++; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7966 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7967 tmpargs = malloc(sizeof(char *)*(z+3)); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7968 z=0; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7969 tmpargs[0] = "xterm"; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7970 tmpargs[1] = "-e"; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7971 while(params[z]) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7972 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7973 tmpargs[z+2] = params[z]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7974 z++; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7975 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7976 tmpargs[z+2] = NULL; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7977 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7978 execvp("xterm", tmpargs); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7979 free(tmpargs); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7980 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7981 /* If we got here exec failed */ |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7982 _exit(-1); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7983 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7984 return ret; |
661
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7985 } |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7986 |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7987 /* |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7988 * 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
|
7989 * Parameters: |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7990 * url: Uniform resource locator. |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7991 */ |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7992 int dw_browse(char *url) |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7993 { |
715
5f8102bd7646
dw_browse() reimplmented so it actually works as expected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
714
diff
changeset
|
7994 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
|
7995 [[NSWorkspace sharedWorkspace] openURL:myurl]; |
5f8102bd7646
dw_browse() reimplmented so it actually works as expected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
714
diff
changeset
|
7996 return 0; |
5f8102bd7646
dw_browse() reimplmented so it actually works as expected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
714
diff
changeset
|
7997 } |