Mercurial > dwindows
annotate mac/dw.m @ 745:d29fb0d5b291
Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Wed, 16 Mar 2011 07:39:28 +0000 |
parents | 9882b0dfa304 |
children | a4f99795ff26 |
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 { |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
45 0x00000000, /* 0 black */ |
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
|
46 0x000000bb, /* 1 red */ |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
47 0x0000bb00, /* 2 green */ |
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
|
48 0x0000aaaa, /* 3 yellow */ |
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
|
49 0x00cc0000, /* 4 blue */ |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
50 0x00bb00bb, /* 5 magenta */ |
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
|
51 0x00bbbb00, /* 6 cyan */ |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
52 0x00bbbbbb, /* 7 white */ |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
53 0x00777777, /* 8 grey */ |
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
|
54 0x000000ff, /* 9 bright red */ |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
55 0x0000ff00, /* 10 bright green */ |
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
|
56 0x0000eeee, /* 11 bright yellow */ |
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
|
57 0x00ff0000, /* 12 bright blue */ |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
58 0x00ff00ff, /* 13 bright magenta */ |
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
|
59 0x00eeee00, /* 14 bright cyan */ |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
60 0x00ffffff, /* 15 bright white */ |
689
4199730e9889
Fixed errors creating scrollbars.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
688
diff
changeset
|
61 0xff000000 /* 16 default color */ |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
62 }; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
63 |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
64 unsigned long _get_color(unsigned long thiscolor) |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
65 { |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
66 if(thiscolor & DW_RGB_COLOR) |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
67 { |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
68 return thiscolor & ~DW_RGB_COLOR; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
69 } |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
70 else if(thiscolor < 17) |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
71 { |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
72 return _colors[thiscolor]; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
73 } |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
74 return 0; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
75 } |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
76 |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
77 typedef struct _sighandler |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
78 { |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
79 struct _sighandler *next; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
80 ULONG message; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
81 HWND window; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
82 int id; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
83 void *signalfunction; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
84 void *data; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
85 |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
86 } SignalHandler; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
87 |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
88 SignalHandler *Root = NULL; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
89 |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
90 /* Some internal prototypes */ |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
91 static void _do_resize(Box *thisbox, int x, int y); |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
92 int _remove_userdata(UserData **root, char *varname, int all); |
725
4e09c92363df
Experimental changes to dw_main_sleep() and dw_main_iteration() to hopefully solve some issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
724
diff
changeset
|
93 int _dw_main_iteration(NSDate *date); |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
94 |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
95 SignalHandler *_get_handler(HWND window, int messageid) |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
96 { |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
97 SignalHandler *tmp = Root; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
98 |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
99 /* Find any callbacks for this function */ |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
100 while(tmp) |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
101 { |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
102 if(tmp->message == messageid && window == tmp->window) |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
103 { |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
104 return tmp; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
105 } |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
106 tmp = tmp->next; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
107 } |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
108 return NULL; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
109 } |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
110 |
703
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
111 typedef struct |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
112 { |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
113 ULONG message; |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
114 char name[30]; |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
115 |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
116 } SignalList; |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
117 |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
118 /* List of signals */ |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
119 #define SIGNALMAX 16 |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
120 |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
121 SignalList SignalTranslate[SIGNALMAX] = { |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
122 { 1, DW_SIGNAL_CONFIGURE }, |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
123 { 2, DW_SIGNAL_KEY_PRESS }, |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
124 { 3, DW_SIGNAL_BUTTON_PRESS }, |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
125 { 4, DW_SIGNAL_BUTTON_RELEASE }, |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
126 { 5, DW_SIGNAL_MOTION_NOTIFY }, |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
127 { 6, DW_SIGNAL_DELETE }, |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
128 { 7, DW_SIGNAL_EXPOSE }, |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
129 { 8, DW_SIGNAL_CLICKED }, |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
130 { 9, DW_SIGNAL_ITEM_ENTER }, |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
131 { 10, DW_SIGNAL_ITEM_CONTEXT }, |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
132 { 11, DW_SIGNAL_LIST_SELECT }, |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
133 { 12, DW_SIGNAL_ITEM_SELECT }, |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
134 { 13, DW_SIGNAL_SET_FOCUS }, |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
135 { 14, DW_SIGNAL_VALUE_CHANGED }, |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
136 { 15, DW_SIGNAL_SWITCH_PAGE }, |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
137 { 16, DW_SIGNAL_TREE_EXPAND } |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
138 }; |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
139 |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
140 int _event_handler(id object, NSEvent *event, int message) |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
141 { |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
142 SignalHandler *handler = _get_handler(object, message); |
706
79b38b1f3346
Scrollbar event fixes... scale was wrong... not sure it is correct but it is better.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
705
diff
changeset
|
143 /* NSLog(@"Event handler - type %d\n", message); */ |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
144 |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
145 if(handler) |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
146 { |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
147 switch(message) |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
148 { |
703
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
149 /* Timer event */ |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
150 case 0: |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
151 { |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
152 int (* API timerfunc)(void *) = (int (* API)(void *))handler->signalfunction; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
153 |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
154 if(!timerfunc(handler->data)) |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
155 dw_timer_disconnect(handler->id); |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
156 return 0; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
157 } |
703
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
158 /* Configure/Resize event */ |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
159 case 1: |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
160 { |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
161 int (*sizefunc)(HWND, int, int, void *) = handler->signalfunction; |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
162 NSSize size; |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
163 |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
164 if([object isMemberOfClass:[NSWindow class]]) |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
165 { |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
166 NSWindow *window = object; |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
167 size = [[window contentView] frame].size; |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
168 } |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
169 else |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
170 { |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
171 NSView *view = object; |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
172 size = [view frame].size; |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
173 } |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
174 |
706
79b38b1f3346
Scrollbar event fixes... scale was wrong... not sure it is correct but it is better.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
705
diff
changeset
|
175 if(size.width > 0 && size.height > 0) |
79b38b1f3346
Scrollbar event fixes... scale was wrong... not sure it is correct but it is better.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
705
diff
changeset
|
176 { |
79b38b1f3346
Scrollbar event fixes... scale was wrong... not sure it is correct but it is better.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
705
diff
changeset
|
177 return sizefunc(object, size.width, size.height, handler->data); |
79b38b1f3346
Scrollbar event fixes... scale was wrong... not sure it is correct but it is better.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
705
diff
changeset
|
178 } |
79b38b1f3346
Scrollbar event fixes... scale was wrong... not sure it is correct but it is better.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
705
diff
changeset
|
179 return 0; |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
180 } |
723
37c8d2b4cec5
Initial key press event/signal handling... does not seem to trap on all controls...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
722
diff
changeset
|
181 case 2: |
37c8d2b4cec5
Initial key press event/signal handling... does not seem to trap on all controls...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
722
diff
changeset
|
182 { |
37c8d2b4cec5
Initial key press event/signal handling... does not seem to trap on all controls...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
722
diff
changeset
|
183 int (*keypressfunc)(HWND, char, int, int, void *) = handler->signalfunction; |
37c8d2b4cec5
Initial key press event/signal handling... does not seem to trap on all controls...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
722
diff
changeset
|
184 NSString *nchar = [event charactersIgnoringModifiers]; |
37c8d2b4cec5
Initial key press event/signal handling... does not seem to trap on all controls...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
722
diff
changeset
|
185 int special = (int)[event modifierFlags]; |
724
41080d22edc8
Couple more fixes to keyhandling... committed before I finished what I was doing...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
723
diff
changeset
|
186 unichar vk = [nchar characterAtIndex:0]; |
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 */ |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
202 case 3: |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
203 case 4: |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
204 { |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
205 int (* API buttonfunc)(HWND, int, int, int, void *) = (int (* API)(HWND, int, int, int, void *))handler->signalfunction; |
701
c91a1b345f2e
Fix for button press and context menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
700
diff
changeset
|
206 int button = (int)event; |
c91a1b345f2e
Fix for button press and context menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
700
diff
changeset
|
207 LONG x,y; |
c91a1b345f2e
Fix for button press and context menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
700
diff
changeset
|
208 |
c91a1b345f2e
Fix for button press and context menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
700
diff
changeset
|
209 dw_pointer_query_pos(&x, &y); |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
210 |
701
c91a1b345f2e
Fix for button press and context menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
700
diff
changeset
|
211 return buttonfunc(object, (int)x, (int)y, button, handler->data); |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
212 } |
703
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
213 /* Window close event */ |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
214 case 6: |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
215 { |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
216 int (* API closefunc)(HWND, void *) = (int (* API)(HWND, void *))handler->signalfunction; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
217 return closefunc(object, handler->data); |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
218 } |
703
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
219 /* Window expose/draw event */ |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
220 case 7: |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
221 { |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
222 DWExpose exp; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
223 int (* API exposefunc)(HWND, DWExpose *, void *) = (int (* API)(HWND, DWExpose *, void *))handler->signalfunction; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
224 NSRect rect = [object frame]; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
225 |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
226 exp.x = rect.origin.x; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
227 exp.y = rect.origin.y; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
228 exp.width = rect.size.width; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
229 exp.height = rect.size.height; |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
230 int result = exposefunc(object, &exp, handler->data); |
661
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
231 [[object window] flushWindow]; |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
232 return result; |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
233 } |
703
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
234 /* Clicked event for buttons and menu items */ |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
235 case 8: |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
236 { |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
237 int (* API clickfunc)(HWND, void *) = (int (* API)(HWND, void *))handler->signalfunction; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
238 |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
239 return clickfunc(object, handler->data); |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
240 } |
703
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
241 /* Container class selection event */ |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
242 case 9: |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
243 { |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
244 int (*containerselectfunc)(HWND, char *, void *) = handler->signalfunction; |
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 */ |
659
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
249 case 10: |
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
250 { |
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
251 int (* API containercontextfunc)(HWND, char *, int, int, void *, void *) = (int (* API)(HWND, char *, int, int, void *, void *))handler->signalfunction; |
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
252 char *text = (char *)event; |
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
253 void *user = NULL; |
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
254 LONG x,y; |
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
255 |
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
256 dw_pointer_query_pos(&x, &y); |
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
257 |
665
e6bec2290f3f
Fixing warnings with Xcode 4 and switched to manual releasing in the draw functions to stop leaking.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
664
diff
changeset
|
258 return containercontextfunc(handler->window, text, (int)x, (int)y, handler->data, user); |
659
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
259 } |
703
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
260 /* Generic selection changed event for several classes */ |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
261 case 11: |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
262 case 14: |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
263 { |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
264 int (* API valuechangedfunc)(HWND, int, void *) = (int (* API)(HWND, int, void *))handler->signalfunction; |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
265 int selected = (int)event; |
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 */ |
659
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
270 case 12: |
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
271 { |
709
5a268d5f1cfa
Fixes for tree event handling. Still more to come shortly...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
708
diff
changeset
|
272 int (* API treeselectfunc)(HWND, HTREEITEM, char *, void *, void *) = (int (* API)(HWND, HTREEITEM, char *, void *, void *))handler->signalfunction; |
5a268d5f1cfa
Fixes for tree event handling. Still more to come shortly...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
708
diff
changeset
|
273 char *text = (char *)event; |
5a268d5f1cfa
Fixes for tree event handling. Still more to come shortly...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
708
diff
changeset
|
274 void *user = NULL; |
5a268d5f1cfa
Fixes for tree event handling. Still more to come shortly...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
708
diff
changeset
|
275 id item = nil; |
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 } |
659
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
298 |
709
5a268d5f1cfa
Fixes for tree event handling. Still more to come shortly...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
708
diff
changeset
|
299 return treeselectfunc(handler->window, item, text, handler->data, user); |
5a268d5f1cfa
Fixes for tree event handling. Still more to come shortly...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
708
diff
changeset
|
300 } |
703
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
301 /* Set Focus event */ |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
302 case 13: |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
303 { |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
304 int (* API setfocusfunc)(HWND, void *) = (int (* API)(HWND, void *))handler->signalfunction; |
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 } |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
322 } |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
323 } |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
324 return -1; |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
325 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
326 |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
327 /* Subclass for the Timer type */ |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
328 @interface DWTimerHandler : NSObject { } |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
329 -(void)runTimer:(id)sender; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
330 @end |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
331 |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
332 @implementation DWTimerHandler |
674
78f9aa6d6d89
Fixes or fonts and loading images from files. Added Mac specific settings to dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
673
diff
changeset
|
333 -(void)runTimer:(id)sender { _event_handler(sender, nil, 0); } |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
334 @end |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
335 |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
336 NSApplication *DWApp; |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
337 NSMenu *DWMainMenu; |
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; |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
349 |
699
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
350 /* 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
|
351 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
|
352 { |
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
353 id src; |
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 dest; |
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
355 int xdest; |
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 ydest; |
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 width; |
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 height; |
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 xsrc; |
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 ysrc; |
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
361 } DWBitBlt; |
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
362 |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
363 /* 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
|
364 @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
|
365 -(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
|
366 -(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
|
367 -(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
|
368 -(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
|
369 @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
|
370 |
578bbfd8c904
Added 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 @implementation DWObject |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
372 -(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
|
373 -(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
|
374 { |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
375 pthread_mutex_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
|
376 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
|
377 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
|
378 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
|
379 } |
699
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
380 -(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
|
381 { |
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
382 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
|
383 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
|
384 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
|
385 id bltsrc = bltinfo->src; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
386 |
699
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
387 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
|
388 { |
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
389 [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
|
390 } |
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
391 else |
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
392 { |
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
393 [bltdest lockFocusIfCanDraw]; |
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
394 _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
|
395 } |
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
396 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
|
397 { |
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
398 NSImage *image = bltsrc; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
399 [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
|
400 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
|
401 [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
|
402 } |
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
403 [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
|
404 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
|
405 } |
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
406 -(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
|
407 { |
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
408 if(_DWLastDrawable) |
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
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 id object = _DWLastDrawable; |
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
411 NSWindow *window = [object window]; |
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
412 [window flushWindow]; |
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
413 } |
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
414 } |
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
|
415 -(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
|
416 { |
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
|
417 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
|
418 void **params = (void **)[v pointerValue]; |
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 (* windowfunc)(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
|
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 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
|
422 { |
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
|
423 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
|
424 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
|
425 { |
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 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
|
427 } |
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 } |
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 } |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
430 @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
|
431 |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
432 DWObject *DWObj; |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
433 |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
434 /* 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
|
435 * 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
|
436 * basically everything. Was hoping to add methods |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
437 * 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
|
438 * 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
|
439 * going to work. -Brian |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
440 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
441 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
442 /* Subclass for a box type */ |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
443 @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
|
444 #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
|
445 <NSWindowDelegate> |
17923b931393
Fixes for building for MacOS 10.5 and PPC
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
715
diff
changeset
|
446 #endif |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
447 { |
666
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
448 Box *box; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
449 void *userdata; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
450 NSColor *bgcolor; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
451 } |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
452 -(id)init; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
453 -(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
|
454 -(Box *)box; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
455 -(void *)userdata; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
456 -(void)setUserdata:(void *)input; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
457 -(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
|
458 -(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
|
459 -(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
|
460 -(void)mouseUp:(NSEvent *)theEvent; |
701
c91a1b345f2e
Fix for button press and context menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
700
diff
changeset
|
461 -(NSMenu *)menuForEvent:(NSEvent *)theEvent; |
c91a1b345f2e
Fix for button press and context menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
700
diff
changeset
|
462 -(void)rightMouseUp:(NSEvent *)theEvent; |
c91a1b345f2e
Fix for button press and context menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
700
diff
changeset
|
463 -(void)otherMouseDown:(NSEvent *)theEvent; |
c91a1b345f2e
Fix for button press and context menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
700
diff
changeset
|
464 -(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
|
465 -(void)keyDown:(NSEvent *)theEvent; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
466 -(void)setColor:(unsigned long)input; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
467 @end |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
468 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
469 @implementation DWBox |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
470 -(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
|
471 { |
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
472 self = [super init]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
473 |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
474 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
|
475 { |
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
476 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
|
477 } |
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
478 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
|
479 } |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
480 -(void)dealloc |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
481 { |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
482 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
|
483 free(box); |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
484 _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
|
485 [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
|
486 } |
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
487 -(Box *)box { return box; } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
488 -(void *)userdata { return userdata; } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
489 -(void)setUserdata:(void *)input { userdata = input; } |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
490 -(void)drawRect:(NSRect)rect |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
491 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
492 if(bgcolor) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
493 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
494 [bgcolor set]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
495 NSRectFill( [self bounds] ); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
496 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
497 } |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
498 -(BOOL)isFlipped { return YES; } |
701
c91a1b345f2e
Fix for button press and context menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
700
diff
changeset
|
499 -(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
|
500 -(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
|
501 -(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
|
502 -(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
|
503 -(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
|
504 -(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
|
505 -(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
|
506 -(void)setColor:(unsigned long)input |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
507 { |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
508 if(input == _colors[DW_CLR_DEFAULT]) |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
509 { |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
510 bgcolor = nil; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
511 } |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
512 else |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
513 { |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
514 bgcolor = [NSColor colorWithDeviceRed: DW_RED_VALUE(input)/255.0 green: DW_GREEN_VALUE(input)/255.0 blue: DW_BLUE_VALUE(input)/255.0 alpha: 1]; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
515 } |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
516 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
517 @end |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
518 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
519 /* Subclass for a top-level window */ |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
520 @interface DWView : DWBox |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
521 { |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
522 NSMenu *windowmenu; |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
523 } |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
524 -(BOOL)windowShouldClose:(id)sender; |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
525 -(void)setMenu:(NSMenu *)input; |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
526 -(void)windowDidBecomeMain:(id)sender; |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
527 -(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
|
528 -(void)keyDown:(NSEvent *)theEvent; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
529 @end |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
530 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
531 @implementation DWView |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
532 -(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
|
533 { |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
534 if(_event_handler(self, nil, 6) == FALSE) |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
535 return NO; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
536 return YES; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
537 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
538 - (void)viewDidMoveToWindow |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
539 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
540 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(windowResized:) name:NSWindowDidResizeNotification object:[self window]]; |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
541 [[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
|
542 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
543 - (void)dealloc |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
544 { |
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
|
545 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
|
546 { |
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
|
547 [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
|
548 } |
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
|
549 [[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
|
550 [super dealloc]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
551 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
552 - (void)windowResized:(NSNotification *)notification; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
553 { |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
554 NSSize size = [self frame].size; |
666
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
555 _do_resize(box, size.width, size.height); |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
556 _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
|
557 } |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
558 -(void)windowDidBecomeMain:(id)sender |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
559 { |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
560 if(windowmenu) |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
561 { |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
562 [DWApp setMainMenu:windowmenu]; |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
563 } |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
564 else |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
565 { |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
566 [DWApp setMainMenu:DWMainMenu]; |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
567 } |
703
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
568 _event_handler(self, nil, 13); |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
569 } |
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
|
570 -(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
|
571 -(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
|
572 -(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
|
573 @end |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
574 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
575 /* Subclass for a button type */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
576 @interface DWButton : NSButton |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
577 { |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
578 void *userdata; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
579 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
580 -(void *)userdata; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
581 -(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
|
582 -(void)buttonClicked:(id)sender; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
583 @end |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
584 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
585 @implementation DWButton |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
586 -(void *)userdata { return userdata; } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
587 -(void)setUserdata:(void *)input { userdata = input; } |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
588 -(void)buttonClicked:(id)sender { _event_handler(self, nil, 8); } |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
589 -(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
|
590 @end |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
591 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
592 /* Subclass for a progress type */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
593 @interface DWPercent : NSProgressIndicator |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
594 { |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
595 void *userdata; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
596 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
597 -(void *)userdata; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
598 -(void)setUserdata:(void *)input; |
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 @implementation DWPercent |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
602 -(void *)userdata { return userdata; } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
603 -(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
|
604 -(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
|
605 @end |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
606 |
651
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
607 /* Subclass for a entryfield type */ |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
608 @interface DWEntryField : NSTextField |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
609 { |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
610 void *userdata; |
651
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
611 } |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
612 -(void *)userdata; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
613 -(void)setUserdata:(void *)input; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
614 @end |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
615 |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
616 @implementation DWEntryField |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
617 -(void *)userdata { return userdata; } |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
618 -(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
|
619 -(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
|
620 @end |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
621 |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
622 /* Subclass for a entryfield password type */ |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
623 @interface DWEntryFieldPassword : NSSecureTextField |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
624 { |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
625 void *userdata; |
651
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
626 } |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
627 -(void *)userdata; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
628 -(void)setUserdata:(void *)input; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
629 @end |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
630 |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
631 @implementation DWEntryFieldPassword |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
632 -(void *)userdata { return userdata; } |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
633 -(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
|
634 -(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
|
635 @end |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
636 |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
637 /* Subclass for a Notebook control type */ |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
638 @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
|
639 #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
|
640 <NSTabViewDelegate> |
17923b931393
Fixes for building for MacOS 10.5 and PPC
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
715
diff
changeset
|
641 #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
|
642 { |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
643 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
|
644 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
|
645 } |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
646 -(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
|
647 -(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
|
648 -(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
|
649 -(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
|
650 -(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
|
651 @end |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
652 |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
653 /* 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
|
654 @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
|
655 { |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
656 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
|
657 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
|
658 } |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
659 -(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
|
660 -(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
|
661 -(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
|
662 -(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
|
663 @end |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
664 |
703
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
665 @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
|
666 -(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
|
667 -(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
|
668 -(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
|
669 -(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
|
670 -(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
|
671 { |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
672 id object = [notepage view]; |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
673 DWNotebookPage *page = (DWNotebookPage *)notepage; |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
674 |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
675 if([object isMemberOfClass:[DWBox class]]) |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
676 { |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
677 DWBox *view = object; |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
678 Box *box = [view box]; |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
679 NSSize size = [view frame].size; |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
680 _do_resize(box, size.width, size.height); |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
681 } |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
682 _event_handler(self, (void *)[page pageid], 15); |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
683 } |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
684 -(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
|
685 @end |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
686 |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
687 @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
|
688 -(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
|
689 -(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
|
690 -(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
|
691 -(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
|
692 -(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
|
693 @end |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
694 |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
695 /* Subclass for a color chooser type */ |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
696 @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
|
697 { |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
698 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
|
699 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
|
700 } |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
701 -(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
|
702 -(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
|
703 -(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
|
704 @end |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
705 |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
706 @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
|
707 -(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
|
708 -(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
|
709 -(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
|
710 -(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
|
711 @end |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
712 |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
713 /* Subclass for a splitbar type */ |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
714 @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
|
715 #ifdef BUILDING_FOR_SNOW_LEOPARD |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
716 <NSSplitViewDelegate> |
717
17923b931393
Fixes for building for MacOS 10.5 and PPC
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
715
diff
changeset
|
717 #endif |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
718 { |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
719 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
|
720 float percent; |
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
721 } |
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
722 -(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
|
723 -(void *)userdata; |
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
724 -(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
|
725 -(float)percent; |
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
726 -(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
|
727 @end |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
728 |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
729 @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
|
730 -(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
|
731 { |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
732 NSArray *views = [self subviews]; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
733 id object; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
734 |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
735 for(object in views) |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
736 { |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
737 if([object isMemberOfClass:[DWBox class]]) |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
738 { |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
739 DWBox *view = object; |
666
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
740 Box *box = [view box]; |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
741 NSSize size = [view frame].size; |
666
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
742 _do_resize(box, size.width, size.height); |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
743 } |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
744 } |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
745 } |
677
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
746 -(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
|
747 -(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
|
748 -(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
|
749 -(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
|
750 -(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
|
751 @end |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
752 |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
753 /* 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
|
754 @interface DWSlider : NSSlider |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
755 { |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
756 void *userdata; |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
757 } |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
758 -(void *)userdata; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
759 -(void)setUserdata:(void *)input; |
704
336800e9e648
Fixes to the slider control so events happen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
703
diff
changeset
|
760 -(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
|
761 @end |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
762 |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
763 @implementation DWSlider |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
764 -(void *)userdata { return userdata; } |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
765 -(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
|
766 -(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
|
767 -(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
|
768 @end |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
769 |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
770 /* 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
|
771 @interface DWScrollbar : NSScroller |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
772 { |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
773 void *userdata; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
774 float range; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
775 float visible; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
776 } |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
777 -(void *)userdata; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
778 -(void)setUserdata:(void *)input; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
779 -(float)range; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
780 -(float)visible; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
781 -(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
|
782 -(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
|
783 @end |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
784 |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
785 @implementation DWScrollbar |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
786 -(void *)userdata { return userdata; } |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
787 -(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
|
788 -(float)range { return range; } |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
789 -(float)visible { return visible; } |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
790 -(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
|
791 -(void)scrollerChanged:(id)sender |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
792 { |
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
|
793 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
|
794 int page = (int)(proportion * range); |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
795 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
|
796 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
|
797 int newpos = result; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
798 |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
799 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
|
800 { |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
801 |
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
|
802 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
|
803 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
|
804 { |
86d76fc09237
Added support for scrollbar line and page scrolling. Need to check the calculations...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
706
diff
changeset
|
805 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
|
806 } |
86d76fc09237
Added support for scrollbar line and page scrolling. Need to check the calculations...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
706
diff
changeset
|
807 break; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
808 |
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
|
809 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
|
810 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
|
811 { |
86d76fc09237
Added support for scrollbar line and page scrolling. Need to check the calculations...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
706
diff
changeset
|
812 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
|
813 } |
86d76fc09237
Added support for scrollbar line and page scrolling. Need to check the calculations...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
706
diff
changeset
|
814 break; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
815 |
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
|
816 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
|
817 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
|
818 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
|
819 { |
86d76fc09237
Added support for scrollbar line and page scrolling. Need to check the calculations...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
706
diff
changeset
|
820 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
|
821 } |
86d76fc09237
Added support for scrollbar line and page scrolling. Need to check the calculations...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
706
diff
changeset
|
822 break; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
823 |
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
|
824 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
|
825 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
|
826 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
|
827 { |
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
|
828 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
|
829 } |
86d76fc09237
Added support for scrollbar line and page scrolling. Need to check the calculations...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
706
diff
changeset
|
830 break; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
831 |
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
|
832 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
|
833 ; /* 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
|
834 } |
86d76fc09237
Added support for scrollbar line and page scrolling. Need to check the calculations...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
706
diff
changeset
|
835 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
|
836 { |
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
|
837 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
|
838 [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
|
839 } |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
840 _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
|
841 } |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
842 -(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
|
843 @end |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
844 |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
845 /* Subclass for a render area type */ |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
846 @interface DWRender : NSView |
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; |
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
|
849 NSFont *font; |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
850 } |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
851 -(void *)userdata; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
852 -(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
|
853 -(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
|
854 -(NSFont *)font; |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
855 -(void)mouseDown:(NSEvent *)theEvent; |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
856 -(void)mouseUp:(NSEvent *)theEvent; |
701
c91a1b345f2e
Fix for button press and context menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
700
diff
changeset
|
857 -(NSMenu *)menuForEvent:(NSEvent *)theEvent; |
c91a1b345f2e
Fix for button press and context menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
700
diff
changeset
|
858 -(void)rightMouseUp:(NSEvent *)theEvent; |
c91a1b345f2e
Fix for button press and context menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
700
diff
changeset
|
859 -(void)otherMouseDown:(NSEvent *)theEvent; |
c91a1b345f2e
Fix for button press and context menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
700
diff
changeset
|
860 -(void)otherMouseUp:(NSEvent *)theEvent; |
c91a1b345f2e
Fix for button press and context menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
700
diff
changeset
|
861 -(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
|
862 -(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
|
863 -(BOOL)isFlipped; |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
864 @end |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
865 |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
866 @implementation DWRender |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
867 -(void *)userdata { return userdata; } |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
868 -(void)setUserdata:(void *)input { userdata = input; } |
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
|
869 -(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
|
870 -(NSFont *)font { return font; } |
701
c91a1b345f2e
Fix for button press and context menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
700
diff
changeset
|
871 -(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
|
872 -(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
|
873 -(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
|
874 -(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
|
875 -(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
|
876 -(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
|
877 -(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
|
878 -(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
|
879 -(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
|
880 -(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
|
881 @end |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
882 |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
883 /* Subclass for a MLE type */ |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
884 @interface DWMLE : NSTextView |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
885 { |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
886 void *userdata; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
887 } |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
888 -(void *)userdata; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
889 -(void)setUserdata:(void *)input; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
890 @end |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
891 |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
892 @implementation DWMLE |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
893 -(void *)userdata { return userdata; } |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
894 -(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
|
895 -(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
|
896 @end |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
897 |
655
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
898 /* Subclass for a Container/List type */ |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
899 @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
|
900 #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
|
901 <NSTableViewDataSource> |
17923b931393
Fixes for building for MacOS 10.5 and PPC
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
715
diff
changeset
|
902 #endif |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
903 { |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
904 void *userdata; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
905 NSMutableArray *tvcols; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
906 NSMutableArray *data; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
907 NSMutableArray *types; |
659
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
908 NSPointerArray *titles; |
675
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
909 int lastAddPoint, lastQueryPoint; |
668
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
910 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
|
911 } |
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
912 -(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
|
913 -(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
|
914 -(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
|
915 -(void *)userdata; |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
916 -(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
|
917 -(id)scrollview; |
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
918 -(void)setScrollview:(id)input; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
919 -(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
|
920 -(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
|
921 -(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
|
922 -(int)addRows:(int)number; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
923 -(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
|
924 -(void)removeRow:(int)row; |
659
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
925 -(void)setRow:(int)row title:(void *)input; |
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
926 -(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
|
927 -(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
|
928 -(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
|
929 -(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
|
930 -(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
|
931 -(void)setLastQueryPoint:(int)input; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
932 -(void)clear; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
933 -(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
|
934 -(void)doubleClicked:(id)sender; |
659
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
935 -(void)selectionChanged:(id)sender; |
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
936 -(NSMenu *)menuForEvent:(NSEvent *)event; |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
937 @end |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
938 |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
939 @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
|
940 -(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
|
941 { |
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
942 if(tvcols && data) |
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
943 { |
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
|
944 int cols = (int)[tvcols count]; |
658
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
945 if(cols) |
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
946 { |
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
947 return [data count] / cols; |
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
948 } |
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
949 } |
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
950 return 0; |
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
951 } |
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
952 -(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
|
953 { |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
954 if(tvcols) |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
955 { |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
956 int z, col = -1; |
665
e6bec2290f3f
Fixing warnings with Xcode 4 and switched to manual releasing in the draw functions to stop leaking.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
664
diff
changeset
|
957 int count = (int)[tvcols count]; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
958 |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
959 for(z=0;z<count;z++) |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
960 { |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
961 if([tvcols objectAtIndex:z] == aCol) |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
962 { |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
963 col = z; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
964 break; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
965 } |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
966 } |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
967 if(col != -1) |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
968 { |
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
|
969 int index = (int)(aRow * count) + col; |
659
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
970 id this = [data objectAtIndex:index]; |
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
971 return ([this isKindOfClass:[NSNull class]]) ? nil : this; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
972 } |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
973 } |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
974 return nil; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
975 } |
708
5fe2ca5ef88b
Fixes for container event handling. Also made container/listbox cells non-editable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
707
diff
changeset
|
976 -(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
|
977 -(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
|
978 -(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
|
979 -(id)scrollview { return scrollview; } |
17923b931393
Fixes for building for MacOS 10.5 and PPC
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
715
diff
changeset
|
980 -(void)setScrollview:(id)input { scrollview = input; } |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
981 -(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
|
982 -(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
|
983 -(int)insertRow:(NSArray *)input at:(int)index |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
984 { |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
985 if(data) |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
986 { |
687
5dde8d34bc69
Implemented dw_listbox_insert for containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
686
diff
changeset
|
987 unsigned long start = [tvcols count] * index; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
988 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
|
989 if(index < lastAddPoint) |
5dde8d34bc69
Implemented dw_listbox_insert for containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
686
diff
changeset
|
990 { |
5dde8d34bc69
Implemented dw_listbox_insert for containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
686
diff
changeset
|
991 lastAddPoint++; |
5dde8d34bc69
Implemented dw_listbox_insert for containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
686
diff
changeset
|
992 } |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
993 [data insertObjects:input atIndexes:set]; |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
994 [titles insertPointer:NULL atIndex:index]; |
687
5dde8d34bc69
Implemented dw_listbox_insert for containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
686
diff
changeset
|
995 [set release]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
996 return (int)[titles count]; |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
997 } |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
998 return 0; |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
999 } |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1000 -(int)addRow:(NSArray *)input |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1001 { |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1002 if(data) |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1003 { |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1004 lastAddPoint = (int)[titles count]; |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1005 [data addObjectsFromArray:input]; |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1006 [titles addPointer:NULL]; |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1007 return (int)[titles count]; |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1008 } |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1009 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
|
1010 } |
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)addRows:(int)number |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
1012 { |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
1013 if(tvcols) |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
1014 { |
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
|
1015 int count = (int)(number * [tvcols count]); |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
1016 int z; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
1017 |
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
|
1018 lastAddPoint = (int)[titles count]; |
658
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
1019 |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
1020 for(z=0;z<count;z++) |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
1021 { |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
1022 [data addObject:[NSNull null]]; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
1023 } |
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
|
1024 for(z=0;z<number;z++) |
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
1025 { |
659
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
1026 [titles addPointer:NULL]; |
658
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
1027 } |
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
|
1028 return (int)[titles count]; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
1029 } |
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 return 0; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
1031 } |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
1032 -(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
|
1033 { |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
1034 if(tvcols && input) |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
1035 { |
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
|
1036 int index = (int)(row * [tvcols count]) + col; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
1037 [data replaceObjectAtIndex:index withObject:input]; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
1038 } |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
1039 } |
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
|
1040 -(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
|
1041 { |
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
|
1042 if(tvcols) |
d7badd5606ca
Removed the Carbon source file, and changes to configure to build the Cocoa version.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
661
diff
changeset
|
1043 { |
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
|
1044 int z, start, end; |
665
e6bec2290f3f
Fixing warnings with Xcode 4 and switched to manual releasing in the draw functions to stop leaking.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
664
diff
changeset
|
1045 int count = (int)[tvcols count]; |
662
d7badd5606ca
Removed the Carbon source file, and changes to configure to build the Cocoa version.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
661
diff
changeset
|
1046 |
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
|
1047 start = count * row; |
d7badd5606ca
Removed the Carbon source file, and changes to configure to build the Cocoa version.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
661
diff
changeset
|
1048 end = start + count; |
d7badd5606ca
Removed the Carbon source file, and changes to configure to build the Cocoa version.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
661
diff
changeset
|
1049 |
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
|
1050 for(z=start;z<end;z++) |
d7badd5606ca
Removed the Carbon source file, and changes to configure to build the Cocoa version.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
661
diff
changeset
|
1051 { |
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
|
1052 [data removeObjectAtIndex:z]; |
d7badd5606ca
Removed the Carbon source file, and changes to configure to build the Cocoa version.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
661
diff
changeset
|
1053 } |
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
|
1054 [titles removePointerAtIndex:row]; |
d7badd5606ca
Removed the Carbon source file, and changes to configure to build the Cocoa version.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
661
diff
changeset
|
1055 if(lastAddPoint > 0 && lastAddPoint < row) |
d7badd5606ca
Removed the Carbon source file, and changes to configure to build the Cocoa version.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
661
diff
changeset
|
1056 { |
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
|
1057 lastAddPoint--; |
d7badd5606ca
Removed the Carbon source file, and changes to configure to build the Cocoa version.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
661
diff
changeset
|
1058 } |
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
|
1059 } |
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
|
1060 } |
659
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
1061 -(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
|
1062 -(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
|
1063 -(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
|
1064 -(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
|
1065 -(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
|
1066 -(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
|
1067 -(void)setLastQueryPoint:(int)input { lastQueryPoint = input; } |
659
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
1068 -(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
|
1069 -(void)setup |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1070 { |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1071 tvcols = [[[NSMutableArray alloc] init] retain]; |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1072 data = [[[NSMutableArray alloc] init] retain]; |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1073 types = [[[NSMutableArray alloc] init] retain]; |
692
bd909322f40d
Added "retain"s to the DWTree/DWContainer/DWListBox classes memory allocation
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
691
diff
changeset
|
1074 titles = [[NSPointerArray pointerArrayWithWeakObjects] retain]; |
743
4462bc7de1e3
Possible fix for container (and possibly tree) controls picking up combobox events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
742
diff
changeset
|
1075 [[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
|
1076 } |
708
5fe2ca5ef88b
Fixes for container event handling. Also made container/listbox cells non-editable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
707
diff
changeset
|
1077 -(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
|
1078 { |
5fe2ca5ef88b
Fixes for container event handling. Also made container/listbox cells non-editable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
707
diff
changeset
|
1079 /* Handler for container class */ |
5fe2ca5ef88b
Fixes for container event handling. Also made container/listbox cells non-editable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
707
diff
changeset
|
1080 _event_handler(self, (NSEvent *)[self getRowTitle:(int)[self selectedRow]], 9); |
5fe2ca5ef88b
Fixes for container event handling. Also made container/listbox cells non-editable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
707
diff
changeset
|
1081 } |
659
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
1082 -(void)selectionChanged:(id)sender |
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
1083 { |
703
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
1084 /* Handler for container class */ |
708
5fe2ca5ef88b
Fixes for container event handling. Also made container/listbox cells non-editable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
707
diff
changeset
|
1085 _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
|
1086 /* Handler for listbox class */ |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
1087 _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
|
1088 } |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1089 -(NSMenu *)menuForEvent:(NSEvent *)event |
659
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
1090 { |
710
78460ff977c1
Finishing up tree event/signal handlers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
709
diff
changeset
|
1091 int row; |
78460ff977c1
Finishing up tree event/signal handlers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
709
diff
changeset
|
1092 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
|
1093 row = (int)[self rowAtPoint:where]; |
78460ff977c1
Finishing up tree event/signal handlers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
709
diff
changeset
|
1094 _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
|
1095 return nil; |
659
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
1096 } |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1097 -(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
|
1098 @end |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1099 |
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
|
1100 /* 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
|
1101 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
|
1102 { |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
1103 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
|
1104 { |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
1105 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
|
1106 int z; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1107 |
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
|
1108 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
|
1109 { |
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
|
1110 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
|
1111 NSMutableArray *children = (NSMutableArray *)[pnt pointerAtIndex:3]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1112 |
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
|
1113 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
|
1114 { |
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
|
1115 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
|
1116 { |
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
|
1117 _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
|
1118 } |
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
|
1119 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
|
1120 { |
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
|
1121 _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
|
1122 } |
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
|
1123 } |
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
|
1124 } |
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
|
1125 } |
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
|
1126 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
|
1127 { |
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
|
1128 [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
|
1129 } |
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
|
1130 } |
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
|
1131 |
680
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1132 /* Subclass for a Tree type */ |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1133 @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
|
1134 #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
|
1135 <NSOutlineViewDataSource> |
17923b931393
Fixes for building for MacOS 10.5 and PPC
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
715
diff
changeset
|
1136 #endif |
680
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1137 { |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1138 void *userdata; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1139 NSTableColumn *imagecol; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1140 NSTableColumn *textcol; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1141 NSMutableArray *data; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1142 /* 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
|
1143 * 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
|
1144 */ |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1145 id scrollview; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1146 } |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1147 -(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
|
1148 -(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
|
1149 -(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
|
1150 -(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
|
1151 -(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
|
1152 -(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
|
1153 -(void *)userdata; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1154 -(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
|
1155 -(void)treeSelectionChanged:(id)sender; |
722
5a8d5161651d
Implemented tree expand event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
721
diff
changeset
|
1156 -(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
|
1157 -(NSScrollView *)scrollview; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1158 -(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
|
1159 -(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
|
1160 -(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
|
1161 @end |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1162 |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1163 @implementation DWTree |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1164 -(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
|
1165 { |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1166 self = [super init]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1167 |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1168 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
|
1169 { |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1170 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
|
1171 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
|
1172 [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
|
1173 [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
|
1174 [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
|
1175 [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
|
1176 textcol = [[NSTableColumn alloc] init]; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1177 [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
|
1178 [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
|
1179 [[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
|
1180 [[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
|
1181 } |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1182 return self; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1183 } |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1184 -(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
|
1185 { |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1186 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
|
1187 { |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1188 NSMutableArray *array = [item pointerAtIndex:3]; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1189 return array ? [array objectAtIndex:index] : nil; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1190 } |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1191 else |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1192 { |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1193 return [data objectAtIndex:index]; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1194 } |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1195 } |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1196 -(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
|
1197 { |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1198 return [self outlineView:outlineView numberOfChildrenOfItem:item] != 0; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1199 } |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1200 -(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
|
1201 { |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1202 if(item) |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1203 { |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1204 if([item isKindOfClass:[NSPointerArray class]]) |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1205 { |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1206 NSMutableArray *array = [item pointerAtIndex:3]; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1207 return array ? (int)[array count] : 0; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1208 } |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1209 else |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1210 { |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1211 return 0; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1212 } |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1213 } |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1214 else |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1215 { |
680
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1216 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
|
1217 } |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1218 } |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1219 -(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
|
1220 { |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1221 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
|
1222 { |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1223 if([item isKindOfClass:[NSPointerArray class]]) |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1224 { |
680
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1225 NSPointerArray *this = (NSPointerArray *)item; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1226 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
|
1227 { |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1228 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
|
1229 } |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1230 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
|
1231 } |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1232 else |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1233 { |
680
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1234 return nil; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1235 } |
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 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
|
1238 } |
710
78460ff977c1
Finishing up tree event/signal handlers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
709
diff
changeset
|
1239 -(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
|
1240 -(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
|
1241 { |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1242 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
|
1243 if(parent) |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1244 { |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1245 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
|
1246 if(!children) |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1247 { |
692
bd909322f40d
Added "retain"s to the DWTree/DWContainer/DWListBox classes memory allocation
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
691
diff
changeset
|
1248 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
|
1249 [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
|
1250 } |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1251 } |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1252 else |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1253 { |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1254 if(!data) |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1255 { |
692
bd909322f40d
Added "retain"s to the DWTree/DWContainer/DWListBox classes memory allocation
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
691
diff
changeset
|
1256 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
|
1257 } |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1258 } |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1259 [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
|
1260 } |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1261 -(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
|
1262 -(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
|
1263 -(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
|
1264 { |
710
78460ff977c1
Finishing up tree event/signal handlers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
709
diff
changeset
|
1265 /* 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
|
1266 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
|
1267 |
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
|
1268 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
|
1269 { |
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
|
1270 _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
|
1271 } |
710
78460ff977c1
Finishing up tree event/signal handlers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
709
diff
changeset
|
1272 } |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1273 -(void)treeItemExpanded:(NSNotification *)notification |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1274 { |
722
5a8d5161651d
Implemented tree expand event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
721
diff
changeset
|
1275 id item = [[notification userInfo ] objectForKey: @"NSObject"]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1276 |
722
5a8d5161651d
Implemented tree expand event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
721
diff
changeset
|
1277 if(item) |
5a8d5161651d
Implemented tree expand event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
721
diff
changeset
|
1278 { |
5a8d5161651d
Implemented tree expand event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
721
diff
changeset
|
1279 _event_handler(self, (void *)item, 16); |
5a8d5161651d
Implemented tree expand event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
721
diff
changeset
|
1280 } |
5a8d5161651d
Implemented tree expand event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
721
diff
changeset
|
1281 } |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1282 -(NSMenu *)menuForEvent:(NSEvent *)event |
710
78460ff977c1
Finishing up tree event/signal handlers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
709
diff
changeset
|
1283 { |
78460ff977c1
Finishing up tree event/signal handlers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
709
diff
changeset
|
1284 int row; |
78460ff977c1
Finishing up tree event/signal handlers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
709
diff
changeset
|
1285 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
|
1286 row = (int)[self rowAtPoint:where]; |
78460ff977c1
Finishing up tree event/signal handlers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
709
diff
changeset
|
1287 id item = [self itemAtRow:row]; |
78460ff977c1
Finishing up tree event/signal handlers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
709
diff
changeset
|
1288 NSString *nstr = [item pointerAtIndex:1]; |
78460ff977c1
Finishing up tree event/signal handlers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
709
diff
changeset
|
1289 _event_handler(self, (NSEvent *)[nstr UTF8String], 10); |
78460ff977c1
Finishing up tree event/signal handlers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
709
diff
changeset
|
1290 return nil; |
709
5a268d5f1cfa
Fixes for tree event handling. Still more to come shortly...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
708
diff
changeset
|
1291 } |
680
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1292 -(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
|
1293 -(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
|
1294 -(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
|
1295 -(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
|
1296 -(void)dealloc |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1297 { |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1298 UserData *root = userdata; |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1299 _remove_userdata(&root, NULL, TRUE); |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1300 _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
|
1301 [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
|
1302 [textcol release]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1303 [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
|
1304 } |
680
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1305 @end |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1306 |
656
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
1307 /* Subclass for a Calendar type */ |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1308 @interface DWCalendar : NSDatePicker |
655
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
1309 { |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
1310 void *userdata; |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
1311 } |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
1312 -(void *)userdata; |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
1313 -(void)setUserdata:(void *)input; |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
1314 @end |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
1315 |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
1316 @implementation DWCalendar |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
1317 -(void *)userdata { return userdata; } |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
1318 -(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
|
1319 -(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
|
1320 @end |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
1321 |
656
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
1322 /* Subclass for a Combobox type */ |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1323 @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
|
1324 #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
|
1325 <NSComboBoxDelegate> |
17923b931393
Fixes for building for MacOS 10.5 and PPC
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
715
diff
changeset
|
1326 #endif |
656
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
1327 { |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
1328 void *userdata; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
1329 } |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
1330 -(void *)userdata; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
1331 -(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
|
1332 -(void)comboBoxSelectionDidChange:(NSNotification *)not; |
656
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
1333 @end |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
1334 |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
1335 @implementation DWComboBox |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
1336 -(void *)userdata { return userdata; } |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
1337 -(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
|
1338 -(void)comboBoxSelectionDidChange:(NSNotification *)not { _event_handler(self, (void *)[self indexOfSelectedItem], 11); } |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1339 -(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
|
1340 @end |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1341 |
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
|
1342 /* 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
|
1343 /* 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
|
1344 @interface DWStepper : NSStepper |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1345 { |
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
|
1346 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
|
1347 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
|
1348 } |
d2d7d1802af4
Implemented a rather hacky fix for the spinbutton issues. The stepper control is really poorly
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
678
diff
changeset
|
1349 -(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
|
1350 -(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
|
1351 -(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
|
1352 -(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
|
1353 -(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
|
1354 -(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
|
1355 @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
|
1356 |
d2d7d1802af4
Implemented a rather hacky fix for the spinbutton issues. The stepper control is really poorly
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
678
diff
changeset
|
1357 @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
|
1358 -(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
|
1359 -(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
|
1360 -(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
|
1361 -(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
|
1362 -(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
|
1363 { |
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
|
1364 [super mouseDown:event]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1365 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
|
1366 { |
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
|
1367 [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
|
1368 _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
|
1369 } |
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
|
1370 } |
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
|
1371 -(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
|
1372 { |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1373 [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
|
1374 _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
|
1375 } |
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
|
1376 @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
|
1377 |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1378 /* Subclass for a Spinbutton type */ |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1379 @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
|
1380 #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
|
1381 <NSTextFieldDelegate> |
17923b931393
Fixes for building for MacOS 10.5 and PPC
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
715
diff
changeset
|
1382 #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
|
1383 { |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1384 void *userdata; |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1385 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
|
1386 DWStepper *stepper; |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1387 } |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1388 -(id)init; |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1389 -(void *)userdata; |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1390 -(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
|
1391 -(NSTextField *)textfield; |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1392 -(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
|
1393 -(void)controlTextDidChange:(NSNotification *)aNotification; |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1394 @end |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1395 |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1396 @implementation DWSpinButton |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1397 -(id)init |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1398 { |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1399 self = [super init]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1400 |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1401 if(self) |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1402 { |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1403 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
|
1404 [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
|
1405 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
|
1406 [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
|
1407 [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
|
1408 [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
|
1409 [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
|
1410 [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
|
1411 } |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1412 return self; |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1413 } |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1414 -(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
|
1415 -(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
|
1416 -(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
|
1417 -(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
|
1418 -(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
|
1419 { |
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
|
1420 [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
|
1421 [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
|
1422 _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
|
1423 } |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1424 -(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
|
1425 @end |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
1426 |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1427 /* 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
|
1428 * 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
|
1429 * 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
|
1430 */ |
014b02436c1f
Added MDI simulation code... the MDI "window" will just be a box for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
683
diff
changeset
|
1431 @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
|
1432 @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
|
1433 |
014b02436c1f
Added MDI simulation code... the MDI "window" will just be a box for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
683
diff
changeset
|
1434 @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
|
1435 @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
|
1436 |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1437 /* 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
|
1438 */ |
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
|
1439 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
|
1440 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1441 SignalHandler *new = malloc(sizeof(SignalHandler)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1442 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1443 new->message = message; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1444 new->window = window; |
688
b52f1d4a60dd
Fixes for timers not working properly. Includes commented out test container code for threadsafety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
687
diff
changeset
|
1445 new->id = msgid; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1446 new->signalfunction = signalfunction; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1447 new->data = data; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1448 new->next = NULL; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1449 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1450 if (!Root) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1451 Root = new; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1452 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1453 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1454 SignalHandler *prev = NULL, *tmp = Root; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1455 while(tmp) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1456 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1457 if(tmp->message == message && |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1458 tmp->window == window && |
688
b52f1d4a60dd
Fixes for timers not working properly. Includes commented out test container code for threadsafety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
687
diff
changeset
|
1459 tmp->id == msgid && |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1460 tmp->signalfunction == signalfunction) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1461 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1462 tmp->data = data; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1463 free(new); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1464 return; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1465 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1466 prev = tmp; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1467 tmp = tmp->next; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1468 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1469 if(prev) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1470 prev->next = new; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1471 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1472 Root = new; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1473 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1474 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1475 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1476 /* 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
|
1477 ULONG _findsigmessage(char *signame) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1478 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1479 int z; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1480 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1481 for(z=0;z<SIGNALMAX;z++) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1482 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1483 if(strcasecmp(signame, SignalTranslate[z].name) == 0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1484 return SignalTranslate[z].message; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1485 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1486 return 0L; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1487 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1488 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1489 unsigned long _foreground = 0xAAAAAA, _background = 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1490 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1491 /* 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
|
1492 * and does expansion as necessary. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1493 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1494 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
|
1495 int pass, int *usedpadx, int *usedpady) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1496 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1497 int z, currentx = 0, currenty = 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1498 int uymax = 0, uxmax = 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1499 int upymax = 0, upxmax = 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1500 /* Used for the SIZEEXPAND */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1501 int nux = *usedx, nuy = *usedy; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1502 int nupx = *usedpadx, nupy = *usedpady; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1503 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1504 (*usedx) += (thisbox->pad * 2); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1505 (*usedy) += (thisbox->pad * 2); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1506 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1507 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
|
1508 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1509 if(thisbox->items[z].type == TYPEBOX) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1510 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1511 int initialx, initialy; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1512 DWBox *box = thisbox->items[z].hwnd; |
666
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
1513 Box *tmp = [box box]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1514 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1515 initialx = x - (*usedx); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1516 initialy = y - (*usedy); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1517 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1518 if(tmp) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1519 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1520 int newx, newy; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1521 int nux = *usedx, nuy = *usedy; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1522 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
|
1523 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1524 /* 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
|
1525 * 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
|
1526 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1527 if(pass == 2) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1528 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1529 int deep = *depth + 1; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1530 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1531 _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
|
1532 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1533 tmp->upx = upx - *usedpadx; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1534 tmp->upy = upy - *usedpady; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1535 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1536 newx = x - nux; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1537 newy = y - nuy; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1538 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1539 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
|
1540 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
|
1541 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1542 tmp->parentxratio = thisbox->xratio; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1543 tmp->parentyratio = thisbox->yratio; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1544 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1545 tmp->parentpad = tmp->pad; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1546 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1547 /* Just in case */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1548 tmp->xratio = thisbox->xratio; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1549 tmp->yratio = thisbox->yratio; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1550 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1551 if(thisbox->type == DW_VERT) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1552 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1553 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
|
1554 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
|
1555 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1556 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1557 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1558 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
|
1559 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
|
1560 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1561 if(thisbox->type == DW_HORZ) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1562 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1563 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
|
1564 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
|
1565 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1566 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1567 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1568 if((thisbox->items[z].height-tmp->upy)!=0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1569 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
|
1570 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1571 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1572 nux = *usedx; nuy = *usedy; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1573 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
|
1574 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1575 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1576 (*depth)++; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1577 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1578 _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
|
1579 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1580 (*depth)--; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1581 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1582 newx = x - nux; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1583 newy = y - nuy; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1584 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1585 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
|
1586 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
|
1587 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1588 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1589 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1590 if(pass > 1 && *depth > 0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1591 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1592 if(thisbox->type == DW_VERT) |
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 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
|
1595 thisbox->items[z].xratio = 1.0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1596 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1597 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
|
1598 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1599 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1600 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1601 if(thisbox->minwidth-thisbox->upx == 0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1602 thisbox->items[z].xratio = 1.0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1603 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1604 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
|
1605 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1606 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1607 if(thisbox->type == DW_HORZ) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1608 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1609 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
|
1610 thisbox->items[z].yratio = 1.0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1611 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1612 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
|
1613 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1614 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1615 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1616 if(thisbox->minheight-thisbox->upy == 0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1617 thisbox->items[z].yratio = 1.0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1618 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1619 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
|
1620 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1621 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1622 if(thisbox->items[z].type == TYPEBOX) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1623 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1624 DWBox *box = thisbox->items[z].hwnd; |
666
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
1625 Box *tmp = [box box]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1626 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1627 if(tmp) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1628 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1629 tmp->parentxratio = thisbox->items[z].xratio; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1630 tmp->parentyratio = thisbox->items[z].yratio; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1631 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1632 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1633 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1634 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1635 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1636 thisbox->items[z].xratio = thisbox->xratio; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1637 thisbox->items[z].yratio = thisbox->yratio; |
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 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1640 if(thisbox->type == DW_VERT) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1641 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1642 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
|
1643 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
|
1644 if(thisbox->items[z].hsize != SIZEEXPAND) |
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(((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
|
1647 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
|
1648 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1649 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1650 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1651 if(thisbox->items[z].pad*2 > upxmax) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1652 upxmax = thisbox->items[z].pad*2; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1653 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1654 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1655 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1656 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1657 if(thisbox->items[z].width == -1) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1658 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1659 /* 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
|
1660 /* thisbox->items[z].width = */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1661 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1662 else |
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 (*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
|
1665 if(thisbox->items[z].hsize != SIZEEXPAND) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1666 (*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
|
1667 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1668 (*usedpadx) += thisbox->items[z].pad*2; |
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 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1671 if(thisbox->type == DW_HORZ) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1672 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1673 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
|
1674 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
|
1675 if(thisbox->items[z].vsize != SIZEEXPAND) |
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].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
|
1678 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
|
1679 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1680 else |
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].pad*2 > upymax) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1683 upymax = thisbox->items[z].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 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1686 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1687 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1688 if(thisbox->items[z].height == -1) |
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 /* 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
|
1691 /* thisbox->items[z].height = */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1692 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1693 else |
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 (*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
|
1696 if(thisbox->items[z].vsize != SIZEEXPAND) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1697 (*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
|
1698 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1699 (*usedpady) += thisbox->items[z].pad*2; |
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 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1702 } |
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 (*usedx) += uxmax; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1705 (*usedy) += uymax; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1706 (*usedpadx) += upxmax; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1707 (*usedpady) += upymax; |
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 currentx += thisbox->pad; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1710 currenty += thisbox->pad; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1711 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1712 /* 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
|
1713 if(pass > 1) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1714 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1715 /* 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
|
1716 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
|
1717 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1718 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
|
1719 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
|
1720 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
|
1721 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
|
1722 /* 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
|
1723 if(thisbox->items[z].type == TYPEBOX) |
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 DWBox *box = thisbox->items[z].hwnd; |
666
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
1726 Box *tmp = [box box]; |
650
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(tmp) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1729 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1730 if(*depth > 0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1731 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1732 float calcval; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1733 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1734 if(thisbox->type == DW_VERT) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1735 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1736 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
|
1737 if(calcval == 0.0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1738 tmp->xratio = thisbox->xratio; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1739 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1740 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
|
1741 tmp->width = thisbox->items[z].width; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1742 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1743 if(thisbox->type == DW_HORZ) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1744 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1745 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
|
1746 if(calcval == 0.0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1747 tmp->yratio = thisbox->yratio; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1748 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1749 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
|
1750 tmp->height = thisbox->items[z].height; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1751 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1752 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1753 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1754 (*depth)++; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1755 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1756 _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
|
1757 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1758 (*depth)--; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1759 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1760 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1761 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1762 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1763 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1764 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
|
1765 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1766 int height = thisbox->items[z].height; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1767 int width = thisbox->items[z].width; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1768 int pad = thisbox->items[z].pad; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1769 NSView *handle = thisbox->items[z].hwnd; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1770 NSPoint point; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1771 NSSize size; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1772 int vectorx, vectory; |
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 /* 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
|
1775 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
|
1776 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
|
1777 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1778 if(width > 0 && height > 0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1779 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1780 /* 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
|
1781 if(*depth == 0) |
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 vectorx++; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1784 vectory++; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1785 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1786 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1787 /* 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
|
1788 if(thisbox->items[z].vsize != SIZEEXPAND) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1789 vectory = 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1790 if(thisbox->items[z].hsize != SIZEEXPAND) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1791 vectorx = 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1792 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1793 point.x = currentx + pad; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1794 point.y = currenty + pad; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1795 size.width = width + vectorx; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1796 size.height = height + vectory; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1797 [handle setFrameOrigin:point]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1798 [handle setFrameSize:size]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1799 |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
1800 /* Special handling for notebook controls */ |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
1801 if([handle isMemberOfClass:[DWNotebook class]]) |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
1802 { |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
1803 DWNotebook *notebook = (DWNotebook *)handle; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
1804 DWNotebookPage *notepage = (DWNotebookPage *)[notebook selectedTabViewItem]; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
1805 DWBox *view = [notepage view]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1806 |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
1807 if(view != nil) |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
1808 { |
666
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
1809 Box *box = [view box]; |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
1810 NSSize size = [view frame].size; |
666
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
1811 _do_resize(box, size.width, size.height); |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
1812 } |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
1813 } |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1814 /* 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
|
1815 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
|
1816 { |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1817 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
|
1818 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
|
1819 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
|
1820 [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
|
1821 [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
|
1822 [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
|
1823 [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
|
1824 } |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
1825 else if([handle isMemberOfClass:[DWRender class]]) |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
1826 { |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
1827 _event_handler(handle, nil, 1); |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
1828 } |
677
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
1829 else if([handle isMemberOfClass:[DWSplitBar class]] && size.width > 20 && size.height > 20) |
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
1830 { |
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
1831 DWSplitBar *split = (DWSplitBar *)handle; |
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
1832 float percent = [split percent]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1833 |
677
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
1834 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
|
1835 { |
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
1836 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
|
1837 [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
|
1838 } |
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
1839 } |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1840 |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
1841 if(thisbox->type == DW_HORZ) |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1842 currentx += width + vectorx + (pad * 2); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1843 if(thisbox->type == DW_VERT) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1844 currenty += height + vectory + (pad * 2); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1845 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1846 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1847 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1848 return 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1849 } |
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 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
|
1852 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1853 if(x != 0 && y != 0) |
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 if(thisbox) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1856 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1857 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
|
1858 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1859 _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
|
1860 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1861 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
|
1862 return; |
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 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
|
1865 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
|
1866 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1867 usedx = usedy = usedpadx = usedpady = depth = 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1868 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1869 _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
|
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 |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
1874 NSMenu *_generate_main_menu() |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
1875 { |
717
17923b931393
Fixes for building for MacOS 10.5 and PPC
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
715
diff
changeset
|
1876 NSString *applicationName = nil; |
17923b931393
Fixes for building for MacOS 10.5 and PPC
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
715
diff
changeset
|
1877 |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1878 /* 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
|
1879 #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
|
1880 applicationName = [[NSRunningApplication currentApplication] localizedName]; |
17923b931393
Fixes for building for MacOS 10.5 and PPC
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
715
diff
changeset
|
1881 #endif |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1882 if(applicationName == nil) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1883 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1884 applicationName = [[NSProcessInfo processInfo] processName]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1885 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1886 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1887 /* Create the main menu */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1888 NSMenu * mainMenu = [[[NSMenu alloc] initWithTitle:@"MainMenu"] autorelease]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1889 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1890 NSMenuItem * mitem = [mainMenu addItemWithTitle:@"Apple" action:NULL keyEquivalent:@""]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1891 NSMenu * menu = [[[NSMenu alloc] initWithTitle:@"Apple"] autorelease]; |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
1892 |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1893 [DWApp performSelector:@selector(setAppleMenu:) withObject:menu]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1894 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1895 /* Setup the Application menu */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1896 NSMenuItem * item = [menu addItemWithTitle:[NSString stringWithFormat:@"%@ %@", NSLocalizedString(@"About", nil), applicationName] |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
1897 action:@selector(orderFrontStandardAboutPanel:) |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
1898 keyEquivalent:@""]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1899 [item setTarget:DWApp]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1900 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1901 [menu addItem:[NSMenuItem separatorItem]]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1902 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1903 item = [menu addItemWithTitle:NSLocalizedString(@"Services", nil) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1904 action:NULL |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1905 keyEquivalent:@""]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1906 NSMenu * servicesMenu = [[[NSMenu alloc] initWithTitle:@"Services"] autorelease]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1907 [menu setSubmenu:servicesMenu forItem:item]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1908 [DWApp setServicesMenu:servicesMenu]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1909 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1910 [menu addItem:[NSMenuItem separatorItem]]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1911 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1912 item = [menu addItemWithTitle:[NSString stringWithFormat:@"%@ %@", NSLocalizedString(@"Hide", nil), applicationName] |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1913 action:@selector(hide:) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1914 keyEquivalent:@"h"]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1915 [item setTarget:DWApp]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1916 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1917 item = [menu addItemWithTitle:NSLocalizedString(@"Hide Others", nil) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1918 action:@selector(hideOtherApplications:) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1919 keyEquivalent:@"h"]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1920 [item setKeyEquivalentModifierMask:NSCommandKeyMask | NSAlternateKeyMask]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1921 [item setTarget:DWApp]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1922 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1923 item = [menu addItemWithTitle:NSLocalizedString(@"Show All", nil) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1924 action:@selector(unhideAllApplications:) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1925 keyEquivalent:@""]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1926 [item setTarget:DWApp]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1927 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1928 [menu addItem:[NSMenuItem separatorItem]]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1929 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1930 item = [menu addItemWithTitle:[NSString stringWithFormat:@"%@ %@", NSLocalizedString(@"Quit", nil), applicationName] |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1931 action:@selector(terminate:) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1932 keyEquivalent:@"q"]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1933 [item setTarget:DWApp]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1934 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1935 [mainMenu setSubmenu:menu forItem:mitem]; |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
1936 |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
1937 return mainMenu; |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
1938 } |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
1939 |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
1940 /* |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1941 * 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
|
1942 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1943 void API dw_main(void) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1944 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
1945 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
|
1946 DWThread = dw_thread_id(); |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1947 [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
|
1948 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
|
1949 dw_mutex_unlock(DWRunMutex); |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1950 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1951 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1952 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1953 * 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
|
1954 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1955 * 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
|
1956 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1957 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
|
1958 { |
694
130ca42c4ae3
Reimplementation of dw_main_iteration and dw_main_sleep that actually work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
693
diff
changeset
|
1959 DWTID curr = pthread_self(); |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1960 |
694
130ca42c4ae3
Reimplementation of dw_main_iteration and dw_main_sleep that actually work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
693
diff
changeset
|
1961 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
|
1962 { |
130ca42c4ae3
Reimplementation of dw_main_iteration and dw_main_sleep that actually work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
693
diff
changeset
|
1963 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
|
1964 NSDate *until = [NSDate dateWithTimeIntervalSinceNow:(milliseconds/1000.0)]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1965 |
695
3b17111499bf
Minor updates to the last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
694
diff
changeset
|
1966 if(orig == (DWTID)-1) |
3b17111499bf
Minor updates to the last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
694
diff
changeset
|
1967 { |
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
|
1968 dw_mutex_lock(DWRunMutex); |
695
3b17111499bf
Minor updates to the last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
694
diff
changeset
|
1969 DWThread = curr; |
3b17111499bf
Minor updates to the last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
694
diff
changeset
|
1970 } |
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
|
1971 /* 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
|
1972 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
|
1973 { |
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
|
1974 /* Just loop */ |
695
3b17111499bf
Minor updates to the last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
694
diff
changeset
|
1975 } |
3b17111499bf
Minor updates to the last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
694
diff
changeset
|
1976 if(orig == (DWTID)-1) |
3b17111499bf
Minor updates to the last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
694
diff
changeset
|
1977 { |
3b17111499bf
Minor updates to the last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
694
diff
changeset
|
1978 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
|
1979 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
|
1980 } |
130ca42c4ae3
Reimplementation of dw_main_iteration and dw_main_sleep that actually work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
693
diff
changeset
|
1981 } |
130ca42c4ae3
Reimplementation of dw_main_iteration and dw_main_sleep that actually work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
693
diff
changeset
|
1982 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
|
1983 { |
694
130ca42c4ae3
Reimplementation of dw_main_iteration and dw_main_sleep that actually work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
693
diff
changeset
|
1984 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
|
1985 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1986 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1987 |
700
7953f0471e4d
Some cleanups for the run loop iteration and thread system.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
699
diff
changeset
|
1988 /* 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
|
1989 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
|
1990 { |
694
130ca42c4ae3
Reimplementation of dw_main_iteration and dw_main_sleep that actually work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
693
diff
changeset
|
1991 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
|
1992 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
|
1993 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
|
1994 dequeue:YES]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1995 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
|
1996 { |
130ca42c4ae3
Reimplementation of dw_main_iteration and dw_main_sleep that actually work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
693
diff
changeset
|
1997 [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
|
1998 [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
|
1999 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
|
2000 } |
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
|
2001 return 0; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2002 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2003 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2004 /* |
700
7953f0471e4d
Some cleanups for the run loop iteration and thread system.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
699
diff
changeset
|
2005 * 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
|
2006 */ |
7953f0471e4d
Some cleanups for the run loop iteration and thread system.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
699
diff
changeset
|
2007 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
|
2008 { |
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
|
2009 DWTID curr = pthread_self(); |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2010 |
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
|
2011 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
|
2012 { |
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
|
2013 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
|
2014 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
|
2015 _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
|
2016 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
|
2017 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
|
2018 } |
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
|
2019 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
|
2020 { |
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
|
2021 _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
|
2022 } |
700
7953f0471e4d
Some cleanups for the run loop iteration and thread system.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
699
diff
changeset
|
2023 } |
7953f0471e4d
Some cleanups for the run loop iteration and thread system.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
699
diff
changeset
|
2024 |
7953f0471e4d
Some cleanups for the run loop iteration and thread system.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
699
diff
changeset
|
2025 /* |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2026 * 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
|
2027 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2028 * 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
|
2029 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2030 void API dw_exit(int exitcode) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2031 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2032 exit(exitcode); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2033 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2034 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2035 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2036 * 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
|
2037 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2038 * ptr: Pointer to dynamic windows allocated |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2039 * memory to be free()'d. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2040 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2041 void API dw_free(void *ptr) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2042 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2043 free(ptr); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2044 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2045 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2046 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2047 * 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
|
2048 * 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
|
2049 * OS/2 and Windows). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2050 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2051 char *dw_user_dir(void) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2052 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2053 static char _user_dir[1024] = ""; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2054 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2055 if(!_user_dir[0]) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2056 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2057 char *home = getenv("HOME"); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2058 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2059 if(home) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2060 strcpy(_user_dir, home); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2061 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2062 strcpy(_user_dir, "/"); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2063 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2064 return _user_dir; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2065 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2066 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2067 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2068 * 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
|
2069 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2070 * 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
|
2071 * 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
|
2072 * format: printf style format string. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2073 * ...: 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
|
2074 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2075 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
|
2076 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2077 int iResponse; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2078 NSString *button1 = @"OK"; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2079 NSString *button2 = nil; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2080 NSString *button3 = nil; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2081 va_list args; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2082 char outbuf[1000]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2083 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2084 va_start(args, format); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2085 vsprintf(outbuf, format, args); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2086 va_end(args); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2087 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2088 if(flags & DW_MB_OKCANCEL) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2089 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2090 button2 = @"Cancel"; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2091 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2092 else if(flags & DW_MB_YESNO) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2093 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2094 button1 = @"Yes"; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2095 button2 = @"No"; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2096 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2097 else if(flags & DW_MB_YESNOCANCEL) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2098 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2099 button1 = @"Yes"; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2100 button2 = @"No"; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2101 button3 = @"Cancel"; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2102 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2103 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2104 if(flags & DW_MB_ERROR) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2105 { |
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
|
2106 iResponse = (int) |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2107 NSRunCriticalAlertPanel([ NSString stringWithUTF8String:title ], |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2108 [ NSString stringWithUTF8String:outbuf ], |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2109 button1, button2, button3); } |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2110 else |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2111 { |
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
|
2112 iResponse = (int) |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2113 NSRunAlertPanel([ NSString stringWithUTF8String:title ], |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2114 [ NSString stringWithUTF8String:outbuf ], |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2115 button1, button2, button3); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2116 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2117 |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2118 switch(iResponse) |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2119 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2120 case NSAlertDefaultReturn: /* user pressed OK */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2121 if(flags & DW_MB_YESNO || flags & DW_MB_YESNOCANCEL) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2122 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2123 return DW_MB_RETURN_YES; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2124 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2125 return DW_MB_RETURN_OK; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2126 case NSAlertAlternateReturn: /* user pressed Cancel */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2127 if(flags & DW_MB_OKCANCEL) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2128 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2129 return DW_MB_RETURN_CANCEL; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2130 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2131 return DW_MB_RETURN_NO; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2132 case NSAlertOtherReturn: /* user pressed the third button */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2133 return DW_MB_RETURN_CANCEL; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2134 case NSAlertErrorReturn: /* an error occurred */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2135 break; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2136 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2137 return 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2138 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2139 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2140 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2141 * 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
|
2142 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2143 * title: Title bar text for dialog. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2144 * 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
|
2145 * ext: Default file extention. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2146 * 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
|
2147 * Returns: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2148 * 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
|
2149 * the file path on success. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2150 * |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2151 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2152 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
|
2153 { |
651
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2154 if(flags == DW_FILE_OPEN) |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2155 { |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2156 /* Create the File Open Dialog class. */ |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2157 NSOpenPanel* openDlg = [NSOpenPanel openPanel]; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2158 |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2159 /* Enable the selection of files in the dialog. */ |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2160 [openDlg setCanChooseFiles:YES]; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2161 [openDlg setCanChooseDirectories:NO]; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2162 |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2163 /* Disable multiple selection */ |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2164 [openDlg setAllowsMultipleSelection:NO]; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2165 |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2166 /* Display the dialog. If the OK button was pressed, |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2167 * process the files. |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2168 */ |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2169 if([openDlg runModal] == NSOKButton) |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2170 { |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2171 /* Get an array containing the full filenames of all |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2172 * files and directories selected. |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2173 */ |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2174 NSArray* files = [openDlg filenames]; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2175 NSString* fileName = [files objectAtIndex:0]; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2176 return strdup([ fileName UTF8String ]); |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2177 } |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2178 } |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2179 else |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2180 { |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2181 /* Create the File Save Dialog class. */ |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2182 NSSavePanel* saveDlg = [NSSavePanel savePanel]; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2183 |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
2184 /* Enable the creation of directories in the dialog. */ |
651
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2185 [saveDlg setCanCreateDirectories:YES]; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2186 |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2187 /* Display the dialog. If the OK button was pressed, |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2188 * process the files. |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2189 */ |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2190 if([saveDlg runModal] == NSFileHandlingPanelOKButton) |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2191 { |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2192 /* Get an array containing the full filenames of all |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2193 * files and directories selected. |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2194 */ |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2195 NSString* fileName = [saveDlg filename]; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2196 return strdup([ fileName UTF8String ]); |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2197 } |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2198 } |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2199 |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2200 return NULL; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2201 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2202 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2203 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2204 * 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
|
2205 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2206 * None. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2207 * Returns: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2208 * 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
|
2209 * be converted to text. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2210 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2211 char *dw_clipboard_get_text() |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2212 { |
651
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2213 NSPasteboard *pasteboard = [NSPasteboard generalPasteboard]; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2214 NSString *str = [pasteboard stringForType:NSStringPboardType]; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2215 if(str != nil) |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2216 { |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2217 return strdup([ str UTF8String ]); |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2218 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2219 return NULL; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2220 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2221 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2222 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2223 * 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
|
2224 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2225 * Text. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2226 */ |
651
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2227 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
|
2228 { |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2229 NSPasteboard *pasteboard = [NSPasteboard generalPasteboard]; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2230 |
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
|
2231 #ifdef BUILDING_FOR_SNOW_LEOPARD |
651
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2232 [pasteboard clearContents]; |
718
002f33d4439d
More 10.5 fixes... some selectors cause exceptions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
717
diff
changeset
|
2233 #endif |
651
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2234 |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2235 [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
|
2236 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2237 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2238 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2239 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2240 * Allocates and initializes a dialog struct. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2241 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2242 * 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
|
2243 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2244 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
|
2245 { |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
2246 DWDialog *tmp = malloc(sizeof(DWDialog)); |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
2247 |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
2248 if(tmp) |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
2249 { |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
2250 tmp->eve = dw_event_new(); |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
2251 dw_event_reset(tmp->eve); |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
2252 tmp->data = data; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
2253 tmp->done = FALSE; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
2254 tmp->result = NULL; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
2255 } |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
2256 return tmp; |
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 * 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
|
2261 * initial called of dw_dialog_wait(). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2262 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2263 * 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
|
2264 * 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
|
2265 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2266 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
|
2267 { |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
2268 dialog->result = result; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
2269 dw_event_post(dialog->eve); |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
2270 dialog->done = TRUE; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2271 return 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2272 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2273 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2274 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2275 * 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
|
2276 * 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
|
2277 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2278 * 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
|
2279 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2280 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
|
2281 { |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
2282 void *tmp; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
2283 |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
2284 while(!dialog->done) |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
2285 { |
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
|
2286 _dw_main_iteration([NSDate dateWithTimeIntervalSinceNow:0.01]); |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
2287 } |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
2288 dw_event_close(&dialog->eve); |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
2289 tmp = dialog->result; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
2290 free(dialog); |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
2291 return tmp; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2292 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2293 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2294 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2295 * 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
|
2296 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2297 * 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
|
2298 * 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
|
2299 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2300 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
|
2301 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
2302 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
|
2303 DW_MUTEX_LOCK; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2304 DWBox *view = [[DWBox alloc] init]; |
666
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
2305 Box *newbox = [view box]; |
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
2306 memset(newbox, 0, sizeof(Box)); |
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
2307 newbox->pad = pad; |
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
2308 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
|
2309 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2310 return view; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2311 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2312 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2313 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2314 * 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
|
2315 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2316 * 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
|
2317 * 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
|
2318 * 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
|
2319 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2320 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
|
2321 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2322 DWBox *box = dw_box_new(type, pad); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2323 [box setFocusRingType:NSFocusRingTypeExterior]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2324 return box; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2325 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2326 |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2327 #ifndef INCOMPLETE |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2328 /* |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2329 * Create a new scrollable Box to be packed. |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2330 * Parameters: |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2331 * 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
|
2332 * 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
|
2333 * 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
|
2334 */ |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2335 HWND dw_scrollbox_new( int type, int pad ) |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2336 { |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2337 DWBox *box = dw_box_new(type, pad); |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2338 [box setFocusRingType:NSFocusRingTypeExterior]; |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2339 NSLog(@"dw_scrollbox_new() unimplemented\n"); |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2340 return box; |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2341 } |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2342 |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2343 /* |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2344 * 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
|
2345 * Parameters: |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2346 * handle: Handle to the scrollbox to be queried. |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2347 * orient: The vertical or horizontal scrollbar. |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2348 */ |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2349 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
|
2350 { |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2351 int val = -1; |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2352 NSLog(@"dw_scrollbox_get_pos() unimplemented\n"); |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2353 return val; |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2354 } |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2355 |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2356 /* |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2357 * 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
|
2358 * Parameters: |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2359 * handle: Handle to the scrollbox to be queried. |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2360 * orient: The vertical or horizontal scrollbar. |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2361 */ |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2362 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
|
2363 { |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2364 int val = -1; |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2365 NSLog(@"dw_scrollbox_get_range() unimplemented\n"); |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2366 return val; |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2367 } |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2368 #endif |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2369 |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2370 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2371 * 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
|
2372 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2373 * 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
|
2374 * 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
|
2375 * 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
|
2376 * 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
|
2377 * 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
|
2378 * 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
|
2379 * 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
|
2380 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2381 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
|
2382 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
2383 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
|
2384 DW_MUTEX_LOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2385 NSObject *object = box; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2386 DWBox *view = box; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2387 DWBox *this = item; |
666
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
2388 Box *thisbox; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2389 int z; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2390 Item *tmpitem, *thisitem; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2391 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2392 /* Query the objects */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2393 if([ object isKindOfClass:[ NSWindow class ] ]) |
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 NSWindow *window = box; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2396 view = [window contentView]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2397 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2398 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2399 thisbox = [view box]; |
666
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
2400 thisitem = thisbox->items; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2401 object = item; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2402 |
668
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
2403 /* Query the objects */ |
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
2404 if([ object isKindOfClass:[ DWContainer class ] ]) |
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
2405 { |
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
2406 DWContainer *cont = item; |
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
2407 this = item = [cont scrollview]; |
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
2408 } |
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
|
2409 else if([ object isKindOfClass:[ DWTree class ] ]) |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
2410 { |
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
|
2411 DWTree *tree = item; |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
2412 this = item = [tree scrollview]; |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
2413 } |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2414 |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2415 /* 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
|
2416 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
|
2417 |
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
2418 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
|
2419 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2420 tmpitem[z+1] = thisitem[z]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2421 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2422 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2423 /* Sanity checks */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2424 if(vsize && !height) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2425 height = 1; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2426 if(hsize && !width) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2427 width = 1; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2428 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2429 /* Fill in the item data appropriately */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2430 if([ object isKindOfClass:[ DWBox class ] ]) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2431 tmpitem[0].type = TYPEBOX; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2432 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2433 tmpitem[0].type = TYPEITEM; |
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 tmpitem[0].hwnd = item; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2436 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
|
2437 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
|
2438 tmpitem[0].pad = pad; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2439 if(hsize) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2440 tmpitem[0].hsize = SIZEEXPAND; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2441 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2442 tmpitem[0].hsize = SIZESTATIC; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2443 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2444 if(vsize) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2445 tmpitem[0].vsize = SIZEEXPAND; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2446 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2447 tmpitem[0].vsize = SIZESTATIC; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2448 |
666
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
2449 thisbox->items = tmpitem; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2450 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2451 /* 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
|
2452 thisbox->count++; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2453 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2454 /* Add the item to the box */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2455 [view addSubview:this]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2456 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2457 /* 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
|
2458 if(thisbox->count) |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2459 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
|
2460 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2461 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2462 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2463 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2464 * 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
|
2465 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2466 * 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
|
2467 * 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
|
2468 * 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
|
2469 * 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
|
2470 * 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
|
2471 * 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
|
2472 * 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
|
2473 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2474 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
|
2475 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
2476 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
|
2477 DW_MUTEX_LOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2478 NSObject *object = box; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2479 DWBox *view = box; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2480 DWBox *this = item; |
666
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
2481 Box *thisbox; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2482 int z; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2483 Item *tmpitem, *thisitem; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2484 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2485 /* Query the objects */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2486 if([ object isKindOfClass:[ NSWindow class ] ]) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2487 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2488 NSWindow *window = box; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2489 view = [window contentView]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2490 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2491 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2492 thisbox = [view box]; |
666
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
2493 thisitem = thisbox->items; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2494 object = item; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2495 |
668
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
2496 /* Query the objects */ |
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
2497 if([ object isKindOfClass:[ DWContainer class ] ]) |
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
2498 { |
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
2499 DWContainer *cont = item; |
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
2500 this = item = [cont scrollview]; |
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
2501 } |
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
|
2502 else if([ object isKindOfClass:[ DWTree class ] ]) |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
2503 { |
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
|
2504 DWTree *tree = item; |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
2505 this = item = [tree scrollview]; |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
2506 } |
668
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
2507 |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2508 /* 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
|
2509 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
|
2510 |
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
2511 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
|
2512 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2513 tmpitem[z] = thisitem[z]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2514 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2515 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2516 /* Sanity checks */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2517 if(vsize && !height) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2518 height = 1; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2519 if(hsize && !width) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2520 width = 1; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2521 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2522 /* Fill in the item data appropriately */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2523 if([ object isKindOfClass:[ DWBox class ] ]) |
666
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
2524 tmpitem[thisbox->count].type = TYPEBOX; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2525 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
|
2526 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
|
2527 |
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
2528 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
|
2529 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
|
2530 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
|
2531 tmpitem[thisbox->count].pad = pad; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2532 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
|
2533 tmpitem[thisbox->count].hsize = SIZEEXPAND; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2534 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
|
2535 tmpitem[thisbox->count].hsize = SIZESTATIC; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2536 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2537 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
|
2538 tmpitem[thisbox->count].vsize = SIZEEXPAND; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2539 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
|
2540 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
|
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 thisbox->items = tmpitem; |
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 /* 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
|
2545 thisbox->count++; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2546 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2547 /* Add the item to the box */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2548 [view addSubview:this]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2549 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2550 /* 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
|
2551 if(thisbox->count) |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2552 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
|
2553 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2554 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2555 |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
2556 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
|
2557 { |
744
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
2558 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
|
2559 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
|
2560 { |
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
2561 [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
|
2562 } |
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
2563 [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
|
2564 [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
|
2565 [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
|
2566 [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
|
2567 [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
|
2568 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
|
2569 { |
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
2570 [[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
|
2571 } |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2572 return button; |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2573 } |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2574 |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2575 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2576 * 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
|
2577 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2578 * 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
|
2579 * 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
|
2580 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
2581 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
|
2582 { |
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
2583 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
|
2584 [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
|
2585 [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
|
2586 [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
|
2587 [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
|
2588 [[button cell] setControlTint:NSBlueControlTint]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2589 return button; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2590 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2591 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2592 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2593 * 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
|
2594 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2595 * 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
|
2596 * 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
|
2597 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
2598 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
|
2599 { |
651
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2600 DWEntryField *entry = [[DWEntryField alloc] init]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2601 [entry setStringValue:[ NSString stringWithUTF8String:text ]]; |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
2602 [entry setTag:cid]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2603 return entry; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2604 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2605 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2606 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2607 * 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
|
2608 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2609 * 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
|
2610 * 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
|
2611 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
2612 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
|
2613 { |
651
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2614 DWEntryFieldPassword *entry = [[DWEntryFieldPassword alloc] init]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2615 [entry setStringValue:[ NSString stringWithUTF8String:text ]]; |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
2616 [entry setTag:cid]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2617 return entry; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2618 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2619 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2620 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2621 * Sets the entryfield character limit. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2622 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2623 * 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
|
2624 * 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
|
2625 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2626 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
|
2627 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2628 NSLog(@"dw_entryfield_set_limit() unimplemented\n"); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2629 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2630 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2631 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2632 * 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
|
2633 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2634 * 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
|
2635 * 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
|
2636 */ |
670
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
2637 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
|
2638 { |
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
|
2639 /* TODO: Implement tooltips */ |
670
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
2640 NSBundle *bundle = [NSBundle mainBundle]; |
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
2641 NSString *respath = [bundle resourcePath]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2642 NSString *filepath = [respath stringByAppendingFormat:@"/%u.png", resid]; |
670
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
2643 NSImage *image = [[NSImage alloc] initWithContentsOfFile:filepath]; |
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
2644 DWButton *button = _button_new("", resid); |
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
2645 [button setImage:image]; |
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
2646 [button setButtonType:NSMomentaryLight]; |
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
2647 [button setBordered:NO]; |
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
2648 [image release]; |
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
2649 return button; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2650 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2651 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2652 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2653 * 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
|
2654 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2655 * 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
|
2656 * 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
|
2657 * 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
|
2658 * DW pick the appropriate file extension. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2659 * (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
|
2660 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
2661 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
|
2662 { |
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
|
2663 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
|
2664 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
|
2665 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
|
2666 { |
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
|
2667 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
|
2668 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
|
2669 } |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
2670 DWButton *button = _button_new("", cid); |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
2671 [button setImage:image]; |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
2672 [image release]; |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
2673 return button; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2674 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2675 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2676 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2677 * 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
|
2678 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2679 * 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
|
2680 * 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
|
2681 * data: The contents of the image |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2682 * (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
|
2683 * len: length of str |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2684 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
2685 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
|
2686 { |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
2687 NSData *thisdata = [[NSData alloc] dataWithBytes:data length:len]; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
2688 NSImage *image = [[NSImage alloc] initWithData:thisdata]; |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
2689 DWButton *button = _button_new("", cid); |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
2690 [button setImage:image]; |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
2691 [image release]; |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
2692 return button; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2693 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2694 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2695 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2696 * 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
|
2697 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2698 * 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
|
2699 * 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
|
2700 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
2701 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
|
2702 { |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
2703 DWSpinButton *spinbutton = [[DWSpinButton alloc] init]; |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
2704 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
|
2705 [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
|
2706 [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
|
2707 return spinbutton; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2708 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2709 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2710 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2711 * Sets the spinbutton value. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2712 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2713 * 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
|
2714 * position: Current value of the spinbutton. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2715 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2716 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
|
2717 { |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
2718 DWSpinButton *spinbutton = handle; |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
2719 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
|
2720 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
|
2721 [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
|
2722 [textfield takeIntValueFrom:stepper]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2723 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2724 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2725 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2726 * Sets the spinbutton limits. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2727 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2728 * 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
|
2729 * upper: Upper limit. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2730 * lower: Lower limit. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2731 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2732 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
|
2733 { |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
2734 DWSpinButton *spinbutton = handle; |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
2735 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
|
2736 [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
|
2737 [stepper setMaxValue:(double)upper]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2738 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2739 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2740 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2741 * 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
|
2742 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2743 * 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
|
2744 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2745 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
|
2746 { |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
2747 DWSpinButton *spinbutton = handle; |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
2748 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
|
2749 return (long)[stepper integerValue]; |
650
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 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2752 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2753 * 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
|
2754 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2755 * 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
|
2756 * 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
|
2757 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
2758 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
|
2759 { |
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
2760 DWButton *button = _button_new(text, cid); |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2761 [button setButtonType:NSRadioButton]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2762 return button; |
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 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2766 * 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
|
2767 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2768 * 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
|
2769 * increments: Number of increments available. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2770 * 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
|
2771 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
2772 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
|
2773 { |
704
336800e9e648
Fixes to the slider control so events happen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
703
diff
changeset
|
2774 DWSlider *slider = [[DWSlider alloc] init]; |
336800e9e648
Fixes to the slider control so events happen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
703
diff
changeset
|
2775 [slider setMaxValue:(double)increments]; |
336800e9e648
Fixes to the slider control so events happen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
703
diff
changeset
|
2776 [slider setMinValue:0]; |
336800e9e648
Fixes to the slider control so events happen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
703
diff
changeset
|
2777 [slider setContinuous:YES]; |
336800e9e648
Fixes to the slider control so events happen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
703
diff
changeset
|
2778 [slider setTarget:slider]; |
336800e9e648
Fixes to the slider control so events happen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
703
diff
changeset
|
2779 [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
|
2780 [slider setTag:cid]; |
704
336800e9e648
Fixes to the slider control so events happen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
703
diff
changeset
|
2781 return slider; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2782 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2783 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2784 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2785 * Returns the position of the slider. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2786 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2787 * 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
|
2788 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2789 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
|
2790 { |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
2791 DWSlider *slider = handle; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
2792 double val = [slider doubleValue]; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
2793 return (int)val; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2794 } |
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 * Sets the slider position. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2798 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2799 * 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
|
2800 * 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
|
2801 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2802 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
|
2803 { |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
2804 DWSlider *slider = handle; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
2805 [slider setDoubleValue:(double)position]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2806 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2807 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2808 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2809 * Create a new scrollbar window (widget) to be packed. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2810 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2811 * 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
|
2812 * increments: Number of increments available. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2813 * 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
|
2814 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
2815 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
|
2816 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
2817 DWScrollbar *scrollbar; |
689
4199730e9889
Fixed errors creating scrollbars.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
688
diff
changeset
|
2818 if(vertical) |
4199730e9889
Fixed errors creating scrollbars.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
688
diff
changeset
|
2819 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
2820 scrollbar = [[DWScrollbar alloc] init]; |
689
4199730e9889
Fixed errors creating scrollbars.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
688
diff
changeset
|
2821 } |
4199730e9889
Fixed errors creating scrollbars.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
688
diff
changeset
|
2822 else |
4199730e9889
Fixed errors creating scrollbars.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
688
diff
changeset
|
2823 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
2824 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
|
2825 } |
4199730e9889
Fixed errors creating scrollbars.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
688
diff
changeset
|
2826 [scrollbar setArrowsPosition:NSScrollerArrowsDefaultSetting]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2827 [scrollbar setTarget:scrollbar]; |
689
4199730e9889
Fixed errors creating scrollbars.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
688
diff
changeset
|
2828 [scrollbar setAction:@selector(changed:)]; |
4199730e9889
Fixed errors creating scrollbars.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
688
diff
changeset
|
2829 [scrollbar setRange:0.0 andVisible:0.0]; |
4199730e9889
Fixed errors creating scrollbars.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
688
diff
changeset
|
2830 [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
|
2831 [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
|
2832 [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
|
2833 [scrollbar setTag:cid]; |
689
4199730e9889
Fixed errors creating scrollbars.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
688
diff
changeset
|
2834 [scrollbar setEnabled:YES]; |
4199730e9889
Fixed errors creating scrollbars.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
688
diff
changeset
|
2835 return scrollbar; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2836 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2837 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2838 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2839 * Returns the position of the scrollbar. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2840 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2841 * 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
|
2842 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2843 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
|
2844 { |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
2845 DWScrollbar *scrollbar = handle; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
2846 float range = [scrollbar range]; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
2847 float fresult = [scrollbar doubleValue] * range; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
2848 return (int)fresult; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2849 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2850 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2851 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2852 * Sets the scrollbar position. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2853 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2854 * 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
|
2855 * 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
|
2856 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2857 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
|
2858 { |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
2859 DWScrollbar *scrollbar = handle; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
2860 double range = (double)[scrollbar range]; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
2861 double newpos = (double)position/range; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
2862 [scrollbar setDoubleValue:newpos]; |
650
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 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2865 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2866 * Sets the scrollbar range. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2867 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2868 * 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
|
2869 * range: Maximum range value. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2870 * 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
|
2871 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2872 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
|
2873 { |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
2874 DWScrollbar *scrollbar = handle; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
2875 float knob = (float)visible/(float)range; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
2876 [scrollbar setRange:(float)range andVisible:(float)visible]; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
2877 [scrollbar setKnobProportion:knob]; |
650
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 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2880 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2881 * 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
|
2882 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2883 * 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
|
2884 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
2885 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
|
2886 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2887 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
|
2888 [percent setStyle:NSProgressIndicatorBarStyle]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2889 [percent setBezeled:YES]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2890 [percent setMaxValue:100]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2891 [percent setMinValue:0]; |
714
cf6246f86c04
Fixed the percent/progress indicators from always being indeterminate.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
713
diff
changeset
|
2892 [percent incrementBy:1]; |
cf6246f86c04
Fixed the percent/progress indicators from always being indeterminate.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
713
diff
changeset
|
2893 [percent setIndeterminate:NO]; |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
2894 /*[percent setTag:cid]; Why doesn't this work? */ |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2895 return percent; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2896 } |
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 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2899 * Sets the percent bar position. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2900 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2901 * 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
|
2902 * 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
|
2903 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2904 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
|
2905 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2906 DWPercent *percent = handle; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2907 [percent setDoubleValue:(double)position]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2908 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2909 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2910 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2911 * 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
|
2912 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2913 * 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
|
2914 * 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
|
2915 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
2916 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
|
2917 { |
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
2918 DWButton *button = _button_new(text, cid); |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2919 [button setButtonType:NSSwitchButton]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2920 [button setBezelStyle:NSRegularSquareBezelStyle]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2921 return button; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2922 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2923 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2924 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2925 * Returns the state of the checkbox. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2926 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2927 * 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
|
2928 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2929 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
|
2930 { |
656
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2931 DWButton *button = handle; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2932 if([button state]) |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2933 { |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2934 return TRUE; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2935 } |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2936 return FALSE; |
650
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 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2939 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2940 * Sets the state of the checkbox. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2941 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2942 * 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
|
2943 * 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
|
2944 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2945 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
|
2946 { |
656
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2947 DWButton *button = handle; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2948 if(value) |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2949 { |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2950 [button setState:NSOnState]; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2951 } |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2952 else |
656
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2953 { |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2954 [button setState:NSOffState]; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2955 } |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2956 |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2957 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2958 |
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
|
2959 /* 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
|
2960 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
|
2961 { |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2962 NSScrollView *scrollview = [[NSScrollView alloc] init]; |
658
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
2963 DWContainer *cont = [[DWContainer alloc] init]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2964 |
668
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
2965 [cont setScrollview:scrollview]; |
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
2966 [scrollview setBorderType:NSBezelBorder]; |
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
2967 [scrollview setHasVerticalScroller:YES]; |
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
2968 [scrollview setAutohidesScrollers:YES]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2969 |
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
|
2970 if(multi) |
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
2971 { |
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
2972 [cont setAllowsMultipleSelection:YES]; |
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
2973 } |
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
2974 else |
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
2975 { |
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
2976 [cont setAllowsMultipleSelection:NO]; |
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
2977 } |
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
2978 [cont setDataSource:cont]; |
668
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
2979 [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
|
2980 [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
|
2981 [scrollview release]; |
658
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
2982 return cont; |
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
2983 } |
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
2984 |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2985 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2986 * 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
|
2987 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2988 * 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
|
2989 * multi: Multiple select TRUE or FALSE. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2990 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
2991 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
|
2992 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
2993 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
|
2994 DW_MUTEX_LOCK; |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
2995 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
|
2996 [cont setHeaderView:nil]; |
658
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
2997 int type = DW_CFA_STRING; |
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
2998 [cont setup]; |
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
2999 NSTableColumn *column = [[NSTableColumn alloc] init]; |
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
3000 [cont addTableColumn:column]; |
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
3001 [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
|
3002 [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
|
3003 DW_MUTEX_UNLOCK; |
658
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
3004 return cont; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3005 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3006 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3007 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3008 * 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
|
3009 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3010 * 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
|
3011 * text: Text to append into listbox. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3012 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3013 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
|
3014 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3015 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
|
3016 DW_MUTEX_LOCK; |
656
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3017 id object = handle; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3018 |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3019 if([object isMemberOfClass:[DWComboBox class]]) |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3020 { |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3021 DWComboBox *combo = handle; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3022 |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3023 [combo addItemWithObjectValue:[ NSString stringWithUTF8String:text ]]; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3024 } |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3025 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
|
3026 { |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3027 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
|
3028 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
|
3029 NSArray *newrow = [NSArray arrayWithObject:nstr]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
3030 |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3031 [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
|
3032 /*[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
|
3033 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
|
3034 waitUntilDone:YES];*/ |
670
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
3035 [cont reloadData]; |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3036 } |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3037 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3038 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3039 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3040 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3041 * 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
|
3042 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3043 * 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
|
3044 * text: Text to insert into listbox. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3045 * 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
|
3046 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3047 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
|
3048 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3049 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
|
3050 DW_MUTEX_LOCK; |
656
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3051 id object = handle; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3052 |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3053 if([object isMemberOfClass:[DWComboBox class]]) |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3054 { |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3055 DWComboBox *combo = handle; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3056 |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3057 [combo insertItemWithObjectValue:[ NSString stringWithUTF8String:text ] atIndex:pos]; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3058 } |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3059 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
|
3060 { |
687
5dde8d34bc69
Implemented dw_listbox_insert for containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
686
diff
changeset
|
3061 DWContainer *cont = handle; |
5dde8d34bc69
Implemented dw_listbox_insert for containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
686
diff
changeset
|
3062 NSString *nstr = [ NSString stringWithUTF8String:text ]; |
5dde8d34bc69
Implemented dw_listbox_insert for containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
686
diff
changeset
|
3063 NSArray *newrow = [NSArray arrayWithObject:nstr]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
3064 |
687
5dde8d34bc69
Implemented dw_listbox_insert for containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
686
diff
changeset
|
3065 [cont insertRow:newrow at:pos]; |
5dde8d34bc69
Implemented dw_listbox_insert for containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
686
diff
changeset
|
3066 [cont reloadData]; |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3067 } |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3068 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3069 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3070 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3071 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3072 * 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
|
3073 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3074 * 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
|
3075 * 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
|
3076 * 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
|
3077 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3078 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
|
3079 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3080 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
|
3081 DW_MUTEX_LOCK; |
656
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3082 id object = handle; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3083 |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3084 if([object isMemberOfClass:[DWComboBox class]]) |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3085 { |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3086 DWComboBox *combo = handle; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3087 int z; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3088 |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3089 for(z=0;z<count;z++) |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3090 { |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3091 [combo addItemWithObjectValue:[ NSString stringWithUTF8String:text[z] ]]; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3092 } |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3093 } |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3094 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
|
3095 { |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3096 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
|
3097 int z; |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3098 |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3099 for(z=0;z<count;z++) |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3100 { |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3101 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
|
3102 NSArray *newrow = [[NSArray alloc] arrayWithObject:nstr]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
3103 |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3104 [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
|
3105 } |
670
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
3106 [cont reloadData]; |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3107 } |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3108 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3109 } |
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 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3112 * 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
|
3113 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3114 * 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
|
3115 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3116 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
|
3117 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3118 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
|
3119 DW_MUTEX_LOCK; |
656
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3120 id object = handle; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3121 |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3122 if([object isMemberOfClass:[DWComboBox class]]) |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3123 { |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3124 DWComboBox *combo = handle; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3125 |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3126 [combo removeAllItems]; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3127 } |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3128 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
|
3129 { |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3130 DWContainer *cont = handle; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
3131 |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3132 [cont clear]; |
670
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
3133 [cont reloadData]; |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3134 } |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3135 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3136 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3137 |
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 * Returns the listbox's item count. |
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 * 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
|
3142 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3143 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
|
3144 { |
656
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3145 id object = handle; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3146 |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3147 if([object isMemberOfClass:[DWComboBox class]]) |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3148 { |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3149 DWComboBox *combo = handle; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3150 |
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
|
3151 return (int)[combo numberOfItems]; |
656
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3152 } |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3153 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
|
3154 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3155 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
|
3156 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
|
3157 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
|
3158 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
|
3159 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
|
3160 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
|
3161 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3162 return 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3163 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3164 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3165 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3166 * 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
|
3167 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3168 * 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
|
3169 * top: Index to the top item. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3170 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3171 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
|
3172 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3173 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
|
3174 DW_MUTEX_LOCK; |
656
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3175 id object = handle; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3176 |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3177 if([object isMemberOfClass:[DWComboBox class]]) |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3178 { |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3179 DWComboBox *combo = handle; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3180 |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3181 [combo scrollItemAtIndexToTop:top]; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3182 } |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3183 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
|
3184 { |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3185 DWContainer *cont = handle; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
3186 |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3187 [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
|
3188 } |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3189 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3190 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3191 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3192 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3193 * 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
|
3194 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3195 * 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
|
3196 * 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
|
3197 * 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
|
3198 * 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
|
3199 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3200 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
|
3201 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3202 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
|
3203 DW_MUTEX_LOCK; |
656
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3204 id object = handle; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3205 |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3206 if([object isMemberOfClass:[DWComboBox class]]) |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3207 { |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3208 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
|
3209 int count = (int)[combo numberOfItems]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
3210 |
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
|
3211 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
|
3212 { |
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
|
3213 *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
|
3214 } |
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
|
3215 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
|
3216 { |
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
|
3217 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
|
3218 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
|
3219 } |
656
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3220 } |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3221 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
|
3222 { |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3223 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
|
3224 int count = (int)[cont numberOfRowsInTableView:cont]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
3225 |
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
|
3226 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
|
3227 { |
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
|
3228 *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
|
3229 } |
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
|
3230 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
|
3231 { |
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
|
3232 NSString *nstr = [cont getRow:index and:0]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
3233 |
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
|
3234 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
|
3235 } |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3236 } |
691
578bbfd8c904
Added 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_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3238 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3239 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3240 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3241 * 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
|
3242 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3243 * 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
|
3244 * 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
|
3245 * 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
|
3246 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3247 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
|
3248 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3249 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
|
3250 DW_MUTEX_LOCK; |
656
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3251 id object = handle; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3252 |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3253 if([object isMemberOfClass:[DWComboBox class]]) |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3254 { |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3255 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
|
3256 int count = (int)[combo numberOfItems]; |
656
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3257 |
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
|
3258 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
|
3259 { |
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
|
3260 [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
|
3261 [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
|
3262 } |
656
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3263 } |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3264 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
|
3265 { |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3266 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
|
3267 int count = (int)[cont numberOfRowsInTableView:cont]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
3268 |
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
|
3269 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
|
3270 { |
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
|
3271 NSString *nstr = [ NSString stringWithUTF8String:buffer ]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
3272 |
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
|
3273 [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
|
3274 [cont reloadData]; |
357b59e57a31
Some fixes for out of range parameters passed to dw_listbox_g/set_text().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
719
diff
changeset
|
3275 } |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3276 } |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
3277 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3278 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3279 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3280 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3281 * 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
|
3282 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3283 * 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
|
3284 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3285 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
|
3286 { |
656
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3287 id object = handle; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3288 |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3289 if([object isMemberOfClass:[DWComboBox class]]) |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3290 { |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3291 DWComboBox *combo = handle; |
665
e6bec2290f3f
Fixing warnings with Xcode 4 and switched to manual releasing in the draw functions to stop leaking.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
664
diff
changeset
|
3292 return (int)[combo indexOfSelectedItem]; |
656
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3293 } |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3294 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
|
3295 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3296 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
|
3297 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
|
3298 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
|
3299 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
|
3300 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
|
3301 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
|
3302 } |
656
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3303 return -1; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3304 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3305 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3306 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3307 * 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
|
3308 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3309 * 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
|
3310 * 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
|
3311 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3312 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
|
3313 { |
691
578bbfd8c904
Added 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 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
|
3315 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
|
3316 id object = handle; |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3317 int retval = -1; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
3318 |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3319 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
|
3320 { |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3321 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
|
3322 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
|
3323 NSUInteger result = [selected indexGreaterThanIndex:where]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
3324 |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3325 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
|
3326 { |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3327 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
|
3328 } |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
3329 } |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3330 DW_MUTEX_UNLOCK; |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3331 return retval; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3332 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3333 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3334 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3335 * 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
|
3336 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3337 * 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
|
3338 * index: Item index. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3339 * 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
|
3340 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3341 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
|
3342 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3343 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
|
3344 DW_MUTEX_LOCK; |
656
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3345 id object = handle; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3346 |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3347 if([object isMemberOfClass:[DWComboBox class]]) |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3348 { |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3349 DWComboBox *combo = handle; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3350 if(state) |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3351 [combo selectItemAtIndex:index]; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3352 else |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3353 [combo deselectItemAtIndex:index]; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3354 } |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3355 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
|
3356 { |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3357 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
|
3358 NSIndexSet *selected = [[NSIndexSet alloc] initWithIndex:(NSUInteger)index]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
3359 |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3360 [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
|
3361 [selected release]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
3362 } |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3363 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3364 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3365 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3366 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3367 * 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
|
3368 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3369 * 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
|
3370 * index: Item index. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3371 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3372 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
|
3373 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3374 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
|
3375 DW_MUTEX_LOCK; |
656
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3376 id object = handle; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3377 |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3378 if([object isMemberOfClass:[DWComboBox class]]) |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3379 { |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3380 DWComboBox *combo = handle; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3381 |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3382 [combo removeItemAtIndex:index]; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3383 } |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3384 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
|
3385 { |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3386 DWContainer *cont = handle; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
3387 |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3388 [cont removeRow:index]; |
670
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
3389 [cont reloadData]; |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3390 } |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3391 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3392 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3393 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3394 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3395 * 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
|
3396 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3397 * 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
|
3398 * 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
|
3399 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
3400 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
|
3401 { |
656
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3402 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
|
3403 [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
|
3404 [combo setTag:cid]; |
656
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3405 return combo; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3406 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3407 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3408 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3409 * 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
|
3410 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3411 * 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
|
3412 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
3413 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
|
3414 { |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
3415 DWMLE *mle = [[DWMLE alloc] init]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
3416 NSScrollView *scrollview = [[NSScrollView alloc] init]; |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
3417 |
676
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
3418 [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
|
3419 [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
|
3420 [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
|
3421 [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
|
3422 [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
|
3423 [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
|
3424 /* [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
|
3425 [mle release]; |
676
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
3426 return scrollview; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3427 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3428 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3429 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3430 * 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
|
3431 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3432 * 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
|
3433 * buffer: Text buffer to be imported. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3434 * startpoint: Point to start entering text. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3435 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3436 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
|
3437 { |
676
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
3438 NSScrollView *sv = handle; |
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
3439 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
|
3440 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
|
3441 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
|
3442 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
|
3443 [ms insertString:nstr atIndex:(startpoint+1)]; |
665
e6bec2290f3f
Fixing warnings with Xcode 4 and switched to manual releasing in the draw functions to stop leaking.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
664
diff
changeset
|
3444 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
|
3445 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3446 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3447 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3448 * Grabs text from an MLE box. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3449 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3450 * 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
|
3451 * buffer: Text buffer to be exported. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3452 * startpoint: Point to start grabbing text. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3453 * 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
|
3454 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3455 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
|
3456 { |
676
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
3457 NSScrollView *sv = handle; |
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
3458 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
|
3459 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
|
3460 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
|
3461 strncpy(buffer, [ms UTF8String], length); |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3462 } |
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 * Obtains information about an MLE box. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3466 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3467 * 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
|
3468 * 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
|
3469 * 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
|
3470 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3471 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
|
3472 { |
676
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
3473 NSScrollView *sv = handle; |
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
3474 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
|
3475 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
|
3476 NSMutableString *ms = [ts mutableString]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
3477 |
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
|
3478 *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
|
3479 *lines = 0; /* TODO: Line count */ |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3480 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3481 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3482 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3483 * Deletes text from an MLE box. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3484 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3485 * 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
|
3486 * startpoint: Point to start deleting text. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3487 * 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
|
3488 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3489 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
|
3490 { |
676
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
3491 NSScrollView *sv = handle; |
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
3492 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
|
3493 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
|
3494 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
|
3495 [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
|
3496 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3497 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3498 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3499 * 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
|
3500 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3501 * 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
|
3502 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3503 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
|
3504 { |
676
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
3505 NSScrollView *sv = handle; |
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
3506 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
|
3507 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
|
3508 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
|
3509 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
|
3510 [ms deleteCharactersInRange:NSMakeRange(0, length)]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3511 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3512 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3513 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3514 * 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
|
3515 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3516 * 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
|
3517 * line: Line to be visible. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3518 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3519 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
|
3520 { |
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
|
3521 /*NSScrollView *sv = handle; |
01107d8e033e
Fixed the scrollbar maximum range to be correct. Also added some MLE code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
711
diff
changeset
|
3522 DWMLE *mle = [sv documentView]; |
01107d8e033e
Fixed the scrollbar maximum range to be correct. Also added some MLE code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
711
diff
changeset
|
3523 [mle scrollrangeToVisible:NSMakeRange(0,13)];*/ |
675
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
3524 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
|
3525 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3526 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3527 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3528 * 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
|
3529 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3530 * handle: Handle to the MLE. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3531 * 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
|
3532 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3533 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
|
3534 { |
676
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
3535 NSScrollView *sv = handle; |
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
3536 DWMLE *mle = [sv documentView]; |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
3537 if(state) |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
3538 { |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
3539 [mle setEditable:YES]; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
3540 } |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
3541 else |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
3542 { |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
3543 [mle setEditable:NO]; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
3544 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3545 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3546 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3547 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3548 * 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
|
3549 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3550 * handle: Handle to the MLE. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3551 * 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
|
3552 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3553 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
|
3554 { |
676
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
3555 NSScrollView *sv = handle; |
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
3556 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
|
3557 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
|
3558 { |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
3559 [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
|
3560 } |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
3561 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
|
3562 { |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
3563 [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
|
3564 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3565 } |
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 * 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
|
3569 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3570 * 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
|
3571 * point: Point to position cursor. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3572 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3573 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
|
3574 { |
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
|
3575 NSScrollView *sv = handle; |
01107d8e033e
Fixed the scrollbar maximum range to be correct. Also added some MLE code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
711
diff
changeset
|
3576 DWMLE *mle = [sv documentView]; |
01107d8e033e
Fixed the scrollbar maximum range to be correct. Also added some MLE code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
711
diff
changeset
|
3577 [mle setSelectedRange: NSMakeRange(point,point)]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3578 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3579 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3580 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3581 * Finds text in an MLE box. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3582 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3583 * 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
|
3584 * text: Text to search for. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3585 * point: Start point of search. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3586 * flags: Search specific flags. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3587 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3588 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
|
3589 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3590 NSLog(@"dw_mle_search() unimplemented\n"); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3591 return 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3592 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3593 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3594 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3595 * Stops redrawing of an MLE box. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3596 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3597 * 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
|
3598 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3599 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
|
3600 { |
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
|
3601 /* 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
|
3602 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3603 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3604 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3605 * Resumes redrawing of an MLE box. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3606 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3607 * 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
|
3608 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3609 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
|
3610 { |
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
|
3611 /* 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
|
3612 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3613 |
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 * 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
|
3616 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3617 * 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
|
3618 * 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
|
3619 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
3620 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
|
3621 { |
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
3622 NSTextField *textfield = dw_text_new(text, cid); |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
3623 [textfield setBordered:YES]; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
3624 [textfield setBezeled:YES]; |
673
6d0f0dc7ff7c
Some minor font fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
672
diff
changeset
|
3625 [textfield setBezelStyle:NSTextFieldSquareBezel]; |
6d0f0dc7ff7c
Some minor font fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
672
diff
changeset
|
3626 [textfield setBackgroundColor:[NSColor colorWithDeviceRed:1 green:1 blue:1 alpha: 0]]; |
6d0f0dc7ff7c
Some minor font fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
672
diff
changeset
|
3627 [textfield setDrawsBackground:NO]; |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
3628 return textfield; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3629 } |
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 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3632 * 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
|
3633 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3634 * 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
|
3635 * 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
|
3636 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
3637 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
|
3638 { |
744
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
3639 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
|
3640 [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
|
3641 [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
|
3642 [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
|
3643 [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
|
3644 [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
|
3645 [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
|
3646 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
|
3647 { |
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
3648 [[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
|
3649 } |
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
3650 return textfield; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3651 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3652 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3653 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3654 * 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
|
3655 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3656 * 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
|
3657 * Returns: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3658 * 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
|
3659 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
3660 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
|
3661 { |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
3662 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
|
3663 /* [render setTag:cid]; Why doesn't this work? */ |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
3664 return render; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3665 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3666 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3667 /* Sets the current foreground drawing color. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3668 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3669 * red: red value. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3670 * green: green value. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3671 * blue: blue value. |
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 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
|
3674 { |
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
|
3675 /* This may need to be thread specific */ |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3676 _foreground = _get_color(value); |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3677 } |
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 /* Sets the current background drawing color. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3680 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3681 * red: red value. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3682 * green: green value. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3683 * blue: blue value. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3684 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3685 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
|
3686 { |
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
|
3687 /* This may need to be thread specific */ |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3688 _background = _get_color(value); |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3689 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3690 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3691 /* 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
|
3692 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3693 * value: current color |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3694 * Returns: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3695 * 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
|
3696 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3697 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
|
3698 { |
733
8d5e5b89725f
Fixed the crashing issue with dw_color_choose() it now functions properly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
732
diff
changeset
|
3699 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
|
3700 /* 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
|
3701 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
|
3702 DWDialog *dialog; |
db3a173e487e
Fixes for the color chooser... it now works a single time. However...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
731
diff
changeset
|
3703 |
733
8d5e5b89725f
Fixed the crashing issue with dw_color_choose() it now functions properly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
732
diff
changeset
|
3704 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
|
3705 { |
db3a173e487e
Fixes for the color chooser... it now works a single time. However...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
731
diff
changeset
|
3706 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
|
3707 /* 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
|
3708 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
|
3709 { |
8d5e5b89725f
Fixed the crashing issue with dw_color_choose() it now functions properly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
732
diff
changeset
|
3710 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
|
3711 } |
732
db3a173e487e
Fixes for the color chooser... it now works a single time. However...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
731
diff
changeset
|
3712 } |
db3a173e487e
Fixes for the color chooser... it now works a single time. However...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
731
diff
changeset
|
3713 else |
db3a173e487e
Fixes for the color chooser... it now works a single time. However...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
731
diff
changeset
|
3714 { |
733
8d5e5b89725f
Fixed the crashing issue with dw_color_choose() it now functions properly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
732
diff
changeset
|
3715 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
|
3716 /* Set defaults for the dialog. */ |
db3a173e487e
Fixes for the color chooser... it now works a single time. However...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
731
diff
changeset
|
3717 [colorDlg setContinuous:NO]; |
db3a173e487e
Fixes for the color chooser... it now works a single time. However...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
731
diff
changeset
|
3718 [colorDlg setTarget:colorDlg]; |
db3a173e487e
Fixes for the color chooser... it now works a single time. However...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
731
diff
changeset
|
3719 [colorDlg setAction:@selector(changeColor:)]; |
db3a173e487e
Fixes for the color chooser... it now works a single time. However...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
731
diff
changeset
|
3720 } |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
3721 |
733
8d5e5b89725f
Fixed the crashing issue with dw_color_choose() it now functions properly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
732
diff
changeset
|
3722 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
|
3723 [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
|
3724 [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
|
3725 [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
|
3726 |
732
db3a173e487e
Fixes for the color chooser... it now works a single time. However...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
731
diff
changeset
|
3727 /* 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
|
3728 color = (NSColor *)dw_dialog_wait(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
|
3729 |
db3a173e487e
Fixes for the color chooser... it now works a single time. However...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
731
diff
changeset
|
3730 /* 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
|
3731 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
|
3732 [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
|
3733 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
|
3734 return value; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3735 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3736 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3737 /* 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
|
3738 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3739 * handle: Handle to the window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3740 * 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
|
3741 * x: X coordinate. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3742 * y: Y coordinate. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3743 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3744 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
|
3745 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3746 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
|
3747 DW_MUTEX_LOCK; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3748 id image = handle; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3749 if(pixmap) |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3750 { |
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
|
3751 image = (id)pixmap->image; |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
3752 [image lockFocus]; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3753 } |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
3754 else |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
3755 { |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
3756 [image lockFocusIfCanDraw]; |
661
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
3757 _DWLastDrawable = handle; |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
3758 } |
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
|
3759 NSBezierPath* aPath = [NSBezierPath bezierPath]; |
ba3af8eb56f1
Fixed drawing of rects and points. Fonts now properly draw in color. Updated property list.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
662
diff
changeset
|
3760 [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
|
3761 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
|
3762 [color set]; |
664
ba3af8eb56f1
Fixed drawing of rects and points. Fonts now properly draw in color. Updated property list.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
662
diff
changeset
|
3763 |
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
|
3764 [aPath moveToPoint:NSMakePoint(x, y)]; |
ba3af8eb56f1
Fixed drawing of rects and points. Fonts now properly draw in color. Updated property list.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
662
diff
changeset
|
3765 [aPath stroke]; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3766 [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
|
3767 DW_MUTEX_UNLOCK; |
650
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 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3770 /* 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
|
3771 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3772 * handle: Handle to the window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3773 * 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
|
3774 * x1: First X coordinate. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3775 * y1: First Y coordinate. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3776 * x2: Second X coordinate. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3777 * y2: Second Y coordinate. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3778 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3779 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
|
3780 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3781 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
|
3782 DW_MUTEX_LOCK; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3783 id image = handle; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3784 if(pixmap) |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3785 { |
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
|
3786 image = (id)pixmap->image; |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
3787 [image lockFocus]; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3788 } |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
3789 else |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
3790 { |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
3791 [image lockFocusIfCanDraw]; |
661
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
3792 _DWLastDrawable = handle; |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
3793 } |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3794 NSBezierPath* aPath = [NSBezierPath bezierPath]; |
661
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
3795 [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
|
3796 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
|
3797 [color set]; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3798 |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3799 [aPath moveToPoint:NSMakePoint(x1, y1)]; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3800 [aPath lineToPoint:NSMakePoint(x2, y2)]; |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
3801 [aPath stroke]; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3802 |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3803 [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
|
3804 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3805 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3806 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3807 /* 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
|
3808 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3809 * handle: Handle to the window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3810 * 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
|
3811 * x: X coordinate. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3812 * y: Y coordinate. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3813 * text: Text to be displayed. |
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 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
|
3816 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3817 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
|
3818 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
|
3819 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
|
3820 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
|
3821 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
|
3822 { |
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
|
3823 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
|
3824 { |
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
|
3825 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
|
3826 NSFont *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
|
3827 [image lockFocusIfCanDraw]; |
665
e6bec2290f3f
Fixing warnings with Xcode 4 and switched to manual releasing in the draw functions to stop leaking.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
664
diff
changeset
|
3828 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
|
3829 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
|
3830 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
|
3831 { |
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
|
3832 [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
|
3833 } |
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
|
3834 [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
|
3835 [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
|
3836 } |
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
|
3837 _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
|
3838 } |
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
|
3839 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
|
3840 { |
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
|
3841 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
|
3842 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
|
3843 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
|
3844 { |
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
|
3845 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
|
3846 } |
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
|
3847 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
|
3848 [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
|
3849 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
|
3850 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
|
3851 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
|
3852 { |
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
|
3853 [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
|
3854 } |
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
|
3855 [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
|
3856 [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
|
3857 } |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3858 DW_MUTEX_UNLOCK; |
650
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 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3861 /* 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
|
3862 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3863 * handle: Handle to the window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3864 * 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
|
3865 * text: Text to be queried. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3866 * 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
|
3867 * 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
|
3868 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3869 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
|
3870 { |
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
|
3871 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
|
3872 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
|
3873 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
|
3874 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
|
3875 { |
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
|
3876 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
|
3877 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
|
3878 } |
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
|
3879 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
|
3880 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
|
3881 { |
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
|
3882 NSFont *font = [object 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
|
3883 |
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
|
3884 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
|
3885 { |
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
|
3886 [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
|
3887 } |
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
|
3888 } |
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
|
3889 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
|
3890 [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
|
3891 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
|
3892 { |
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
|
3893 *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
|
3894 } |
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
|
3895 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
|
3896 { |
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
|
3897 *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
|
3898 } |
650
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 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3901 /* 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
|
3902 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3903 * handle: Handle to the window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3904 * 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
|
3905 * fill: Fill box TRUE or FALSE. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3906 * x: X coordinate. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3907 * y: Y coordinate. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3908 * width: Width of rectangle. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3909 * height: Height of rectangle. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3910 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3911 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
|
3912 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3913 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
|
3914 DW_MUTEX_LOCK; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3915 id image = handle; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3916 int z; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3917 if(pixmap) |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3918 { |
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
|
3919 image = (id)pixmap->image; |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
3920 [image lockFocus]; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3921 } |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
3922 else |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
3923 { |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
3924 [image lockFocusIfCanDraw]; |
661
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
3925 _DWLastDrawable = handle; |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
3926 } |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3927 NSBezierPath* aPath = [NSBezierPath bezierPath]; |
661
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
3928 [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
|
3929 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
|
3930 [color set]; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3931 |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3932 [aPath moveToPoint:NSMakePoint(*x, *y)]; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3933 for(z=1;z<npoints;z++) |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3934 { |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3935 [aPath lineToPoint:NSMakePoint(x[z], y[z])]; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3936 } |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3937 [aPath closePath]; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3938 if(fill) |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3939 { |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3940 [aPath fill]; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3941 } |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
3942 [aPath stroke]; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3943 [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
|
3944 DW_MUTEX_UNLOCK; |
650
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 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3947 /* 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
|
3948 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3949 * handle: Handle to the window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3950 * 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
|
3951 * fill: Fill box TRUE or FALSE. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3952 * x: X coordinate. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3953 * y: Y coordinate. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3954 * width: Width of rectangle. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3955 * height: Height of rectangle. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3956 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3957 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
|
3958 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3959 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
|
3960 DW_MUTEX_LOCK; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3961 id image = handle; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3962 if(pixmap) |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3963 { |
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
|
3964 image = (id)pixmap->image; |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
3965 [image lockFocus]; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3966 } |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
3967 else |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
3968 { |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
3969 [image lockFocusIfCanDraw]; |
661
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
3970 _DWLastDrawable = handle; |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
3971 } |
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
|
3972 NSBezierPath* aPath = [NSBezierPath bezierPath]; |
ba3af8eb56f1
Fixed drawing of rects and points. Fonts now properly draw in color. Updated property list.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
662
diff
changeset
|
3973 [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
|
3974 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
|
3975 [color set]; |
664
ba3af8eb56f1
Fixed drawing of rects and points. Fonts now properly draw in color. Updated property list.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
662
diff
changeset
|
3976 |
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
|
3977 [aPath moveToPoint:NSMakePoint(x, y)]; |
ba3af8eb56f1
Fixed drawing of rects and points. Fonts now properly draw in color. Updated property list.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
662
diff
changeset
|
3978 [aPath lineToPoint:NSMakePoint(x, y + height)]; |
ba3af8eb56f1
Fixed drawing of rects and points. Fonts now properly draw in color. Updated property list.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
662
diff
changeset
|
3979 [aPath lineToPoint:NSMakePoint(x + width, y + height)]; |
ba3af8eb56f1
Fixed drawing of rects and points. Fonts now properly draw in color. Updated property list.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
662
diff
changeset
|
3980 [aPath lineToPoint:NSMakePoint(x + width, y)]; |
ba3af8eb56f1
Fixed drawing of rects and points. Fonts now properly draw in color. Updated property list.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
662
diff
changeset
|
3981 [aPath closePath]; |
ba3af8eb56f1
Fixed drawing of rects and points. Fonts now properly draw in color. Updated property list.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
662
diff
changeset
|
3982 [aPath fill]; |
ba3af8eb56f1
Fixed drawing of rects and points. Fonts now properly draw in color. Updated property list.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
662
diff
changeset
|
3983 [aPath stroke]; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3984 [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
|
3985 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3986 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3987 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3988 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3989 * 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
|
3990 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3991 * 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
|
3992 * resource file. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3993 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
3994 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
|
3995 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3996 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
|
3997 DW_MUTEX_LOCK; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
3998 NSScrollView *scrollview = [[NSScrollView alloc] init]; |
680
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
3999 DWTree *tree = [[DWTree alloc] init]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
4000 |
680
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
4001 [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
|
4002 [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
|
4003 [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
|
4004 [scrollview setAutohidesScrollers:YES]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
4005 |
680
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
4006 [tree setAllowsMultipleSelection:NO]; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
4007 [tree setDataSource:tree]; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
4008 [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
|
4009 [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
|
4010 [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
|
4011 [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
|
4012 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
|
4013 return tree; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4014 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4015 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4016 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4017 * 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
|
4018 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4019 * 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
|
4020 * 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
|
4021 * 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
|
4022 * icon: Handle to coresponding icon. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4023 * 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
|
4024 * itemdata: Item specific data. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4025 */ |
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
|
4026 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
|
4027 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4028 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
|
4029 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
|
4030 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
|
4031 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
|
4032 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
|
4033 [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
|
4034 [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
|
4035 [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
|
4036 [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
|
4037 [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
|
4038 [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
|
4039 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
|
4040 return treenode; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4041 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4042 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4043 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4044 * 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
|
4045 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4046 * 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
|
4047 * 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
|
4048 * icon: Handle to coresponding icon. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4049 * 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
|
4050 * itemdata: Item specific data. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4051 */ |
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
|
4052 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
|
4053 { |
680
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
4054 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
|
4055 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4056 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4057 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4058 * 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
|
4059 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4060 * 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
|
4061 * 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
|
4062 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4063 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
|
4064 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4065 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
|
4066 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
|
4067 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
|
4068 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
|
4069 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
|
4070 return strdup([nstr UTF8String]); |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4071 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4072 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4073 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4074 * 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
|
4075 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4076 * 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
|
4077 * 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
|
4078 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4079 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
|
4080 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4081 NSLog(@"dw_tree_get_parent() unimplemented\n"); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4082 return HWND_DESKTOP; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4083 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4084 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4085 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4086 * 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
|
4087 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4088 * handle: Handle to the tree containing the item. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4089 * 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
|
4090 * 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
|
4091 * icon: Handle to coresponding icon. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4092 */ |
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
|
4093 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
|
4094 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4095 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
|
4096 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
|
4097 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
|
4098 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
|
4099 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
|
4100 { |
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
|
4101 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
|
4102 [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
|
4103 } |
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
|
4104 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
|
4105 { |
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
|
4106 [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
|
4107 } |
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
|
4108 [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
|
4109 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4110 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4111 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4112 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4113 * 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
|
4114 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4115 * 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
|
4116 * 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
|
4117 * 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
|
4118 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4119 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
|
4120 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4121 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
|
4122 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
|
4123 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
|
4124 [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
|
4125 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4126 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4127 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4128 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4129 * 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
|
4130 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4131 * 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
|
4132 * 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
|
4133 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4134 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
|
4135 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4136 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
|
4137 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
|
4138 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
|
4139 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
|
4140 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
|
4141 return result; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4142 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4143 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4144 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4145 * 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
|
4146 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4147 * 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
|
4148 * 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
|
4149 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4150 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
|
4151 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4152 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
|
4153 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
|
4154 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
|
4155 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
|
4156 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
|
4157 { |
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
|
4158 [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
|
4159 } |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4160 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4161 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4162 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4163 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4164 * Removes all nodes from a tree. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4165 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4166 * 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
|
4167 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4168 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
|
4169 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4170 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
|
4171 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
|
4172 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
|
4173 [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
|
4174 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4175 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4176 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4177 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4178 * Expands a node on a tree. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4179 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4180 * 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
|
4181 * 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
|
4182 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4183 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
|
4184 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4185 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
|
4186 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
|
4187 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
|
4188 [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
|
4189 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4190 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4191 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4192 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4193 * Collapses a node on a tree. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4194 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4195 * 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
|
4196 * 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
|
4197 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4198 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
|
4199 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4200 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
|
4201 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
|
4202 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
|
4203 [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
|
4204 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4205 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4206 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4207 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4208 * Removes a node from a tree. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4209 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4210 * 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
|
4211 * 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
|
4212 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4213 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
|
4214 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4215 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
|
4216 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
|
4217 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
|
4218 [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
|
4219 [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
|
4220 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4221 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4222 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4223 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4224 * 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
|
4225 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4226 * 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
|
4227 * resource file. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4228 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
4229 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
|
4230 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4231 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
|
4232 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
|
4233 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
|
4234 NSScrollView *scrollview = [cont scrollview]; |
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
4235 [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
|
4236 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
|
4237 [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
|
4238 [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
|
4239 [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
|
4240 [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
|
4241 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
|
4242 return cont; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4243 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4244 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4245 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4246 * Sets up the container columns. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4247 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4248 * 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
|
4249 * 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
|
4250 * 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
|
4251 * 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
|
4252 * 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
|
4253 * (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
|
4254 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4255 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
|
4256 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4257 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
|
4258 DW_MUTEX_LOCK; |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
4259 int z; |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
4260 DWContainer *cont = handle; |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
4261 |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4262 [cont setup]; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4263 |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
4264 for(z=0;z<count;z++) |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
4265 { |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
4266 NSTableColumn *column = [[NSTableColumn alloc] init]; |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
4267 [[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
|
4268 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
|
4269 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4270 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
|
4271 [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
|
4272 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
|
4273 { |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4274 [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
|
4275 [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
|
4276 } |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4277 [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
|
4278 } |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
4279 [cont addTableColumn:column]; |
665
e6bec2290f3f
Fixing warnings with Xcode 4 and switched to manual releasing in the draw functions to stop leaking.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
664
diff
changeset
|
4280 [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
|
4281 [column release]; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4282 } |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4283 DW_MUTEX_UNLOCK; |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
4284 return TRUE; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4285 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4286 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4287 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4288 * 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
|
4289 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4290 * 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
|
4291 * 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
|
4292 * 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
|
4293 * 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
|
4294 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4295 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
|
4296 { |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4297 char **newtitles = malloc(sizeof(char *) * (count + 2)); |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4298 unsigned long *newflags = malloc(sizeof(unsigned long) * (count + 2)); |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
4299 |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4300 newtitles[0] = "Icon"; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4301 newtitles[1] = "Filename"; |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
4302 |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4303 newflags[0] = DW_CFA_BITMAPORICON | DW_CFA_LEFT | DW_CFA_HORZSEPARATOR; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4304 newflags[1] = DW_CFA_STRING | DW_CFA_LEFT | DW_CFA_HORZSEPARATOR; |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
4305 |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4306 memcpy(&newtitles[2], titles, sizeof(char *) * count); |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4307 memcpy(&newflags[2], flags, sizeof(unsigned long) * count); |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
4308 |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4309 dw_container_setup(handle, newflags, newtitles, count + 2, 0); |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
4310 |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
4311 free(newtitles); |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
4312 free(newflags); |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
4313 return TRUE; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4314 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4315 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4316 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4317 * 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
|
4318 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4319 * handle: Handle to the container window (widget). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4320 * 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
|
4321 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4322 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
|
4323 { |
691
578bbfd8c904
Added 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 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
|
4325 DW_MUTEX_LOCK; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4326 DWContainer *cont = handle; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4327 [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
|
4328 DW_MUTEX_UNLOCK; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4329 return cont; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4330 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4331 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4332 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4333 * 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
|
4334 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4335 * 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
|
4336 * 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
|
4337 * 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
|
4338 * 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
|
4339 * 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
|
4340 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4341 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
|
4342 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4343 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
|
4344 DW_MUTEX_LOCK; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4345 DWContainer *cont = handle; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4346 id object = nil; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4347 int type = [cont cellType:column]; |
658
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
4348 int lastadd = [cont lastAddPoint]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
4349 |
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
|
4350 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
|
4351 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4352 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
|
4353 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
|
4354 } |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4355 if(type & DW_CFA_BITMAPORICON) |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4356 { |
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
|
4357 object = *((NSImage **)data); |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4358 } |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4359 else if(type & DW_CFA_STRING) |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4360 { |
726
ecf47778caff
Possible fix for container string columns not showing correctly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
725
diff
changeset
|
4361 char *str = *((char **)data); |
ecf47778caff
Possible fix for container string columns not showing correctly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
725
diff
changeset
|
4362 object = [ NSString stringWithUTF8String:str ]; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4363 } |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
4364 else |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4365 { |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4366 char textbuffer[100]; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4367 |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4368 if(type & DW_CFA_ULONG) |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4369 { |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4370 ULONG tmp = *((ULONG *)data); |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4371 |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4372 sprintf(textbuffer, "%lu", tmp); |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4373 } |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4374 else if(type & DW_CFA_DATE) |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4375 { |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4376 struct tm curtm; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4377 CDATE cdate = *((CDATE *)data); |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4378 |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4379 memset( &curtm, 0, sizeof(curtm) ); |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4380 curtm.tm_mday = cdate.day; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4381 curtm.tm_mon = cdate.month - 1; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4382 curtm.tm_year = cdate.year - 1900; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4383 |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4384 strftime(textbuffer, 100, "%x", &curtm); |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4385 } |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4386 else if(type & DW_CFA_TIME) |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4387 { |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4388 struct tm curtm; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4389 CTIME ctime = *((CTIME *)data); |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4390 |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4391 memset( &curtm, 0, sizeof(curtm) ); |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4392 curtm.tm_hour = ctime.hours; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4393 curtm.tm_min = ctime.minutes; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4394 curtm.tm_sec = ctime.seconds; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4395 |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4396 strftime(textbuffer, 100, "%X", &curtm); |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4397 } |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
4398 else |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4399 { |
691
578bbfd8c904
Added 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_UNLOCK; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4401 return; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4402 } |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4403 object = [ NSString stringWithUTF8String:textbuffer ]; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4404 } |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4405 |
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
|
4406 [cont editCell:object at:(row+lastadd) and:column]; |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4407 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4408 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4409 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4410 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4411 * 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
|
4412 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4413 * 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
|
4414 * 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
|
4415 * 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
|
4416 * 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
|
4417 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4418 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
|
4419 { |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4420 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
|
4421 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4422 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4423 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4424 * 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
|
4425 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4426 * 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
|
4427 * 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
|
4428 * 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
|
4429 * 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
|
4430 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4431 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
|
4432 { |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4433 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
|
4434 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4435 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4436 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4437 * 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
|
4438 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4439 * 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
|
4440 * 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
|
4441 * 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
|
4442 * 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
|
4443 * 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
|
4444 */ |
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
|
4445 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
|
4446 { |
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
|
4447 dw_container_change_item(handle, 0, row, &icon); |
726
ecf47778caff
Possible fix for container string columns not showing correctly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
725
diff
changeset
|
4448 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
|
4449 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4450 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4451 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4452 * 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
|
4453 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4454 * 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
|
4455 * 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
|
4456 * 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
|
4457 * 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
|
4458 * 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
|
4459 */ |
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
|
4460 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
|
4461 { |
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 dw_container_set_item(handle, pointer, 0, row, &icon); |
726
ecf47778caff
Possible fix for container string columns not showing correctly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
725
diff
changeset
|
4463 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
|
4464 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4465 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4466 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4467 * 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
|
4468 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4469 * 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
|
4470 * 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
|
4471 * 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
|
4472 * 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
|
4473 * 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
|
4474 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4475 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
|
4476 { |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4477 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
|
4478 } |
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 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4481 * 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
|
4482 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4483 * 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
|
4484 * column: Zero based column. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4485 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4486 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
|
4487 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4488 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
|
4489 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
|
4490 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
|
4491 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
|
4492 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
|
4493 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
|
4494 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
|
4495 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
|
4496 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
|
4497 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
|
4498 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
|
4499 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
|
4500 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
|
4501 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
|
4502 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
|
4503 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
|
4504 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
|
4505 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
|
4506 return rc; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4507 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4508 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4509 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4510 * 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
|
4511 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4512 * 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
|
4513 * column: Zero based column. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4514 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4515 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
|
4516 { |
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
|
4517 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
|
4518 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4519 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4520 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4521 * 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
|
4522 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4523 * 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
|
4524 * 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
|
4525 * width: Width of column in pixels. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4526 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4527 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
|
4528 { |
691
578bbfd8c904
Added 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 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
|
4530 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
|
4531 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
|
4532 NSTableColumn *col = [cont getColumn:column]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
4533 |
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
|
4534 [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
|
4535 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4536 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4537 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4538 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4539 * 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
|
4540 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4541 * 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
|
4542 * 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
|
4543 * title: String title of the item. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4544 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4545 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
|
4546 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4547 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
|
4548 DW_MUTEX_LOCK; |
659
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
4549 DWContainer *cont = pointer; |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4550 [cont setRow:row title:title]; |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4551 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4552 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4553 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4554 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4555 * 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
|
4556 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4557 * 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
|
4558 * 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
|
4559 * 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
|
4560 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4561 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
|
4562 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4563 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
|
4564 DW_MUTEX_LOCK; |
658
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
4565 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
|
4566 [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
|
4567 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4568 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4569 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4570 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4571 * Removes all rows from a container. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4572 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4573 * 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
|
4574 * 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
|
4575 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4576 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
|
4577 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4578 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
|
4579 DW_MUTEX_LOCK; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4580 DWContainer *cont = handle; |
670
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
4581 [cont clear]; |
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
4582 if(redraw) |
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
4583 { |
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
4584 [cont reloadData]; |
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
4585 } |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4586 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4587 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4588 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4589 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4590 * 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
|
4591 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4592 * 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
|
4593 * 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
|
4594 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4595 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
|
4596 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4597 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
|
4598 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
|
4599 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
|
4600 int x; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
4601 |
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
|
4602 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
|
4603 { |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4604 [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
|
4605 } |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4606 DW_MUTEX_UNLOCK; |
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 * Scrolls container up or down. |
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 window (widget) to be scrolled. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4613 * 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
|
4614 * 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
|
4615 * 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
|
4616 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4617 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
|
4618 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4619 NSLog(@"dw_container_scroll() unimplemented\n"); |
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 * 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
|
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 window (widget) to be queried. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4626 * 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
|
4627 * 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
|
4628 * 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
|
4629 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4630 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
|
4631 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4632 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
|
4633 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
|
4634 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
|
4635 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
|
4636 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
|
4637 char *retval = NULL; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
4638 |
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
|
4639 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
|
4640 { |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4641 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
|
4642 [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
|
4643 } |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4644 DW_MUTEX_UNLOCK; |
675
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4645 return retval; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4646 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4647 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4648 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4649 * 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
|
4650 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4651 * 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
|
4652 * 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
|
4653 * 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
|
4654 * 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
|
4655 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4656 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
|
4657 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4658 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
|
4659 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
|
4660 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
|
4661 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
|
4662 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
|
4663 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
|
4664 char *retval = NULL; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
4665 |
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
|
4666 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
|
4667 { |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4668 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
|
4669 [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
|
4670 } |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4671 DW_MUTEX_UNLOCK; |
675
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4672 return retval; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4673 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4674 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4675 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4676 * 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
|
4677 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4678 * 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
|
4679 * 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
|
4680 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4681 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
|
4682 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4683 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
|
4684 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
|
4685 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
|
4686 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
|
4687 int x, count = (int)[cont numberOfRowsInTableView:cont]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
4688 |
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
|
4689 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
|
4690 { |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4691 thistext = [cont getRowTitle:x]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
4692 |
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
|
4693 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
|
4694 { |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4695 NSIndexSet *selected = [[NSIndexSet alloc] initWithIndex:(NSUInteger)x]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
4696 |
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
|
4697 [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
|
4698 [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
|
4699 } |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4700 } |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4701 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4702 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4703 |
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 * 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
|
4706 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4707 * handle: Handle to the window (widget). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4708 * 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
|
4709 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4710 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
|
4711 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4712 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
|
4713 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
|
4714 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
|
4715 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
|
4716 int x, count = (int)[cont numberOfRowsInTableView:cont]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
4717 |
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
|
4718 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
|
4719 { |
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 thistext = [cont getRowTitle:x]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
4721 |
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
|
4722 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
|
4723 { |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4724 [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
|
4725 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
|
4726 } |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4727 } |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4728 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4729 } |
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 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4732 * 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
|
4733 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4734 * 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
|
4735 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4736 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
|
4737 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4738 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
|
4739 DW_MUTEX_LOCK; |
658
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
4740 DWContainer *cont = handle; |
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
4741 /*[cont sizeToFit];*/ |
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
4742 [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
|
4743 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4744 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4745 |
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 * Inserts an icon into the taskbar. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4748 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4749 * 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
|
4750 * 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
|
4751 * 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
|
4752 */ |
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
|
4753 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
|
4754 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4755 NSLog(@"dw_taskbar_insert() unimplemented\n"); |
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 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4758 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4759 * Deletes an icon from the taskbar. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4760 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4761 * 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
|
4762 * 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
|
4763 */ |
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
|
4764 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
|
4765 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4766 NSLog(@"dw_taskbar_delete() unimplemented\n"); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4767 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4768 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4769 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4770 * 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
|
4771 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4772 * 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
|
4773 * 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
|
4774 * 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
|
4775 * to an embedded XPM. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4776 */ |
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
|
4777 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
|
4778 { |
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
|
4779 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
|
4780 NSString *respath = [bundle resourcePath]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
4781 NSString *filepath = [respath stringByAppendingFormat:@"/%u.png", resid]; |
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
|
4782 NSImage *image = [[NSImage alloc] initWithContentsOfFile:filepath]; |
c60a4f6cfae8
Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
670
diff
changeset
|
4783 return image; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4784 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4785 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4786 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4787 * Obtains an icon from a file. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4788 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4789 * 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
|
4790 * DW pick the appropriate file extension. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4791 * (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
|
4792 */ |
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
|
4793 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
|
4794 { |
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
|
4795 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
|
4796 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
|
4797 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
|
4798 { |
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
|
4799 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
|
4800 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
|
4801 } |
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
|
4802 return image; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4803 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4804 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4805 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4806 * Obtains an icon from data |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4807 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4808 * 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
|
4809 * DW pick the appropriate file extension. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4810 * (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
|
4811 */ |
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
|
4812 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
|
4813 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4814 NSData *thisdata = [[NSData alloc] dataWithBytes:data length:len]; |
671
c60a4f6cfae8
Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
670
diff
changeset
|
4815 NSImage *image = [[NSImage alloc] initWithData:thisdata]; |
c60a4f6cfae8
Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
670
diff
changeset
|
4816 return image; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4817 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4818 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4819 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4820 * 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
|
4821 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4822 * 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
|
4823 */ |
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
|
4824 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
|
4825 { |
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
|
4826 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
|
4827 [image release]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4828 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4829 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4830 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4831 * 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
|
4832 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4833 * 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
|
4834 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
4835 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
|
4836 { |
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
|
4837 /* 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
|
4838 * 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
|
4839 * when the application is deactivated to simulate |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
4840 * 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
|
4841 */ |
014b02436c1f
Added MDI simulation code... the MDI "window" will just be a box for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
683
diff
changeset
|
4842 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
|
4843 /* [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
|
4844 return mdi; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4845 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4846 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4847 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4848 * 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
|
4849 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4850 * 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
|
4851 * 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
|
4852 * 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
|
4853 * Returns: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4854 * 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
|
4855 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
4856 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
|
4857 { |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
4858 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
|
4859 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
|
4860 DW_MUTEX_LOCK; |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
4861 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
|
4862 [split setDelegate:split]; |
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
4863 dw_box_pack_start(tmpbox, topleft, 0, 0, TRUE, TRUE, 0); |
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
4864 [split addSubview:tmpbox]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
4865 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
|
4866 dw_box_pack_start(tmpbox, bottomright, 0, 0, TRUE, TRUE, 0); |
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
4867 [split addSubview:tmpbox]; |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
4868 if(type == DW_VERT) |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
4869 { |
668
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
4870 [split setVertical:NO]; |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
4871 } |
668
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
4872 else |
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
4873 { |
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
4874 [split setVertical:YES]; |
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
4875 } |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
4876 /* [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
|
4877 DW_MUTEX_UNLOCK; |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
4878 return split; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4879 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4880 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4881 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4882 * 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
|
4883 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4884 * 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
|
4885 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4886 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
|
4887 { |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
4888 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
|
4889 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
|
4890 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
|
4891 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
|
4892 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
|
4893 /* 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
|
4894 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
|
4895 { |
677
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
4896 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
|
4897 } |
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
4898 else |
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
4899 { |
676
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
4900 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
|
4901 } |
677
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
4902 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
|
4903 { |
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
4904 [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
|
4905 } |
676
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
4906 else |
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
4907 { |
677
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
4908 /* 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
|
4909 * 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
|
4910 * 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
|
4911 */ |
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
4912 [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
|
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 * 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
|
4919 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4920 * 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
|
4921 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4922 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
|
4923 { |
676
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
4924 DWSplitBar *split = handle; |
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
4925 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
|
4926 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
|
4927 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
|
4928 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
|
4929 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
|
4930 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
|
4931 { |
677
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
4932 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
|
4933 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
|
4934 } |
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
4935 else |
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
4936 { |
677
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
4937 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
|
4938 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
|
4939 } |
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
4940 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
|
4941 { |
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
4942 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
|
4943 } |
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
4944 return retval; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4945 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4946 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4947 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4948 * 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
|
4949 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4950 * 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
|
4951 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
4952 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
|
4953 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4954 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
|
4955 DW_MUTEX_LOCK; |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
4956 NSImageView *bitmap = [[NSImageView alloc] init]; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
4957 [bitmap setImageFrameStyle:NSImageFrameNone]; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
4958 [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
|
4959 [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
|
4960 DW_MUTEX_UNLOCK; |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
4961 return bitmap; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4962 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4963 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4964 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4965 * Creates a pixmap with given parameters. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4966 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4967 * 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
|
4968 * 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
|
4969 * 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
|
4970 * depth: Color depth of the pixmap. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4971 * Returns: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4972 * 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
|
4973 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4974 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
|
4975 { |
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
|
4976 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
|
4977 HPIXMAP pixmap; |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
4978 |
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
|
4979 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
|
4980 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
|
4981 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
|
4982 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
|
4983 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
|
4984 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
|
4985 [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
|
4986 return pixmap; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4987 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4988 |
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 * Creates a pixmap from a file. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4991 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4992 * 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
|
4993 * 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
|
4994 * DW pick the appropriate file extension. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4995 * (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
|
4996 * Returns: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4997 * 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
|
4998 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4999 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
|
5000 { |
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
|
5001 HPIXMAP pixmap; |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
5002 |
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
|
5003 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
|
5004 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
|
5005 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
|
5006 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
|
5007 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
|
5008 { |
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
|
5009 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
|
5010 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
|
5011 } |
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
|
5012 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
|
5013 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
|
5014 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
|
5015 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
|
5016 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
|
5017 [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
|
5018 return pixmap; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5019 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5020 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5021 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5022 * Creates a pixmap from memory. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5023 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5024 * 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
|
5025 * data: Source of the image data |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5026 * (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
|
5027 * le: length of data |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5028 * Returns: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5029 * 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
|
5030 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5031 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
|
5032 { |
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
|
5033 HPIXMAP pixmap; |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
5034 |
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
|
5035 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
|
5036 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
|
5037 NSData *thisdata = [[NSData alloc] dataWithBytes:data length:len]; |
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
|
5038 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
|
5039 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
|
5040 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
|
5041 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
|
5042 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
|
5043 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
|
5044 [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
|
5045 return pixmap; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5046 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5047 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5048 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5049 * 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
|
5050 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5051 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
|
5052 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5053 NSLog(@"dw_pixmap_set_transparent_color() unimplemented\n"); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5054 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5055 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5056 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5057 * 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
|
5058 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5059 * 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
|
5060 * 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
|
5061 * Returns: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5062 * 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
|
5063 */ |
670
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
5064 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
|
5065 { |
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
|
5066 HPIXMAP pixmap; |
670
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
5067 |
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
|
5068 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
|
5069 return NULL; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
5070 |
670
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
5071 NSBundle *bundle = [NSBundle mainBundle]; |
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
5072 NSString *respath = [bundle resourcePath]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
5073 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
|
5074 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
|
5075 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
|
5076 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
|
5077 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
|
5078 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
|
5079 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
|
5080 [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
|
5081 return pixmap; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5082 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5083 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5084 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5085 * Destroys an allocated pixmap. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5086 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5087 * 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
|
5088 * dw_pixmap_new.. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5089 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5090 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
|
5091 { |
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
|
5092 NSImage *image = (NSImage *)pixmap->image; |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
5093 [image dealloc]; |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
5094 free(pixmap); |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5095 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5096 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5097 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5098 * Copies from one item to another. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5099 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5100 * dest: Destination window handle. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5101 * destp: Destination pixmap. (choose only one). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5102 * xdest: X coordinate of destination. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5103 * ydest: Y coordinate of destination. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5104 * width: Width of area to copy. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5105 * height: Height of area to copy. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5106 * src: Source window handle. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5107 * srcp: Source pixmap. (choose only one). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5108 * xsrc: X coordinate of source. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5109 * ysrc: Y coordinate of source. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5110 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5111 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
|
5112 { |
699
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
5113 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
|
5114 NSValue* bi = [NSValue valueWithPointer:bltinfo]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
5115 |
699
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
5116 /* 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
|
5117 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
|
5118 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
|
5119 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
|
5120 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
|
5121 bltinfo->width = width; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
5122 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
|
5123 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
|
5124 bltinfo->ysrc = ysrc; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
5125 |
699
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
5126 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
|
5127 { |
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
|
5128 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
|
5129 } |
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
5130 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
|
5131 { |
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
|
5132 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
|
5133 [object retain]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
5134 } |
699
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
5135 [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
|
5136 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5137 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5138 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5139 * Create a new 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
|
5140 * Not available under OS/2, eCS |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5141 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5142 * text: The 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
|
5143 * id: An ID to be used with dw_window_from_id() or 0L. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5144 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
5145 HWND API dw_calendar_new(ULONG cid) |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5146 { |
729
6712e4211522
Switched to graphical calendar control style... and fixed date querying code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
728
diff
changeset
|
5147 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
|
5148 [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
|
5149 [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
|
5150 [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
|
5151 [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
|
5152 return calendar; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5153 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5154 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5155 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5156 * 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
|
5157 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5158 * 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
|
5159 * year... |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5160 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5161 void 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
|
5162 { |
729
6712e4211522
Switched to graphical calendar control style... and fixed date querying code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
728
diff
changeset
|
5163 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
|
5164 NSDate *date; |
6712e4211522
Switched to graphical calendar control style... and fixed date querying code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
728
diff
changeset
|
5165 char buffer[100]; |
655
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
5166 |
729
6712e4211522
Switched to graphical calendar control style... and fixed date querying code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
728
diff
changeset
|
5167 sprintf(buffer, "%04d-%02d-%02d 00:00:00 +0600", year, month, day); |
655
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
5168 |
729
6712e4211522
Switched to graphical calendar control style... and fixed date querying code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
728
diff
changeset
|
5169 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
|
5170 [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
|
5171 [date release]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5172 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5173 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5174 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5175 * 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
|
5176 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5177 * 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
|
5178 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5179 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
|
5180 { |
729
6712e4211522
Switched to graphical calendar control style... and fixed date querying code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
728
diff
changeset
|
5181 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
|
5182 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
|
5183 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
|
5184 [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
|
5185 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
|
5186 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
|
5187 if(*year < 70) |
d3fb3613726a
Calendar control should return years with 4 digits not 2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
729
diff
changeset
|
5188 { |
d3fb3613726a
Calendar control should return years with 4 digits not 2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
729
diff
changeset
|
5189 *year += 2000; |
d3fb3613726a
Calendar control should return years with 4 digits not 2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
729
diff
changeset
|
5190 } |
d3fb3613726a
Calendar control should return years with 4 digits not 2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
729
diff
changeset
|
5191 else if(*year < 100) |
d3fb3613726a
Calendar control should return years with 4 digits not 2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
729
diff
changeset
|
5192 { |
d3fb3613726a
Calendar control should return years with 4 digits not 2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
729
diff
changeset
|
5193 *year += 1900; |
d3fb3613726a
Calendar control should return years with 4 digits not 2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
729
diff
changeset
|
5194 } |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
5195 [df release]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5196 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5197 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5198 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5199 * 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
|
5200 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5201 * handle: Handle to the window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5202 * 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
|
5203 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5204 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
|
5205 { |
655
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
5206 WebView *html = handle; |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
5207 switch(action) |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
5208 { |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
5209 case DW_HTML_GOBACK: |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
5210 [html goBack]; |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
5211 break; |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
5212 case DW_HTML_GOFORWARD: |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
5213 [html goForward]; |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
5214 break; |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
5215 case DW_HTML_GOHOME: |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
5216 break; |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
5217 case DW_HTML_SEARCH: |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
5218 break; |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
5219 case DW_HTML_RELOAD: |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
5220 [html reload:html]; |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
5221 break; |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
5222 case DW_HTML_STOP: |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
5223 [html stopLoading:html]; |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
5224 break; |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
5225 case DW_HTML_PRINT: |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
5226 break; |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
5227 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5228 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5229 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5230 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5231 * 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
|
5232 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5233 * handle: Handle to the window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5234 * 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
|
5235 * be rendered. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5236 * Returns: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5237 * 0 on success. |
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 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
|
5240 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5241 WebView *html = handle; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5242 [[html mainFrame] loadHTMLString:[ NSString stringWithUTF8String:string ] baseURL:nil]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5243 return 0; |
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 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5246 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5247 * 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
|
5248 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5249 * handle: Handle to the window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5250 * 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
|
5251 * file object to be rendered. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5252 * Returns: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5253 * 0 on success. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5254 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5255 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
|
5256 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5257 WebView *html = handle; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5258 [[html mainFrame] loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:[ NSString stringWithUTF8String:url ]]]]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5259 return 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5260 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5261 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5262 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5263 * 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
|
5264 * Not available under OS/2, eCS |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5265 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5266 * 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
|
5267 * 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
|
5268 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
5269 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
|
5270 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
5271 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
|
5272 DW_MUTEX_LOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5273 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
|
5274 /* [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
|
5275 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5276 return web; |
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 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5279 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5280 * 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
|
5281 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5282 * 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
|
5283 * 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
|
5284 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5285 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
|
5286 { |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
5287 NSPoint mouseLoc; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5288 mouseLoc = [NSEvent mouseLocation]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5289 if(x) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5290 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5291 *x = mouseLoc.x; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5292 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5293 if(y) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5294 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5295 *y = mouseLoc.y; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5296 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5297 } |
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 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5300 * 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
|
5301 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5302 * x: X coordinate. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5303 * y: Y coordinate. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5304 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5305 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
|
5306 { |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
5307 /* 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
|
5308 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5309 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5310 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5311 * 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
|
5312 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5313 * 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
|
5314 * resource file. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5315 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
5316 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
|
5317 { |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5318 NSMenu *menu = [[[NSMenu alloc] init] autorelease]; |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5319 [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
|
5320 /* [menu setTag:cid]; Why doesn't this work? */ |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5321 return menu; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5322 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5323 |
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 * Create a menubar on a window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5326 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5327 * 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
|
5328 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5329 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
|
5330 { |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5331 NSWindow *window = location; |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5332 NSMenu *windowmenu = _generate_main_menu(); |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5333 [[window contentView] setMenu:windowmenu]; |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5334 return (HMENUI)windowmenu; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5335 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5336 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5337 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5338 * 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
|
5339 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5340 * menu: Handle of a menu. |
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 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
|
5343 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5344 NSMenu *thismenu = *menu; |
658
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
5345 [thismenu release]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5346 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5347 |
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 * 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
|
5350 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5351 * 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
|
5352 * 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
|
5353 * x: X coordinate. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5354 * y: Y coordinate. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5355 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5356 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
|
5357 { |
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
|
5358 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
|
5359 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
|
5360 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
|
5361 NSWindow *window = [view window]; |
701
c91a1b345f2e
Fix for button press and context menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
700
diff
changeset
|
5362 NSEvent *event = [DWApp currentEvent]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
5363 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
|
5364 location:[window convertScreenToBase:NSMakePoint(x, y)] |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
5365 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
|
5366 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
|
5367 windowNumber:[window windowNumber] |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
5368 context:[NSGraphicsContext currentContext] |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
5369 eventNumber:1 |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
5370 clickCount:1 |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
5371 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
|
5372 [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
|
5373 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5374 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5375 char _removetilde(char *dest, char *src) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5376 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5377 int z, cur=0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5378 char accel = '\0'; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5379 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5380 for(z=0;z<strlen(src);z++) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5381 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5382 if(src[z] != '~') |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5383 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5384 dest[cur] = src[z]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5385 cur++; |
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 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5388 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5389 accel = src[z+1]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5390 } |
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 dest[cur] = 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5393 return accel; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5394 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5395 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5396 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5397 * 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
|
5398 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5399 * 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
|
5400 * 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
|
5401 * 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
|
5402 * 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
|
5403 * 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
|
5404 * 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
|
5405 * 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
|
5406 * 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
|
5407 */ |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5408 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
|
5409 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5410 NSMenu *menu = menux; |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5411 NSMenu *submenu = submenux; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5412 NSMenuItem *item = NULL; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5413 if(strlen(title) == 0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5414 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5415 [menu addItem:[NSMenuItem separatorItem]]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5416 } |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
5417 else |
650
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 char accel[2]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5420 char *newtitle = malloc(strlen(title)+1); |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5421 NSString *nstr; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5422 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5423 accel[0] = _removetilde(newtitle, title); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5424 accel[1] = 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5425 |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5426 nstr = [ NSString stringWithUTF8String:newtitle ]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5427 free(newtitle); |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5428 |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5429 item = [menu addItemWithTitle: nstr |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5430 action:@selector(menuHandler:) |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5431 keyEquivalent:[ NSString stringWithUTF8String:accel ]]; |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5432 [item setTag:itemid]; |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5433 if(flags & DW_MIS_CHECKED) |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5434 { |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5435 [item setState:NSOnState]; |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5436 } |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5437 if(flags & DW_MIS_DISABLED) |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5438 { |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5439 [item setEnabled:NO]; |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5440 } |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5441 |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5442 if(submenux) |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5443 { |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5444 [submenu setTitle:nstr]; |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5445 [menu setSubmenu:submenu forItem:item]; |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5446 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5447 return item; |
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 return item; |
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 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5452 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5453 * 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
|
5454 * 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
|
5455 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5456 * 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
|
5457 * id: Menuitem id. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5458 * 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
|
5459 */ |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5460 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
|
5461 { |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5462 id menu = menux; |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5463 NSMenuItem *menuitem = (NSMenuItem *)[menu itemWithTag:itemid]; |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5464 |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5465 if(menuitem != nil) |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5466 { |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5467 if(check) |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5468 { |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5469 [menuitem setState:NSOnState]; |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5470 } |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5471 else |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5472 { |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5473 [menuitem setState:NSOffState]; |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5474 } |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5475 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5476 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5477 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5478 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5479 * 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
|
5480 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5481 * 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
|
5482 * id: Menuitem id. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5483 * 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
|
5484 * DW_MIS_CHECKED/DW_MIS_UNCHECKED |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5485 */ |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5486 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
|
5487 { |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5488 id menu = menux; |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5489 NSMenuItem *menuitem = (NSMenuItem *)[menu itemWithTag:itemid]; |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5490 |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5491 if(menuitem != nil) |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5492 { |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5493 if(state & DW_MIS_CHECKED) |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5494 { |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5495 [menuitem setState:NSOnState]; |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5496 } |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5497 else if(state & DW_MIS_UNCHECKED) |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5498 { |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5499 [menuitem setState:NSOffState]; |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5500 } |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5501 if(state & DW_MIS_ENABLED) |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5502 { |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5503 [menuitem setEnabled:YES]; |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5504 } |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5505 else if(state & DW_MIS_DISABLED) |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5506 { |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5507 [menuitem setEnabled:NO]; |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5508 } |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
5509 } |
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 |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5512 /* 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
|
5513 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
|
5514 { |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5515 NSArray *pages = [notebook tabViewItems]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
5516 for(DWNotebookPage *notepage in pages) |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5517 { |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5518 if([notepage pageid] == pageid) |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5519 { |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5520 return notepage; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5521 } |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5522 } |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5523 return nil; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5524 } |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5525 |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5526 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5527 * 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
|
5528 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5529 * 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
|
5530 * resource file. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5531 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
5532 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
|
5533 { |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5534 DWNotebook *notebook = [[DWNotebook alloc] init]; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5535 [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
|
5536 /* [notebook setTag:cid]; Why doesn't this work? */ |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5537 return notebook; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5538 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5539 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5540 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5541 * 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
|
5542 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5543 * handle: Window (widget) handle. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5544 * flags: Any additional page creation flags. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5545 * 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
|
5546 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5547 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
|
5548 { |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5549 DWNotebook *notebook = handle; |
665
e6bec2290f3f
Fixing warnings with Xcode 4 and switched to manual releasing in the draw functions to stop leaking.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
664
diff
changeset
|
5550 NSInteger page = [notebook pageid]; |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5551 DWNotebookPage *notepage = [[DWNotebookPage alloc] initWithIdentifier:nil]; |
666
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
5552 [notepage setPageid:(NSInteger)page]; |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5553 if(front) |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5554 { |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5555 [notebook insertTabViewItem:notepage atIndex:(NSInteger)0]; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5556 } |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5557 else |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5558 { |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5559 [notebook addTabViewItem:notepage]; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5560 } |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5561 [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
|
5562 [notepage release]; |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5563 return (unsigned long)page; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5564 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5565 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5566 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5567 * Remove a page from a notebook. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5568 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5569 * handle: Handle to the notebook widget. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5570 * 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
|
5571 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5572 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
|
5573 { |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5574 DWNotebook *notebook = handle; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5575 DWNotebookPage *notepage = _notepage_from_id(notebook, pageid); |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5576 |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5577 if(notepage != nil) |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5578 { |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5579 [notebook removeTabViewItem:notepage]; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5580 [notepage release]; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5581 } |
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 * Queries the currently visible page ID. |
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 * handle: Handle to the notebook widget. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5588 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5589 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
|
5590 { |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5591 DWNotebook *notebook = handle; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5592 DWNotebookPage *notepage = (DWNotebookPage *)[notebook selectedTabViewItem]; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5593 return [notepage pageid]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5594 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5595 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5596 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5597 * Sets the currently visibale page ID. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5598 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5599 * handle: Handle to the notebook widget. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5600 * 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
|
5601 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5602 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
|
5603 { |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5604 DWNotebook *notebook = handle; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5605 DWNotebookPage *notepage = _notepage_from_id(notebook, pageid); |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5606 |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5607 if(notepage != nil) |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5608 { |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5609 [notebook selectTabViewItem:notepage]; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5610 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5611 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5612 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5613 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5614 * 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
|
5615 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5616 * handle: Notebook handle. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5617 * 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
|
5618 * 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
|
5619 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5620 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
|
5621 { |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5622 DWNotebook *notebook = handle; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5623 DWNotebookPage *notepage = _notepage_from_id(notebook, pageid); |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5624 |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5625 if(notepage != nil) |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5626 { |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5627 [notepage setLabel:[ NSString stringWithUTF8String:text ]]; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5628 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5629 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5630 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5631 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5632 * 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
|
5633 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5634 * handle: Notebook handle. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5635 * 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
|
5636 * 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
|
5637 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5638 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
|
5639 { |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5640 /* Note supported here... do nothing */ |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5641 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5642 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5643 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5644 * 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
|
5645 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5646 * 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
|
5647 * 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
|
5648 * page: Box handle to be packed. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5649 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5650 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
|
5651 { |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5652 DWNotebook *notebook = handle; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5653 DWNotebookPage *notepage = _notepage_from_id(notebook, pageid); |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5654 |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5655 if(notepage != nil) |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5656 { |
667
28727d9a835c
Fix for a rather serious notebook layout bug.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
666
diff
changeset
|
5657 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
|
5658 DWBox *box = tmpbox; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
5659 |
667
28727d9a835c
Fix for a rather serious notebook layout bug.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
666
diff
changeset
|
5660 dw_box_pack_start(tmpbox, page, 0, 0, TRUE, TRUE, 0); |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5661 [notepage setView:box]; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
5662 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5663 } |
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 * Create a new Window Frame. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5667 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5668 * 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
|
5669 * title: The Window title. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5670 * 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
|
5671 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5672 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
|
5673 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
5674 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
|
5675 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
|
5676 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
|
5677 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
|
5678 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
|
5679 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
|
5680 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
|
5681 defer:false]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5682 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5683 [window setTitle:[ NSString stringWithUTF8String:title ]]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5684 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5685 DWView *view = [[DWView alloc] init]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5686 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5687 [window setContentView:view]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5688 [window setDelegate:view]; |
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
|
5689 #ifdef BUILDING_FOR_SNOW_LEOPARD |
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
|
5690 [window setAllowsConcurrentViewDrawing:NO]; |
718
002f33d4439d
More 10.5 fixes... some selectors cause exceptions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
717
diff
changeset
|
5691 #endif |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
5692 [view release]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
5693 |
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
|
5694 /* 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
|
5695 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
|
5696 { |
014b02436c1f
Added MDI simulation code... the MDI "window" will just be a box for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
683
diff
changeset
|
5697 id object = hwndOwner; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
5698 |
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
|
5699 /* 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
|
5700 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
|
5701 { |
014b02436c1f
Added MDI simulation code... the MDI "window" will just be a box for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
683
diff
changeset
|
5702 /* 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
|
5703 [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
|
5704 [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
|
5705 } |
014b02436c1f
Added MDI simulation code... the MDI "window" will just be a box for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
683
diff
changeset
|
5706 } |
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
|
5707 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
|
5708 return (HWND)window; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5709 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5710 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5711 /* |
651
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5712 * 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
|
5713 * Parameters: |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5714 * handle: Window handle of the widget. |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5715 * function: Function pointer to be called. |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5716 * 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
|
5717 */ |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5718 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
|
5719 { |
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
|
5720 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
|
5721 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
|
5722 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
|
5723 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
|
5724 [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
|
5725 free(params); |
651
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5726 } |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5727 |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5728 |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5729 /* |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5730 * 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
|
5731 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5732 * 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
|
5733 * 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
|
5734 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5735 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
|
5736 { |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
5737 id object = handle; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
5738 |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
5739 if([ object isKindOfClass:[ NSView class ] ]) |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
5740 { |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
5741 NSView *view = handle; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
5742 |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
5743 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
|
5744 { |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
5745 [view discardCursorRects]; |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
5746 } |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
5747 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
|
5748 { |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
5749 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
|
5750 NSCursor *cursor = [NSCursor arrowCursor]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
5751 |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
5752 [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
|
5753 } |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
5754 /* 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
|
5755 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5756 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5757 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5758 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5759 * Makes the window visible. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5760 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5761 * 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
|
5762 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5763 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
|
5764 { |
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
|
5765 NSObject *object = handle; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5766 |
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
|
5767 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
|
5768 { |
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
|
5769 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
|
5770 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
|
5771 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
|
5772 { |
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
|
5773 [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
|
5774 } |
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
|
5775 /* 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
|
5776 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
|
5777 { |
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
|
5778 /* 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
|
5779 [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
|
5780 } |
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
|
5781 [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
|
5782 [[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
|
5783 [[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
|
5784 } |
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
|
5785 return 0; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5786 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5787 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5788 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5789 * Makes the window invisible. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5790 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5791 * 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
|
5792 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5793 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
|
5794 { |
733
8d5e5b89725f
Fixed the crashing issue with dw_color_choose() it now functions properly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
732
diff
changeset
|
5795 NSObject *object = handle; |
8d5e5b89725f
Fixed the crashing issue with dw_color_choose() it now functions properly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
732
diff
changeset
|
5796 |
8d5e5b89725f
Fixed the crashing issue with dw_color_choose() it now functions properly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
732
diff
changeset
|
5797 if([ object isKindOfClass:[ NSWindow class ] ]) |
8d5e5b89725f
Fixed the crashing issue with dw_color_choose() it now functions properly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
732
diff
changeset
|
5798 { |
8d5e5b89725f
Fixed the crashing issue with dw_color_choose() it now functions properly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
732
diff
changeset
|
5799 NSWindow *window = handle; |
8d5e5b89725f
Fixed the crashing issue with dw_color_choose() it now functions properly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
732
diff
changeset
|
5800 |
8d5e5b89725f
Fixed the crashing issue with dw_color_choose() it now functions properly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
732
diff
changeset
|
5801 [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
|
5802 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5803 return 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5804 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5805 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5806 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5807 * 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
|
5808 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5809 * handle: The window (widget) handle. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5810 * 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
|
5811 * 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
|
5812 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5813 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
|
5814 { |
739
a0aec9a56914
Font and color improvements... including implementing dw_window_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
738
diff
changeset
|
5815 id object = handle; |
a0aec9a56914
Font and color improvements... including implementing dw_window_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
738
diff
changeset
|
5816 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
|
5817 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
|
5818 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
|
5819 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]; |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
5820 |
739
a0aec9a56914
Font and color improvements... including implementing dw_window_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
738
diff
changeset
|
5821 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
|
5822 { |
a0aec9a56914
Font and color improvements... including implementing dw_window_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
738
diff
changeset
|
5823 NSTextFieldCell *text = object; |
a0aec9a56914
Font and color improvements... including implementing dw_window_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
738
diff
changeset
|
5824 [text setTextColor:fg]; |
a0aec9a56914
Font and color improvements... including implementing dw_window_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
738
diff
changeset
|
5825 } |
a0aec9a56914
Font and color improvements... including implementing dw_window_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
738
diff
changeset
|
5826 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
|
5827 { |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
5828 DWBox *box = object; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
5829 |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
5830 [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
|
5831 } |
a0aec9a56914
Font and color improvements... including implementing dw_window_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
738
diff
changeset
|
5832 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
|
5833 { |
a0aec9a56914
Font and color improvements... including implementing dw_window_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
738
diff
changeset
|
5834 DWButton *button = object; |
a0aec9a56914
Font and color improvements... including implementing dw_window_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
738
diff
changeset
|
5835 |
a0aec9a56914
Font and color improvements... including implementing dw_window_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
738
diff
changeset
|
5836 [[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
|
5837 } |
a0aec9a56914
Font and color improvements... including implementing dw_window_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
738
diff
changeset
|
5838 return 0; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5839 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5840 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5841 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5842 * 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
|
5843 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5844 * handle: The window (widget) handle. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5845 * 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
|
5846 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5847 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
|
5848 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5849 return 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5850 } |
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 * 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
|
5854 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5855 * handle: Window (widget) handle. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5856 * width: New width in pixels. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5857 * height: New height in pixels. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5858 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5859 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
|
5860 { |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
5861 id object = handle; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
5862 |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
5863 if([object isMemberOfClass:[NSWindow class]]) |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
5864 { |
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
|
5865 #ifdef BUILDING_FOR_SNOW_LEOPARD |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
5866 NSWindow *window = object; |
665
e6bec2290f3f
Fixing warnings with Xcode 4 and switched to manual releasing in the draw functions to stop leaking.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
664
diff
changeset
|
5867 int currentstyle = (int)[window styleMask]; |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
5868 int tmp; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
5869 |
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
|
5870 tmp = currentstyle | (int)mask; |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
5871 tmp ^= mask; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
5872 tmp |= style; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
5873 |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
5874 [window setStyleMask:tmp]; |
718
002f33d4439d
More 10.5 fixes... some selectors cause exceptions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
717
diff
changeset
|
5875 #endif |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
5876 } |
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
|
5877 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
|
5878 { |
bb3b2d804f0e
Working on fonts some more.... setting a default label font that is smaller.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
739
diff
changeset
|
5879 NSTextField *tf = object; |
bb3b2d804f0e
Working on fonts some more.... setting a default label font that is smaller.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
739
diff
changeset
|
5880 |
bb3b2d804f0e
Working on fonts some more.... setting a default label font that is smaller.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
739
diff
changeset
|
5881 /* 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
|
5882 [[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
|
5883 } |
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
|
5884 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
|
5885 { |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
5886 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
|
5887 [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
|
5888 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5889 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5890 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5891 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5892 * 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
|
5893 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5894 * window: Toplevel window or dialog. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5895 * 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
|
5896 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5897 void API dw_window_default(HWND window, HWND defaultitem) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5898 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5899 NSLog(@"dw_window_default() unimplemented\n"); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5900 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5901 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5902 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5903 * 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
|
5904 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5905 * 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
|
5906 * 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
|
5907 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5908 void API dw_window_click_default(HWND window, HWND next) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5909 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5910 NSLog(@"dw_window_click_default() unimplemented\n"); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5911 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5912 |
686
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5913 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
|
5914 |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5915 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5916 * 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
|
5917 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5918 * handle: Handle to receive mouse input. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5919 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5920 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
|
5921 { |
686
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5922 id object = handle; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
5923 |
686
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5924 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
|
5925 { |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5926 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
|
5927 } |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5928 if(object) |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5929 { |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5930 [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
|
5931 _DWCapture = object; |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5932 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5933 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5934 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5935 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5936 * Releases previous mouse capture. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5937 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5938 void API dw_window_release(void) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5939 { |
686
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5940 if(_DWCapture) |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5941 { |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5942 [_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
|
5943 _DWCapture = nil; |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5944 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5945 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5946 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5947 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5948 * Tracks this window movement. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5949 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5950 * 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
|
5951 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5952 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
|
5953 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5954 NSLog(@"dw_window_track() unimplemented\n"); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5955 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5956 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5957 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5958 * 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
|
5959 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5960 * handle: The window handle to destroy. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5961 * 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
|
5962 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5963 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
|
5964 { |
686
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5965 id object = handle; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
5966 |
686
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5967 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
|
5968 { |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5969 /* 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
|
5970 * 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
|
5971 * 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
|
5972 */ |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5973 NSWindow *window = handle; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
5974 |
686
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5975 /* 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
|
5976 if(newparent) |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5977 { |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5978 object = newparent; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
5979 |
686
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5980 /* 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
|
5981 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
|
5982 { |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5983 /* 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
|
5984 [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
|
5985 [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
|
5986 return; |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5987 } |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5988 } |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5989 /* 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
|
5990 [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
|
5991 [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
|
5992 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5993 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5994 |
744
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
5995 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
|
5996 { |
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
5997 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
|
5998 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
|
5999 NSFont *font = nil; |
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
6000 |
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
6001 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
|
6002 { |
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
6003 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
|
6004 *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
|
6005 name++; |
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
6006 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
|
6007 } |
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
6008 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
|
6009 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
|
6010 } |
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
6011 |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6012 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6013 * 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
|
6014 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6015 * handle: The window (widget) handle. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6016 * 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
|
6017 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6018 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
|
6019 { |
744
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
6020 NSFont *font = _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
|
6021 |
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
6022 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
|
6023 { |
744
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
6024 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
|
6025 if([object window]) |
673
6d0f0dc7ff7c
Some minor font fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
672
diff
changeset
|
6026 { |
744
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
6027 [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
|
6028 [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
|
6029 [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
|
6030 } |
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
6031 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
|
6032 { |
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
6033 [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
|
6034 [[object cell] setFont:font]; |
673
6d0f0dc7ff7c
Some minor font fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
672
diff
changeset
|
6035 } |
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
|
6036 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
|
6037 { |
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
|
6038 DWRender *render = object; |
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
|
6039 |
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
|
6040 [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
|
6041 } |
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
|
6042 } |
bb3b2d804f0e
Working on fonts some more.... setting a default label font that is smaller.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
739
diff
changeset
|
6043 return 0; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6044 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6045 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6046 /* |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
6047 * Returns the current font for the specified window |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
6048 * Parameters: |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
6049 * 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
|
6050 */ |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
6051 char * API dw_window_get_font(HWND handle) |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
6052 { |
739
a0aec9a56914
Font and color improvements... including implementing dw_window_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
738
diff
changeset
|
6053 id object = handle; |
a0aec9a56914
Font and color improvements... including implementing dw_window_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
738
diff
changeset
|
6054 |
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
|
6055 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
|
6056 { |
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
|
6057 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
|
6058 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
|
6059 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
|
6060 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
|
6061 } |
a0aec9a56914
Font and color improvements... including implementing dw_window_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
738
diff
changeset
|
6062 return NULL; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
6063 } |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
6064 |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
6065 /* |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6066 * 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
|
6067 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6068 * handle: The window handle to destroy. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6069 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6070 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
|
6071 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
6072 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
|
6073 DW_MUTEX_LOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6074 NSObject *object = handle; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6075 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6076 if([ object isKindOfClass:[ NSWindow class ] ]) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6077 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6078 NSWindow *window = handle; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6079 [window close]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6080 } |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
6081 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6082 return 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6083 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6084 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6085 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6086 * 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
|
6087 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6088 * handle: Handle to the window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6089 * Returns: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6090 * 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
|
6091 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6092 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
|
6093 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6094 NSObject *object = handle; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6095 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6096 if([ object isKindOfClass:[ NSControl class ] ]) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6097 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6098 NSControl *control = handle; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6099 NSString *nsstr = [ control stringValue]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6100 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6101 return strdup([ nsstr UTF8String ]); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6102 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6103 else if([ object isKindOfClass:[ NSWindow class ] ]) |
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 NSWindow *window = handle; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6106 NSString *nsstr = [ window title]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6107 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6108 return strdup([ nsstr UTF8String ]); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6109 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6110 return NULL; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6111 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6112 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6113 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6114 * 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
|
6115 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6116 * handle: Handle to the window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6117 * 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
|
6118 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6119 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
|
6120 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
6121 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
|
6122 DW_MUTEX_LOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6123 NSObject *object = handle; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6124 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6125 if([ object isKindOfClass:[ NSControl class ] ]) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6126 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6127 NSControl *control = handle; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6128 [control setStringValue:[ NSString stringWithUTF8String:text ]]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6129 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6130 else if([ object isKindOfClass:[ NSWindow class ] ]) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6131 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6132 NSWindow *window = handle; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6133 [window setTitle:[ NSString stringWithUTF8String:text ]]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6134 } |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
6135 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6136 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6137 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6138 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6139 * Disables given window (widget). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6140 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6141 * handle: Handle to the window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6142 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6143 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
|
6144 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6145 NSObject *object = handle; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6146 if([ object isKindOfClass:[ NSControl class ] ]) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6147 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6148 NSControl *control = handle; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6149 [control setEnabled:NO]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6150 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6151 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6152 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6153 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6154 * Enables given window (widget). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6155 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6156 * handle: Handle to the window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6157 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6158 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
|
6159 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6160 NSObject *object = handle; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6161 if([ object isKindOfClass:[ NSControl class ] ]) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6162 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6163 NSControl *control = handle; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6164 [control setEnabled:YES]; |
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 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6167 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6168 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6169 * Sets the 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
|
6170 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6171 * handle: Handle to the window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6172 * 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
|
6173 * (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
|
6174 * 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
|
6175 * 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
|
6176 * 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
|
6177 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
6178 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
|
6179 { |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
6180 NSObject *object = handle; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
6181 if([ object isKindOfClass:[ NSImageView class ] ]) |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
6182 { |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
6183 NSImageView *iv = handle; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
6184 NSData *thisdata = [[NSData alloc] dataWithBytes:data length:len]; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
6185 NSImage *pixmap = [[NSImage alloc] initWithData:thisdata]; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
6186 |
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
|
6187 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
|
6188 { |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
6189 [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
|
6190 } |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
6191 [pixmap release]; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
6192 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6193 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6194 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6195 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6196 * 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
|
6197 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6198 * handle: Handle to the window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6199 * 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
|
6200 * (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
|
6201 * 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
|
6202 * 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
|
6203 * 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
|
6204 */ |
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
|
6205 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
|
6206 { |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
6207 NSObject *object = handle; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
6208 if([ object isKindOfClass:[ NSImageView class ] ]) |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
6209 { |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
6210 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
|
6211 NSImage *bitmap = nil; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
6212 |
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
|
6213 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
|
6214 { |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
6215 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
|
6216 } |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
6217 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
|
6218 { |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
6219 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
|
6220 } |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
6221 |
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
|
6222 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
|
6223 { |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
6224 [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
|
6225 } |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
6226 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6227 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6228 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6229 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6230 * 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
|
6231 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6232 * handle: Handle to the window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6233 * 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
|
6234 */ |
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
|
6235 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
|
6236 { |
661
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
6237 /* 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
|
6238 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6239 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6240 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6241 * 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
|
6242 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6243 * handle: Handle to the parent window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6244 * id: Integer ID of the child. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6245 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
6246 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
|
6247 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6248 NSObject *object = handle; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6249 NSView *view = handle; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6250 if([ object isKindOfClass:[ NSWindow class ] ]) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6251 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6252 NSWindow *window = handle; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6253 view = [window contentView]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6254 } |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
6255 return [view viewWithTag:cid]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6256 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6257 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6258 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6259 * 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
|
6260 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6261 * handle: The window handle to minimize. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6262 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6263 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
|
6264 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6265 NSWindow *window = handle; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6266 [window miniaturize:nil]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6267 return 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6268 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6269 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6270 /* 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
|
6271 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6272 * 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
|
6273 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6274 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
|
6275 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6276 NSWindow *window = handle; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6277 [window flushWindow]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6278 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6279 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6280 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6281 * Makes the window topmost. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6282 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6283 * 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
|
6284 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6285 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
|
6286 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6287 NSWindow *window = handle; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6288 [window orderFront:nil]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6289 return 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6290 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6291 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6292 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6293 * Makes the window bottommost. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6294 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6295 * 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
|
6296 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6297 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
|
6298 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6299 NSWindow *window = handle; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6300 [window orderBack:nil]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6301 return 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6302 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6303 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6304 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6305 * 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
|
6306 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6307 * handle: Window (widget) handle. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6308 * width: New width in pixels. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6309 * height: New height in pixels. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6310 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6311 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
|
6312 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
6313 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
|
6314 DW_MUTEX_LOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6315 NSObject *object = handle; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6316 NSSize size; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6317 size.width = width; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
6318 size.height = height; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6319 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6320 if([ object isKindOfClass:[ NSWindow class ] ]) |
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 NSWindow *window = handle; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6323 [window setContentSize:size]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6324 } |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
6325 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6326 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6327 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6328 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6329 * 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
|
6330 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6331 * handle: Window (widget) handle. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6332 * 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
|
6333 * 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
|
6334 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6335 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
|
6336 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
6337 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
|
6338 DW_MUTEX_LOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6339 NSObject *object = handle; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6340 NSPoint point; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6341 point.x = x; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
6342 point.y = y; |
650
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 if([ object isKindOfClass:[ NSWindow class ] ]) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6345 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6346 NSWindow *window = handle; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6347 [window setFrameOrigin:point]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6348 } |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
6349 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6350 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6351 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6352 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6353 * 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
|
6354 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6355 * handle: Window (widget) handle. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6356 * 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
|
6357 * 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
|
6358 * width: Width of the widget. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6359 * height: Height of the widget. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6360 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6361 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
|
6362 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6363 dw_window_set_pos(handle, x, y); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6364 dw_window_set_size(handle, width, height); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6365 } |
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 * 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
|
6369 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6370 * handle: Window (widget) handle. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6371 * 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
|
6372 * 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
|
6373 * width: Width of the widget. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6374 * height: Height of the widget. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6375 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6376 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
|
6377 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6378 NSObject *object = handle; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6379 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6380 if([ object isKindOfClass:[ NSWindow class ] ]) |
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 NSWindow *window = handle; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6383 NSRect rect = [window frame]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6384 if(x) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6385 *x = rect.origin.x; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6386 if(y) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6387 *y = rect.origin.y; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6388 if(width) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6389 *width = rect.size.width; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6390 if(height) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6391 *height = rect.size.height; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
6392 return; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6393 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6394 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6395 |
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 * Returns the width of the screen. |
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 int API dw_screen_width(void) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6400 { |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
6401 NSRect screenRect = [[NSScreen mainScreen] frame]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6402 return screenRect.size.width; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6403 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6404 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6405 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6406 * Returns the height of the screen. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6407 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6408 int API dw_screen_height(void) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6409 { |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
6410 NSRect screenRect = [[NSScreen mainScreen] frame]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6411 return screenRect.size.height; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6412 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6413 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6414 /* 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
|
6415 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
|
6416 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6417 NSWindowDepth screenDepth = [[NSScreen mainScreen] depth]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6418 return NSBitsPerPixelFromDepth(screenDepth); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6419 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6420 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6421 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6422 * 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
|
6423 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6424 * env: Pointer to a DWEnv struct. |
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 void dw_environment_query(DWEnv *env) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6427 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6428 struct utsname name; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6429 char tempbuf[100]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6430 int len, z; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6431 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6432 uname(&name); |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
6433 strcpy(env->osName, "MacOS"); |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6434 strcpy(tempbuf, name.release); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6435 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6436 env->MajorBuild = env->MinorBuild = 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6437 |
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
|
6438 len = (int)strlen(tempbuf); |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6439 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6440 strcpy(env->buildDate, __DATE__); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6441 strcpy(env->buildTime, __TIME__); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6442 env->DWMajorVersion = DW_MAJOR_VERSION; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6443 env->DWMinorVersion = DW_MINOR_VERSION; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6444 env->DWSubVersion = DW_SUB_VERSION; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6445 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6446 for(z=1;z<len;z++) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6447 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6448 if(tempbuf[z] == '.') |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6449 { |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
6450 int ver = atoi(tempbuf); |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6451 tempbuf[z] = '\0'; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
6452 if(ver > 4) |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
6453 { |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
6454 env->MajorVersion = 10; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
6455 env->MinorVersion = ver - 4; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
6456 env->MajorBuild = atoi(&tempbuf[z+1]); |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
6457 } |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
6458 else |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
6459 { |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
6460 env->MajorVersion = ver; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
6461 env->MinorVersion = atoi(&tempbuf[z+1]); |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
6462 } |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
6463 |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6464 return; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6465 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6466 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6467 env->MajorVersion = atoi(tempbuf); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6468 env->MinorVersion = 0; |
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 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6472 * Emits a beep. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6473 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6474 * freq: Frequency. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6475 * dur: Duration. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6476 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6477 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
|
6478 { |
651
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6479 NSBeep(); |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6480 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6481 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6482 /* 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
|
6483 * anything you have drawn is visible. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6484 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6485 void API dw_flush(void) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6486 { |
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
|
6487 /* 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
|
6488 [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
|
6489 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6490 |
651
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6491 /* 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
|
6492 * 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
|
6493 * dw_window_get_data(). |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6494 */ |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6495 UserData *_find_userdata(UserData **root, char *varname) |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6496 { |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6497 UserData *tmp = *root; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6498 |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6499 while(tmp) |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6500 { |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6501 if(strcasecmp(tmp->varname, varname) == 0) |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6502 return tmp; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6503 tmp = tmp->next; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6504 } |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6505 return NULL; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6506 } |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6507 |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6508 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
|
6509 { |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6510 UserData *new = _find_userdata(root, varname); |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6511 |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6512 if(new) |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6513 { |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6514 new->data = data; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6515 return TRUE; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6516 } |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6517 else |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6518 { |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6519 new = malloc(sizeof(UserData)); |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6520 if(new) |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6521 { |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6522 new->varname = strdup(varname); |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6523 new->data = data; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6524 |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6525 new->next = NULL; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6526 |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6527 if (!*root) |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6528 *root = new; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6529 else |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6530 { |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6531 UserData *prev = NULL, *tmp = *root; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6532 while(tmp) |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6533 { |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6534 prev = tmp; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6535 tmp = tmp->next; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6536 } |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6537 if(prev) |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6538 prev->next = new; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6539 else |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6540 *root = new; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6541 } |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6542 return TRUE; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6543 } |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6544 } |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6545 return FALSE; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6546 } |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6547 |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6548 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
|
6549 { |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6550 UserData *prev = NULL, *tmp = *root; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6551 |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6552 while(tmp) |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6553 { |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6554 if(all || strcasecmp(tmp->varname, varname) == 0) |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6555 { |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6556 if(!prev) |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6557 { |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6558 *root = tmp->next; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6559 free(tmp->varname); |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6560 free(tmp); |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6561 if(!all) |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6562 return 0; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6563 tmp = *root; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6564 } |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6565 else |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6566 { |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6567 /* If all is true we should |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6568 * never get here. |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6569 */ |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6570 prev->next = tmp->next; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6571 free(tmp->varname); |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6572 free(tmp); |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6573 return 0; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6574 } |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6575 } |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6576 else |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6577 { |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6578 prev = tmp; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6579 tmp = tmp->next; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6580 } |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6581 } |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6582 return 0; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6583 } |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6584 |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6585 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6586 * 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
|
6587 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6588 * 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
|
6589 * 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
|
6590 * 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
|
6591 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6592 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
|
6593 { |
651
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6594 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
|
6595 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
|
6596 { |
5fe12469c1fb
Fix for dw_window_set/get_data() on a top-level window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
680
diff
changeset
|
6597 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
|
6598 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
|
6599 } |
5fe12469c1fb
Fix for dw_window_set/get_data() on a top-level window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
680
diff
changeset
|
6600 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
|
6601 { |
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
6602 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
|
6603 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
|
6604 } |
651
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6605 WindowData *blah = (WindowData *)[object userdata]; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6606 |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6607 if(!blah) |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6608 { |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6609 if(!dataname) |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6610 return; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6611 |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6612 blah = calloc(1, sizeof(WindowData)); |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6613 [object setUserdata:blah]; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6614 } |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6615 |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6616 if(data) |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6617 _new_userdata(&(blah->root), dataname, data); |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6618 else |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6619 { |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6620 if(dataname) |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6621 _remove_userdata(&(blah->root), dataname, FALSE); |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6622 else |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6623 _remove_userdata(&(blah->root), NULL, TRUE); |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6624 } |
650
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 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6628 * 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
|
6629 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6630 * 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
|
6631 * 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
|
6632 * 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
|
6633 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6634 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
|
6635 { |
651
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6636 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
|
6637 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
|
6638 { |
5fe12469c1fb
Fix for dw_window_set/get_data() on a top-level window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
680
diff
changeset
|
6639 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
|
6640 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
|
6641 } |
5fe12469c1fb
Fix for dw_window_set/get_data() on a top-level window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
680
diff
changeset
|
6642 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
|
6643 { |
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
6644 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
|
6645 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
|
6646 } |
651
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6647 WindowData *blah = (WindowData *)[object userdata]; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6648 |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6649 if(blah && blah->root && dataname) |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6650 { |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6651 UserData *ud = _find_userdata(&(blah->root), dataname); |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6652 if(ud) |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6653 return ud->data; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6654 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6655 return NULL; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6656 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6657 |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
6658 #define DW_TIMER_MAX 64 |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
6659 NSTimer *DWTimers[DW_TIMER_MAX]; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
6660 |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6661 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6662 * 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
|
6663 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6664 * interval: Milliseconds to delay between calls. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6665 * 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
|
6666 * 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
|
6667 * Returns: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6668 * 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
|
6669 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6670 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
|
6671 { |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
6672 int z; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
6673 |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
6674 for(z=0;z<DW_TIMER_MAX;z++) |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6675 { |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
6676 if(!DWTimers[z]) |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6677 { |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
6678 break; |
650
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 } |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
6681 |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
6682 if(sigfunc && !DWTimers[z]) |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
6683 { |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
6684 NSTimeInterval seconds = (double)interval / 1000.0; |
688
b52f1d4a60dd
Fixes for timers not working properly. Includes commented out test container code for threadsafety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
687
diff
changeset
|
6685 NSTimer *thistimer = DWTimers[z] = [NSTimer scheduledTimerWithTimeInterval:seconds target:DWHandler selector:@selector(runTimer:) userInfo:nil repeats:YES]; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
6686 _new_signal(0, thistimer, z+1, sigfunc, data); |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
6687 return z+1; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
6688 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6689 return 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6690 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6691 |
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 * Removes timer callback. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6694 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6695 * 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
|
6696 */ |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
6697 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
|
6698 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6699 SignalHandler *prev = NULL, *tmp = Root; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
6700 NSTimer *thistimer; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6701 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6702 /* 0 is an invalid timer ID */ |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
6703 if(timerid < 1 || !DWTimers[timerid-1]) |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6704 return; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6705 |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
6706 thistimer = DWTimers[timerid-1]; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
6707 DWTimers[timerid-1] = nil; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
6708 |
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
|
6709 [thistimer invalidate]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6710 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6711 while(tmp) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6712 { |
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
|
6713 if(tmp->id == timerid && tmp->window == thistimer) |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6714 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6715 if(prev) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6716 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6717 prev->next = tmp->next; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6718 free(tmp); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6719 tmp = prev->next; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6720 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6721 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6722 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6723 Root = tmp->next; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6724 free(tmp); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6725 tmp = Root; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6726 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6727 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6728 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6729 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6730 prev = tmp; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6731 tmp = tmp->next; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6732 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6733 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6734 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6735 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6736 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6737 * 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
|
6738 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6739 * 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
|
6740 * 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
|
6741 * 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
|
6742 * 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
|
6743 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6744 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
|
6745 { |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
6746 ULONG message = 0, msgid = 0; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
6747 |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6748 if(window && signame && sigfunc) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6749 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6750 if((message = _findsigmessage(signame)) != 0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6751 { |
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
|
6752 _new_signal(message, window, (int)msgid, sigfunc, data); |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6753 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6754 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6755 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6756 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6757 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6758 * 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
|
6759 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6760 * 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
|
6761 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6762 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
|
6763 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6764 SignalHandler *prev = NULL, *tmp = Root; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6765 ULONG message; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6766 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6767 if(!window || !signame || (message = _findsigmessage(signame)) == 0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6768 return; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6769 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6770 while(tmp) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6771 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6772 if(tmp->window == window && tmp->message == message) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6773 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6774 if(prev) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6775 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6776 prev->next = tmp->next; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6777 free(tmp); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6778 tmp = prev->next; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6779 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6780 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6781 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6782 Root = tmp->next; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6783 free(tmp); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6784 tmp = Root; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6785 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6786 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6787 else |
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 prev = tmp; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6790 tmp = tmp->next; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6791 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6792 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6793 } |
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 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6796 * 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
|
6797 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6798 * 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
|
6799 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6800 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
|
6801 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6802 SignalHandler *prev = NULL, *tmp = Root; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6803 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6804 while(tmp) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6805 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6806 if(tmp->window == window) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6807 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6808 if(prev) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6809 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6810 prev->next = tmp->next; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6811 free(tmp); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6812 tmp = prev->next; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6813 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6814 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6815 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6816 Root = tmp->next; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6817 free(tmp); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6818 tmp = Root; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6819 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6820 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6821 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6822 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6823 prev = tmp; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6824 tmp = tmp->next; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6825 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6826 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6827 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6828 |
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 * 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
|
6831 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6832 * 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
|
6833 * 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
|
6834 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6835 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
|
6836 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6837 SignalHandler *prev = NULL, *tmp = Root; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6838 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6839 while(tmp) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6840 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6841 if(tmp->window == window && tmp->data == data) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6842 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6843 if(prev) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6844 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6845 prev->next = tmp->next; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6846 free(tmp); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6847 tmp = prev->next; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6848 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6849 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6850 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6851 Root = tmp->next; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6852 free(tmp); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6853 tmp = Root; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6854 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6855 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6856 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6857 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6858 prev = tmp; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6859 tmp = tmp->next; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6860 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6861 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6862 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6863 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6864 void _my_strlwr(char *buf) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6865 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6866 int z, len = strlen(buf); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6867 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6868 for(z=0;z<len;z++) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6869 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6870 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
|
6871 buf[z] -= 'A' - 'a'; |
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 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6874 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6875 /* 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
|
6876 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6877 * 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
|
6878 * handle: Pointer to a module handle, |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6879 * 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
|
6880 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6881 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
|
6882 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6883 int len; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6884 char *newname; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6885 char errorbuf[1024]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6886 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6887 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6888 if(!handle) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6889 return -1; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6890 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6891 if((len = strlen(name)) == 0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6892 return -1; |
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 /* Lenth + "lib" + ".dylib" + NULL */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6895 newname = malloc(len + 10); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6896 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6897 if(!newname) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6898 return -1; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6899 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6900 sprintf(newname, "lib%s.dylib", name); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6901 _my_strlwr(newname); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6902 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6903 *handle = dlopen(newname, RTLD_NOW); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6904 if(*handle == NULL) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6905 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6906 strncpy(errorbuf, dlerror(), 1024); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6907 printf("%s\n", errorbuf); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6908 sprintf(newname, "lib%s.dylib", name); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6909 *handle = dlopen(newname, RTLD_NOW); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6910 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6911 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6912 free(newname); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6913 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6914 return (NULL == *handle) ? -1 : 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6915 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6916 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6917 /* 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
|
6918 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6919 * 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
|
6920 * 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
|
6921 * 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
|
6922 * the address. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6923 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6924 int dw_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
|
6925 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6926 if(!func || !name) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6927 return -1; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6928 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6929 if(strlen(name) == 0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6930 return -1; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6931 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6932 *func = (void*)dlsym(handle, name); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6933 return (NULL == *func); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6934 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6935 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6936 /* Frees the shared library previously opened. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6937 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6938 * 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
|
6939 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6940 int dw_module_close(HMOD handle) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6941 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6942 if(handle) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6943 return dlclose(handle); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6944 return 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6945 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6946 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6947 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6948 * 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
|
6949 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6950 HMTX dw_mutex_new(void) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6951 { |
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
|
6952 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
|
6953 |
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
|
6954 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
|
6955 return mutex; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6956 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6957 |
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 * 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
|
6960 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6961 * 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
|
6962 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6963 void dw_mutex_close(HMTX mutex) |
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 if(mutex) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6966 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6967 pthread_mutex_destroy(mutex); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6968 free(mutex); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6969 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6970 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6971 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6972 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6973 * 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
|
6974 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6975 * 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
|
6976 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6977 void dw_mutex_lock(HMTX mutex) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6978 { |
693
2f21ee9d7c7b
Experimental change for locking on the main thread... will be committing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
692
diff
changeset
|
6979 /* 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
|
6980 * 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
|
6981 * 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
|
6982 * 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
|
6983 */ |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
6984 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
|
6985 { |
693
2f21ee9d7c7b
Experimental change for locking on the main thread... will be committing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
692
diff
changeset
|
6986 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
|
6987 { |
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
|
6988 /* 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
|
6989 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
|
6990 { |
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
|
6991 /* 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
|
6992 } |
693
2f21ee9d7c7b
Experimental change for locking on the main thread... will be committing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
692
diff
changeset
|
6993 } |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
6994 } |
693
2f21ee9d7c7b
Experimental change for locking on the main thread... will be committing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
692
diff
changeset
|
6995 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
|
6996 { |
693
2f21ee9d7c7b
Experimental change for locking on the main thread... will be committing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
692
diff
changeset
|
6997 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
|
6998 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6999 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7000 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7001 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7002 * Reliquishes the access to the semaphore. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7003 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7004 * 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
|
7005 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7006 void dw_mutex_unlock(HMTX mutex) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7007 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7008 pthread_mutex_unlock(mutex); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7009 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7010 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7011 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7012 * 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
|
7013 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7014 HEV dw_event_new(void) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7015 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7016 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
|
7017 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7018 if(!eve) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7019 return NULL; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7020 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7021 /* 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
|
7022 * 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
|
7023 * 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
|
7024 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7025 pthread_mutex_init (&(eve->mutex), NULL); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7026 pthread_mutex_lock (&(eve->mutex)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7027 pthread_cond_init (&(eve->event), NULL); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7028 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7029 pthread_mutex_unlock (&(eve->mutex)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7030 eve->alive = 1; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7031 eve->posted = 0; |
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 return eve; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7034 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7035 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7036 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7037 * 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
|
7038 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7039 * 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
|
7040 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7041 int dw_event_reset (HEV eve) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7042 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7043 if(!eve) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7044 return FALSE; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7045 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7046 pthread_mutex_lock (&(eve->mutex)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7047 pthread_cond_broadcast (&(eve->event)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7048 pthread_cond_init (&(eve->event), NULL); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7049 eve->posted = 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7050 pthread_mutex_unlock (&(eve->mutex)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7051 return 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7052 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7053 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7054 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7055 * 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
|
7056 * 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
|
7057 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7058 * 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
|
7059 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7060 int dw_event_post (HEV eve) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7061 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7062 if(!eve) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7063 return FALSE; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7064 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7065 pthread_mutex_lock (&(eve->mutex)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7066 pthread_cond_broadcast (&(eve->event)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7067 eve->posted = 1; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7068 pthread_mutex_unlock (&(eve->mutex)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7069 return 0; |
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 |
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 * 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
|
7074 * 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
|
7075 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7076 * 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
|
7077 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7078 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
|
7079 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7080 int rc; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7081 struct timeval now; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7082 struct timespec timeo; |
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 if(!eve) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7085 return FALSE; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7086 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7087 if(eve->posted) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7088 return 0; |
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 pthread_mutex_lock (&(eve->mutex)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7091 gettimeofday(&now, 0); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7092 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
|
7093 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
|
7094 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
|
7095 pthread_mutex_unlock (&(eve->mutex)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7096 if(!rc) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7097 return 1; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7098 if(rc == ETIMEDOUT) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7099 return -1; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7100 return 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7101 } |
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 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7104 * 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
|
7105 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7106 * 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
|
7107 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7108 int dw_event_close(HEV *eve) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7109 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7110 if(!eve || !(*eve)) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7111 return FALSE; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7112 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7113 pthread_mutex_lock (&((*eve)->mutex)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7114 pthread_cond_destroy (&((*eve)->event)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7115 pthread_mutex_unlock (&((*eve)->mutex)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7116 pthread_mutex_destroy (&((*eve)->mutex)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7117 free(*eve); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7118 *eve = NULL; |
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 return TRUE; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7121 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7122 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7123 struct _seminfo { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7124 int fd; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7125 int waiting; |
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 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7128 static void _handle_sem(int *tmpsock) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7129 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7130 fd_set rd; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7131 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
|
7132 int listenfd = tmpsock[0]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7133 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
|
7134 char command; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7135 sigset_t mask; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7136 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7137 sigfillset(&mask); /* Mask all allowed signals */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7138 pthread_sigmask(SIG_BLOCK, &mask, NULL); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7139 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7140 /* problems */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7141 if(tmpsock[1] == -1) |
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 free(array); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7144 return; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7145 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7146 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7147 array[0].fd = tmpsock[1]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7148 array[0].waiting = 0; |
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 /* 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
|
7151 free(tmpsock); |
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 while(1) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7154 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7155 FD_ZERO(&rd); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7156 FD_SET(listenfd, &rd); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7157 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7158 maxfd = listenfd; |
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 /* 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
|
7161 for(z=0;z<connectcount;z++) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7162 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7163 if(array[z].fd > maxfd) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7164 maxfd = array[z].fd; |
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 FD_SET(array[z].fd, &rd); |
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 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7169 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
|
7170 return; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7171 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7172 if(FD_ISSET(listenfd, &rd)) |
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 struct _seminfo *newarray; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7175 int newfd = accept(listenfd, 0, 0); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7176 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7177 if(newfd > -1) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7178 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7179 /* Add new connections to the set */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7180 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
|
7181 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
|
7182 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7183 newarray[connectcount].fd = newfd; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7184 newarray[connectcount].waiting = 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7185 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7186 connectcount++; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7187 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7188 /* Replace old array with new one */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7189 free(array); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7190 array = newarray; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7191 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7192 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7193 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7194 /* 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
|
7195 for(z=0;z<connectcount;z++) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7196 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7197 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
|
7198 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7199 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
|
7200 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7201 struct _seminfo *newarray; |
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 /* Remove this connection from the set */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7204 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
|
7205 if(!z) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7206 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
|
7207 else |
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 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
|
7210 if(z!=(connectcount-1)) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7211 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
|
7212 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7213 connectcount--; |
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 /* Replace old array with new one */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7216 free(array); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7217 array = newarray; |
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 else if(bytesread == 1) |
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 switch(command) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7222 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7223 case 0: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7224 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7225 /* Reset */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7226 posted = 0; |
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 break; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7229 case 1: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7230 /* Post */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7231 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7232 int s; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7233 char tmp = (char)0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7234 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7235 posted = 1; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7236 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7237 for(s=0;s<connectcount;s++) |
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 /* The semaphore has been posted so |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7240 * 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
|
7241 * continue. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7242 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7243 if(array[s].waiting) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7244 write(array[s].fd, &tmp, 1); |
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 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7247 break; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7248 case 2: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7249 /* Wait */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7250 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7251 char tmp = (char)0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7252 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7253 array[z].waiting = 1; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7254 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7255 /* If we are posted exit immeditately */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7256 if(posted) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7257 write(array[z].fd, &tmp, 1); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7258 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7259 break; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7260 case 3: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7261 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7262 /* Done Waiting */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7263 array[z].waiting = 0; |
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 break; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7266 } |
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 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7269 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7270 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7271 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7272 |
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 /* 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
|
7276 /* 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
|
7277 * opened from other processes. |
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: 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
|
7280 * 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
|
7281 * by other processes. |
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 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
|
7284 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7285 struct sockaddr_un un; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7286 int ev, *tmpsock = (int *)malloc(sizeof(int)*2); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7287 HEV eve; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7288 DWTID dwthread; |
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(!tmpsock) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7291 return NULL; |
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 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
|
7294 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7295 if(!eve) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7296 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7297 free(tmpsock); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7298 return NULL; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7299 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7300 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7301 tmpsock[0] = socket(AF_UNIX, SOCK_STREAM, 0); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7302 ev = socket(AF_UNIX, SOCK_STREAM, 0); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7303 memset(&un, 0, sizeof(un)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7304 un.sun_family=AF_UNIX; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7305 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
|
7306 strcpy(un.sun_path, "/tmp/.dw/"); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7307 strcat(un.sun_path, name); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7308 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7309 /* just to be safe, this should be changed |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7310 * to support multiple instances. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7311 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7312 remove(un.sun_path); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7313 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7314 bind(tmpsock[0], (struct sockaddr *)&un, sizeof(un)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7315 listen(tmpsock[0], 0); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7316 connect(ev, (struct sockaddr *)&un, sizeof(un)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7317 tmpsock[1] = accept(tmpsock[0], 0, 0); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7318 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7319 if(tmpsock[0] < 0 || tmpsock[1] < 0 || ev < 0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7320 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7321 if(tmpsock[0] > -1) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7322 close(tmpsock[0]); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7323 if(tmpsock[1] > -1) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7324 close(tmpsock[1]); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7325 if(ev > -1) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7326 close(ev); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7327 free(tmpsock); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7328 free(eve); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7329 return NULL; |
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 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7332 /* Create a thread to handle this event semaphore */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7333 pthread_create(&dwthread, NULL, (void *)_handle_sem, (void *)tmpsock); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7334 eve->alive = ev; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7335 return eve; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7336 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7337 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7338 /* 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
|
7339 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7340 * 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
|
7341 * 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
|
7342 * by other processes. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7343 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7344 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
|
7345 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7346 struct sockaddr_un un; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7347 HEV eve; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7348 int ev = socket(AF_UNIX, SOCK_STREAM, 0); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7349 if(ev < 0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7350 return NULL; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7351 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7352 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
|
7353 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7354 if(!eve) |
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 close(ev); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7357 return NULL; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7358 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7359 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7360 un.sun_family=AF_UNIX; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7361 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
|
7362 strcpy(un.sun_path, "/tmp/.dw/"); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7363 strcat(un.sun_path, name); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7364 connect(ev, (struct sockaddr *)&un, sizeof(un)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7365 eve->alive = ev; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7366 return eve; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7367 } |
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 /* 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
|
7370 * on this semaphore will block. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7371 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7372 * 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
|
7373 * an open or create call. |
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 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
|
7376 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7377 /* signal reset */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7378 char tmp = (char)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(!eve || eve->alive < 0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7381 return 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7382 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7383 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
|
7384 return 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7385 return 1; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7386 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7387 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7388 /* 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
|
7389 * 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
|
7390 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7391 * 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
|
7392 * an open or create call. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7393 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7394 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
|
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 /* signal post */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7398 char tmp = (char)1; |
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(!eve || eve->alive < 0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7401 return 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7402 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7403 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
|
7404 return 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7405 return 1; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7406 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7407 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7408 /* 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
|
7409 * 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
|
7410 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7411 * 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
|
7412 * an open or create call. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7413 * 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
|
7414 * or -1 if indefinite. |
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 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
|
7417 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7418 fd_set rd; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7419 struct timeval tv, *useme; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7420 int retval = 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7421 char tmp; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7422 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7423 if(!eve || eve->alive < 0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7424 return DW_ERROR_NON_INIT; |
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 /* Set the timout or infinite */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7427 if(timeout == -1) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7428 useme = NULL; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7429 else |
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 tv.tv_sec = timeout / 1000; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7432 tv.tv_usec = timeout % 1000; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7433 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7434 useme = &tv; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7435 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7436 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7437 FD_ZERO(&rd); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7438 FD_SET(eve->alive, &rd); |
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 /* Signal wait */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7441 tmp = (char)2; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7442 write(eve->alive, &tmp, 1); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7443 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7444 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
|
7445 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7446 /* Signal done waiting. */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7447 tmp = (char)3; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7448 write(eve->alive, &tmp, 1); |
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 if(retval == 0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7451 return DW_ERROR_TIMEOUT; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7452 else if(retval == -1) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7453 return DW_ERROR_INTERRUPT; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7454 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7455 /* 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
|
7456 * we don't loop endlessly. :) |
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 read(eve->alive, &tmp, 1); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7459 return 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7460 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7461 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7462 /* 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
|
7463 * 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
|
7464 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7465 * 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
|
7466 * an open or create call. |
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 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
|
7469 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7470 /* Finally close the domain socket, |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7471 * cleanup will continue in _handle_sem. |
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 if(eve) |
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 close(eve->alive); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7476 free(eve); |
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 return 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7479 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7480 |
697
830e1f3672b9
Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
696
diff
changeset
|
7481 #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
|
7482 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
|
7483 #endif |
830e1f3672b9
Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
696
diff
changeset
|
7484 |
830e1f3672b9
Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
696
diff
changeset
|
7485 /* 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
|
7486 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
|
7487 { |
830e1f3672b9
Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
696
diff
changeset
|
7488 #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
|
7489 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
|
7490 [pool drain]; |
698
e19f69a78f21
Fix for pool being removed and not just drained.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
697
diff
changeset
|
7491 pool = [[NSAutoreleasePool alloc] init]; |
e19f69a78f21
Fix for pool being removed and not just drained.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
697
diff
changeset
|
7492 pthread_setspecific(_dw_pool_key, pool); |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
7493 #endif |
697
830e1f3672b9
Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
696
diff
changeset
|
7494 } |
830e1f3672b9
Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
696
diff
changeset
|
7495 |
830e1f3672b9
Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
696
diff
changeset
|
7496 /* |
830e1f3672b9
Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
696
diff
changeset
|
7497 * Setup thread independent pools. |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7498 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7499 void _dwthreadstart(void *data) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7500 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7501 void (*threadfunc)(void *) = NULL; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7502 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
|
7503 /* 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
|
7504 #if !defined(GARBAGE_COLLECT) |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
7505 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
|
7506 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
|
7507 #endif |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
7508 |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7509 threadfunc = (void (*)(void *))tmp[0]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7510 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7511 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
|
7512 /* 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
|
7513 #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
|
7514 pool = pthread_getspecific(_dw_pool_key); |
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
|
7515 [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
|
7516 #endif |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7517 free(tmp); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7518 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7519 |
744
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
7520 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
|
7521 { |
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
7522 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
|
7523 { |
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
7524 [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
|
7525 } |
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
7526 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
|
7527 [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
|
7528 } |
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
7529 |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7530 /* |
697
830e1f3672b9
Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
696
diff
changeset
|
7531 * 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
|
7532 * Parameters: |
830e1f3672b9
Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
696
diff
changeset
|
7533 * 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
|
7534 * 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
|
7535 */ |
830e1f3672b9
Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
696
diff
changeset
|
7536 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
|
7537 { |
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
|
7538 /* 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
|
7539 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
|
7540 /* 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
|
7541 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
|
7542 /* 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
|
7543 #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
|
7544 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
|
7545 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
|
7546 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
|
7547 #endif |
830e1f3672b9
Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
696
diff
changeset
|
7548 /* 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
|
7549 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
|
7550 [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
|
7551 [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
|
7552 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
|
7553 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
|
7554 /* 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
|
7555 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
|
7556 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
|
7557 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
|
7558 /* 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
|
7559 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
|
7560 [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
|
7561 [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
|
7562 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
|
7563 } |
830e1f3672b9
Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
696
diff
changeset
|
7564 |
830e1f3672b9
Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
696
diff
changeset
|
7565 /* |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7566 * 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
|
7567 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7568 * 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
|
7569 * 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
|
7570 * 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
|
7571 * 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
|
7572 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7573 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
|
7574 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7575 char namebuf[1024]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7576 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
|
7577 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7578 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
|
7579 sprintf(namebuf, "/tmp/.dw/%s", name); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7580 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7581 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
|
7582 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7583 free(handle); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7584 return NULL; |
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 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7587 ftruncate(handle->fd, size); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7588 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7589 /* 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
|
7590 *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
|
7591 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7592 if(*dest == MAP_FAILED) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7593 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7594 close(handle->fd); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7595 *dest = NULL; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7596 free(handle); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7597 return NULL; |
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 handle->size = size; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7601 handle->sid = getsid(0); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7602 handle->path = strdup(namebuf); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7603 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7604 return handle; |
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 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7607 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7608 * 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
|
7609 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7610 * 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
|
7611 * 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
|
7612 * 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
|
7613 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7614 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
|
7615 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7616 char namebuf[1024]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7617 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
|
7618 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7619 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
|
7620 sprintf(namebuf, "/tmp/.dw/%s", name); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7621 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7622 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
|
7623 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7624 free(handle); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7625 return NULL; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7626 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7627 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7628 /* 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
|
7629 *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
|
7630 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7631 if(*dest == MAP_FAILED) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7632 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7633 close(handle->fd); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7634 *dest = NULL; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7635 free(handle); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7636 return NULL; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7637 } |
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 handle->size = size; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7640 handle->sid = -1; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7641 handle->path = NULL; |
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 return handle; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7644 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7645 |
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 * 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
|
7648 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7649 * 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
|
7650 * 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
|
7651 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7652 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
|
7653 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7654 struct _dw_unix_shm *h = handle; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7655 int rc = munmap(ptr, h->size); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7656 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7657 close(h->fd); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7658 if(h->path) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7659 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7660 /* 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
|
7661 * creator of the file. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7662 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7663 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
|
7664 remove(h->path); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7665 free(h->path); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7666 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7667 return rc; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7668 } |
697
830e1f3672b9
Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
696
diff
changeset
|
7669 |
650
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 * 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
|
7672 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7673 * 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
|
7674 * 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
|
7675 * 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
|
7676 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7677 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
|
7678 { |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
7679 DWTID thread; |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
7680 void **tmp = malloc(sizeof(void *) * 2); |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
7681 int rc; |
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 tmp[0] = func; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7684 tmp[1] = data; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7685 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7686 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
|
7687 if(rc == 0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7688 return thread; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7689 return (DWTID)-1; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7690 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7691 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7692 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7693 * Ends execution of current thread immediately. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7694 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7695 void dw_thread_end(void) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7696 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7697 pthread_exit(NULL); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7698 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7699 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7700 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7701 * Returns the current thread's ID. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7702 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7703 DWTID dw_thread_id(void) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7704 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7705 return (DWTID)pthread_self(); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7706 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7707 |
661
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7708 /* |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7709 * 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
|
7710 * Parameters: |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7711 * program: Program name with optional path. |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7712 * 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
|
7713 * 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
|
7714 * Returns: |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7715 * -1 on error. |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7716 */ |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7717 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
|
7718 { |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7719 int ret = -1; |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7720 |
738
52d5ed00f892
Use NSWorkplace to launch GUI applications instead of fork() and exec().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
737
diff
changeset
|
7721 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
|
7722 { |
52d5ed00f892
Use NSWorkplace to launch GUI applications instead of fork() and exec().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
737
diff
changeset
|
7723 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
|
7724 { |
52d5ed00f892
Use NSWorkplace to launch GUI applications instead of fork() and exec().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
737
diff
changeset
|
7725 [[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
|
7726 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
|
7727 } |
52d5ed00f892
Use NSWorkplace to launch GUI applications instead of fork() and exec().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
737
diff
changeset
|
7728 else |
52d5ed00f892
Use NSWorkplace to launch GUI applications instead of fork() and exec().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
737
diff
changeset
|
7729 { |
52d5ed00f892
Use NSWorkplace to launch GUI applications instead of fork() and exec().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
737
diff
changeset
|
7730 [[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
|
7731 } |
52d5ed00f892
Use NSWorkplace to launch GUI applications instead of fork() and exec().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
737
diff
changeset
|
7732 return 0; |
52d5ed00f892
Use NSWorkplace to launch GUI applications instead of fork() and exec().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
737
diff
changeset
|
7733 } |
52d5ed00f892
Use NSWorkplace to launch GUI applications instead of fork() and exec().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
737
diff
changeset
|
7734 |
661
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7735 if((ret = fork()) == 0) |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7736 { |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7737 int i; |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7738 |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7739 for (i = 3; i < 256; i++) |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7740 close(i); |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7741 setsid(); |
738
52d5ed00f892
Use NSWorkplace to launch GUI applications instead of fork() and exec().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
737
diff
changeset
|
7742 |
52d5ed00f892
Use NSWorkplace to launch GUI applications instead of fork() and exec().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
737
diff
changeset
|
7743 if(type == DW_EXEC_CON) |
661
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7744 { |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7745 char **tmpargs; |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7746 |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7747 if(!params) |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7748 { |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7749 tmpargs = malloc(sizeof(char *)); |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7750 tmpargs[0] = NULL; |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7751 } |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7752 else |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7753 { |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7754 int z = 0; |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7755 |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7756 while(params[z]) |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7757 { |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7758 z++; |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7759 } |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7760 tmpargs = malloc(sizeof(char *)*(z+3)); |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7761 z=0; |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7762 tmpargs[0] = "xterm"; |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7763 tmpargs[1] = "-e"; |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7764 while(params[z]) |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7765 { |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7766 tmpargs[z+2] = params[z]; |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7767 z++; |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7768 } |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7769 tmpargs[z+2] = NULL; |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7770 } |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7771 execvp("xterm", tmpargs); |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7772 free(tmpargs); |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7773 } |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7774 /* If we got here exec failed */ |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7775 _exit(-1); |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7776 } |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7777 return ret; |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7778 } |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7779 |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7780 /* |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7781 * 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
|
7782 * Parameters: |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7783 * url: Uniform resource locator. |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7784 */ |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7785 int dw_browse(char *url) |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
7786 { |
715
5f8102bd7646
dw_browse() reimplmented so it actually works as expected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
714
diff
changeset
|
7787 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
|
7788 [[NSWorkspace sharedWorkspace] openURL:myurl]; |
5f8102bd7646
dw_browse() reimplmented so it actually works as expected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
714
diff
changeset
|
7789 return 0; |
5f8102bd7646
dw_browse() reimplmented so it actually works as expected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
714
diff
changeset
|
7790 } |