Mercurial > dwindows
annotate mac/dw.m @ 919:2ab67f71b50f
I guess the retains aren't needed on the NSBitmapImageReps on the Mac.
This should fix the memory leak I think.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Fri, 22 Apr 2011 04:56:59 +0000 |
parents | 6b400a0f5f70 |
children | f47d5fa72f84 |
rev | line source |
---|---|
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2 * Dynamic Windows: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3 * A GTK like implementation of the MacOS GUI using Cocoa |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4 * |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5 * (C) 2011 Brian Smith <brian@dbsoft.org> |
721
56053f1af9ee
Fixes for dw_container/filessystem_get_column_type from Mark Hessling... adding him to the copyright section.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
720
diff
changeset
|
6 * (C) 2011 Mark Hessling <mark@rexx.org> |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7 * |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8 * Using garbage collection so requires 10.5 or later. |
671
c60a4f6cfae8
Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
670
diff
changeset
|
9 * clang -std=c99 -g -o dwtest -D__MAC__ -I. dwtest.c mac/dw.m -framework Cocoa -framework WebKit -fobjc-gc-only |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
10 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
11 #import <Cocoa/Cocoa.h> |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
12 #import <WebKit/WebKit.h> |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
13 #include "dw.h" |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
14 #include <sys/utsname.h> |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
15 #include <sys/socket.h> |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
16 #include <sys/un.h> |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
17 #include <sys/mman.h> |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
18 #include <sys/time.h> |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
19 #include <sys/stat.h> |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
20 |
719
d5e49ef8f541
Updated the #if for Snow Leopard/Leopard builds to handle them not being defined properly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
718
diff
changeset
|
21 /* Create a define to let us know to include Snow Leopard specific features */ |
d5e49ef8f541
Updated the #if for Snow Leopard/Leopard builds to handle them not being defined properly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
718
diff
changeset
|
22 #if defined(MAC_OS_X_VERSION_10_6) && ((defined(MAC_OS_X_VERSION_MIN_REQUIRED) && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6) || !defined(MAC_OS_X_VERSION_MIN_REQUIRED)) |
d5e49ef8f541
Updated the #if for Snow Leopard/Leopard builds to handle them not being defined properly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
718
diff
changeset
|
23 #define BUILDING_FOR_SNOW_LEOPARD |
d5e49ef8f541
Updated the #if for Snow Leopard/Leopard builds to handle them not being defined properly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
718
diff
changeset
|
24 #endif |
d5e49ef8f541
Updated the #if for Snow Leopard/Leopard builds to handle them not being defined properly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
718
diff
changeset
|
25 |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
26 /* Macros to protect access to thread unsafe classes */ |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
27 #define DW_MUTEX_LOCK { \ |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
28 if(DWThread != (DWTID)-1 && pthread_self() != DWThread && pthread_self() != _dw_mutex_locked) { \ |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
29 dw_mutex_lock(DWThreadMutex); \ |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
30 _dw_mutex_locked = pthread_self(); \ |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
31 dw_mutex_lock(DWThreadMutex2); \ |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
32 [DWObj performSelectorOnMainThread:@selector(synchronizeThread:) withObject:nil waitUntilDone:NO]; \ |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
33 dw_mutex_lock(DWRunMutex); \ |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
34 _locked_by_me = TRUE; } } |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
35 #define DW_MUTEX_UNLOCK { \ |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
36 if(pthread_self() != DWThread && _locked_by_me == TRUE) { \ |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
37 dw_mutex_unlock(DWRunMutex); \ |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
38 dw_mutex_unlock(DWThreadMutex2); \ |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
39 _dw_mutex_locked = (pthread_t)-1; \ |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
40 dw_mutex_unlock(DWThreadMutex); \ |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
41 _locked_by_me = FALSE; } } |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
42 |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
43 unsigned long _colors[] = |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
44 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
45 0x00000000, /* 0 black */ |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
46 0x000000bb, /* 1 red */ |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
47 0x0000bb00, /* 2 green */ |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
48 0x0000aaaa, /* 3 yellow */ |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
49 0x00cc0000, /* 4 blue */ |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
50 0x00bb00bb, /* 5 magenta */ |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
51 0x00bbbb00, /* 6 cyan */ |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
52 0x00bbbbbb, /* 7 white */ |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
53 0x00777777, /* 8 grey */ |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
54 0x000000ff, /* 9 bright red */ |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
55 0x0000ff00, /* 10 bright green */ |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
56 0x0000eeee, /* 11 bright yellow */ |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
57 0x00ff0000, /* 12 bright blue */ |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
58 0x00ff00ff, /* 13 bright magenta */ |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
59 0x00eeee00, /* 14 bright cyan */ |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
60 0x00ffffff, /* 15 bright white */ |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
61 0xff000000 /* 16 default color */ |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
62 }; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
63 |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
64 unsigned long _get_color(unsigned long thiscolor) |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
65 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
66 if(thiscolor & DW_RGB_COLOR) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
67 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
68 return thiscolor & ~DW_RGB_COLOR; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
69 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
70 else if(thiscolor < 17) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
71 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
72 return _colors[thiscolor]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
73 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
74 return 0; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
75 } |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
76 |
826
6bb8bff36548
Implemented thread specific colors. Allows threads to have their own colors... also reducing color object recreation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
825
diff
changeset
|
77 /* Thread specific storage */ |
6bb8bff36548
Implemented thread specific colors. Allows threads to have their own colors... also reducing color object recreation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
825
diff
changeset
|
78 #if !defined(GARBAGE_COLLECT) |
6bb8bff36548
Implemented thread specific colors. Allows threads to have their own colors... also reducing color object recreation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
825
diff
changeset
|
79 pthread_key_t _dw_pool_key; |
6bb8bff36548
Implemented thread specific colors. Allows threads to have their own colors... also reducing color object recreation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
825
diff
changeset
|
80 #endif |
6bb8bff36548
Implemented thread specific colors. Allows threads to have their own colors... also reducing color object recreation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
825
diff
changeset
|
81 pthread_key_t _dw_fg_color_key; |
6bb8bff36548
Implemented thread specific colors. Allows threads to have their own colors... also reducing color object recreation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
825
diff
changeset
|
82 pthread_key_t _dw_bg_color_key; |
6bb8bff36548
Implemented thread specific colors. Allows threads to have their own colors... also reducing color object recreation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
825
diff
changeset
|
83 |
6bb8bff36548
Implemented thread specific colors. Allows threads to have their own colors... also reducing color object recreation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
825
diff
changeset
|
84 /* Create a default colors for a thread */ |
6bb8bff36548
Implemented thread specific colors. Allows threads to have their own colors... also reducing color object recreation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
825
diff
changeset
|
85 void _init_colors(void) |
6bb8bff36548
Implemented thread specific colors. Allows threads to have their own colors... also reducing color object recreation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
825
diff
changeset
|
86 { |
6bb8bff36548
Implemented thread specific colors. Allows threads to have their own colors... also reducing color object recreation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
825
diff
changeset
|
87 NSColor *fgcolor = [[NSColor grayColor] retain]; |
6bb8bff36548
Implemented thread specific colors. Allows threads to have their own colors... also reducing color object recreation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
825
diff
changeset
|
88 |
6bb8bff36548
Implemented thread specific colors. Allows threads to have their own colors... also reducing color object recreation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
825
diff
changeset
|
89 pthread_setspecific(_dw_fg_color_key, fgcolor); |
891
3774af45eb0c
Fix for dw_draw_text() not using the background color on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
890
diff
changeset
|
90 pthread_setspecific(_dw_bg_color_key, NULL); |
826
6bb8bff36548
Implemented thread specific colors. Allows threads to have their own colors... also reducing color object recreation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
825
diff
changeset
|
91 } |
6bb8bff36548
Implemented thread specific colors. Allows threads to have their own colors... also reducing color object recreation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
825
diff
changeset
|
92 |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
93 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
|
94 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
95 struct _sighandler *next; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
96 ULONG message; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
97 HWND window; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
98 int id; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
99 void *signalfunction; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
100 void *data; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
101 |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
102 } SignalHandler; |
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 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
|
105 |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
106 /* Some internal prototypes */ |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
107 static void _do_resize(Box *thisbox, int x, int y); |
916
44a0f9a2e8f9
Experimental change, pulling the resize event handling out of the resizer code on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
915
diff
changeset
|
108 void _handle_resize_events(Box *thisbox); |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
109 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
|
110 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
|
111 |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
112 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
|
113 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
114 SignalHandler *tmp = Root; |
894
d1d7e5c51860
Added a DWWindow subclass to trap key events on the main window for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
891
diff
changeset
|
115 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
116 /* Find any callbacks for this function */ |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
117 while(tmp) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
118 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
119 if(tmp->message == messageid && window == tmp->window) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
120 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
121 return tmp; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
122 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
123 tmp = tmp->next; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
124 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
125 return NULL; |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
126 } |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
127 |
703
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
128 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
|
129 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
130 ULONG message; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
131 char name[30]; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
132 |
703
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
133 } SignalList; |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
134 |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
135 /* List of signals */ |
803
8555ac1bcbcd
Attempt at implementing column click events. Doesn't seem to work yet but needed to commit before switching to laptop.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
802
diff
changeset
|
136 #define SIGNALMAX 17 |
703
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
137 |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
138 SignalList SignalTranslate[SIGNALMAX] = { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
139 { 1, DW_SIGNAL_CONFIGURE }, |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
140 { 2, DW_SIGNAL_KEY_PRESS }, |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
141 { 3, DW_SIGNAL_BUTTON_PRESS }, |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
142 { 4, DW_SIGNAL_BUTTON_RELEASE }, |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
143 { 5, DW_SIGNAL_MOTION_NOTIFY }, |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
144 { 6, DW_SIGNAL_DELETE }, |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
145 { 7, DW_SIGNAL_EXPOSE }, |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
146 { 8, DW_SIGNAL_CLICKED }, |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
147 { 9, DW_SIGNAL_ITEM_ENTER }, |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
148 { 10, DW_SIGNAL_ITEM_CONTEXT }, |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
149 { 11, DW_SIGNAL_LIST_SELECT }, |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
150 { 12, DW_SIGNAL_ITEM_SELECT }, |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
151 { 13, DW_SIGNAL_SET_FOCUS }, |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
152 { 14, DW_SIGNAL_VALUE_CHANGED }, |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
153 { 15, DW_SIGNAL_SWITCH_PAGE }, |
803
8555ac1bcbcd
Attempt at implementing column click events. Doesn't seem to work yet but needed to commit before switching to laptop.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
802
diff
changeset
|
154 { 16, DW_SIGNAL_TREE_EXPAND }, |
8555ac1bcbcd
Attempt at implementing column click events. Doesn't seem to work yet but needed to commit before switching to laptop.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
802
diff
changeset
|
155 { 17, DW_SIGNAL_COLUMN_CLICK } |
703
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
156 }; |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
157 |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
158 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
|
159 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
160 SignalHandler *handler = _get_handler(object, message); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
161 /* NSLog(@"Event handler - type %d\n", message); */ |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
162 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
163 if(handler) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
164 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
165 switch(message) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
166 { |
703
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
167 /* Timer event */ |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
168 case 0: |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
169 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
170 int (* API timerfunc)(void *) = (int (* API)(void *))handler->signalfunction; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
171 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
172 if(!timerfunc(handler->data)) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
173 dw_timer_disconnect(handler->id); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
174 return 0; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
175 } |
703
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
176 /* Configure/Resize event */ |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
177 case 1: |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
178 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
179 int (*sizefunc)(HWND, int, int, void *) = handler->signalfunction; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
180 NSSize size; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
181 |
894
d1d7e5c51860
Added a DWWindow subclass to trap key events on the main window for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
891
diff
changeset
|
182 if([object isKindOfClass:[NSWindow class]]) |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
183 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
184 NSWindow *window = object; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
185 size = [[window contentView] frame].size; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
186 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
187 else |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
188 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
189 NSView *view = object; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
190 size = [view frame].size; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
191 } |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
192 |
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
|
193 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
|
194 { |
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
|
195 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
|
196 } |
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
|
197 return 0; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
198 } |
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
|
199 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
|
200 { |
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
|
201 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
|
202 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
|
203 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
|
204 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
|
205 char ch = '\0'; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
206 |
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
|
207 /* 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
|
208 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
|
209 { |
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
|
210 const char *tmp = [nchar UTF8String]; |
899
3fbba8b1f440
Don't pass in a partial UTF8 string in the character field during key press events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
898
diff
changeset
|
211 if(tmp && strlen(tmp) == 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
|
212 { |
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
|
213 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
|
214 } |
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
|
215 } |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
216 |
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
|
217 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
|
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 /* Button press and release event */ |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
220 case 3: |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
221 case 4: |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
222 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
223 int (* API buttonfunc)(HWND, int, int, int, void *) = (int (* API)(HWND, int, int, int, void *))handler->signalfunction; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
224 int button = (int)event; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
225 LONG x,y; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
226 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
227 dw_pointer_query_pos(&x, &y); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
228 |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
229 return buttonfunc(object, (int)x, (int)y, button, handler->data); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
230 } |
886
d94a4fa0359e
Implemented the motion notify event on Mac. Most of it was there except the event handler.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
882
diff
changeset
|
231 /* Motion notify event */ |
d94a4fa0359e
Implemented the motion notify event on Mac. Most of it was there except the event handler.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
882
diff
changeset
|
232 case 5: |
d94a4fa0359e
Implemented the motion notify event on Mac. Most of it was there except the event handler.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
882
diff
changeset
|
233 { |
d94a4fa0359e
Implemented the motion notify event on Mac. Most of it was there except the event handler.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
882
diff
changeset
|
234 int (* API motionfunc)(HWND, int, int, int, void *) = (int (* API)(HWND, int, int, int, void *))handler->signalfunction; |
d94a4fa0359e
Implemented the motion notify event on Mac. Most of it was there except the event handler.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
882
diff
changeset
|
235 int buttonmask = (int)[NSEvent pressedMouseButtons]; |
d94a4fa0359e
Implemented the motion notify event on Mac. Most of it was there except the event handler.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
882
diff
changeset
|
236 NSPoint point = [NSEvent mouseLocation]; |
d94a4fa0359e
Implemented the motion notify event on Mac. Most of it was there except the event handler.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
882
diff
changeset
|
237 |
d94a4fa0359e
Implemented the motion notify event on Mac. Most of it was there except the event handler.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
882
diff
changeset
|
238 return motionfunc(object, (int)point.x, (int)point.y, buttonmask, handler->data); |
d94a4fa0359e
Implemented the motion notify event on Mac. Most of it was there except the event handler.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
882
diff
changeset
|
239 } |
703
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
240 /* Window close event */ |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
241 case 6: |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
242 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
243 int (* API closefunc)(HWND, void *) = (int (* API)(HWND, void *))handler->signalfunction; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
244 return closefunc(object, handler->data); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
245 } |
703
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
246 /* Window expose/draw event */ |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
247 case 7: |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
248 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
249 DWExpose exp; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
250 int (* API exposefunc)(HWND, DWExpose *, void *) = (int (* API)(HWND, DWExpose *, void *))handler->signalfunction; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
251 NSRect rect = [object frame]; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
252 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
253 exp.x = rect.origin.x; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
254 exp.y = rect.origin.y; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
255 exp.width = rect.size.width; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
256 exp.height = rect.size.height; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
257 int result = exposefunc(object, &exp, handler->data); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
258 [[object window] flushWindow]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
259 return result; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
260 } |
703
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
261 /* Clicked event for buttons and menu items */ |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
262 case 8: |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
263 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
264 int (* API clickfunc)(HWND, void *) = (int (* API)(HWND, void *))handler->signalfunction; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
265 |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
266 return clickfunc(object, handler->data); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
267 } |
703
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
268 /* 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
|
269 case 9: |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
270 { |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
271 int (*containerselectfunc)(HWND, char *, void *) = handler->signalfunction; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
272 |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
273 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
|
274 } |
703
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
275 /* Container context menu event */ |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
276 case 10: |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
277 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
278 int (* API containercontextfunc)(HWND, char *, int, int, void *, void *) = (int (* API)(HWND, char *, int, int, void *, void *))handler->signalfunction; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
279 char *text = (char *)event; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
280 void *user = NULL; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
281 LONG x,y; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
282 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
283 dw_pointer_query_pos(&x, &y); |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
284 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
285 return containercontextfunc(handler->window, text, (int)x, (int)y, handler->data, user); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
286 } |
703
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
287 /* 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
|
288 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
|
289 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
|
290 { |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
291 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
|
292 int selected = (int)event; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
293 |
703
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
294 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
|
295 } |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
296 /* Tree class selection event */ |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
297 case 12: |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
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 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
|
300 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
|
301 void *user = NULL; |
5a268d5f1cfa
Fixes for tree event handling. Still more to come shortly...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
708
diff
changeset
|
302 id item = nil; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
303 |
710
78460ff977c1
Finishing up tree event/signal handlers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
709
diff
changeset
|
304 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
|
305 { |
5a268d5f1cfa
Fixes for tree event handling. Still more to come shortly...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
708
diff
changeset
|
306 item = (id)event; |
5a268d5f1cfa
Fixes for tree event handling. Still more to come shortly...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
708
diff
changeset
|
307 NSString *nstr = [item pointerAtIndex:1]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
308 |
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
|
309 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
|
310 { |
01107d8e033e
Fixed the scrollbar maximum range to be correct. Also added some MLE code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
711
diff
changeset
|
311 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
|
312 } |
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
|
313 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
|
314 { |
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
|
315 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
|
316 } |
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
|
317 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
|
318 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
|
319 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
|
320 { |
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
|
321 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
|
322 } |
709
5a268d5f1cfa
Fixes for tree event handling. Still more to come shortly...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
708
diff
changeset
|
323 return result; |
5a268d5f1cfa
Fixes for tree event handling. Still more to come shortly...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
708
diff
changeset
|
324 } |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
325 |
709
5a268d5f1cfa
Fixes for tree event handling. Still more to come shortly...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
708
diff
changeset
|
326 return treeselectfunc(handler->window, item, text, handler->data, user); |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
327 } |
703
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
328 /* 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
|
329 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
|
330 { |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
331 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
|
332 |
703
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
333 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
|
334 } |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
335 /* 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
|
336 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
|
337 { |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
338 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
|
339 int pageid = (int)event; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
340 |
703
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
341 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
|
342 } |
722
5a8d5161651d
Implemented tree expand event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
721
diff
changeset
|
343 case 16: |
5a8d5161651d
Implemented tree expand event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
721
diff
changeset
|
344 { |
5a8d5161651d
Implemented tree expand event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
721
diff
changeset
|
345 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
|
346 |
722
5a8d5161651d
Implemented tree expand event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
721
diff
changeset
|
347 return treeexpandfunc(handler->window, (HTREEITEM)event, handler->data); |
5a8d5161651d
Implemented tree expand event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
721
diff
changeset
|
348 } |
803
8555ac1bcbcd
Attempt at implementing column click events. Doesn't seem to work yet but needed to commit before switching to laptop.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
802
diff
changeset
|
349 case 17: |
8555ac1bcbcd
Attempt at implementing column click events. Doesn't seem to work yet but needed to commit before switching to laptop.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
802
diff
changeset
|
350 { |
8555ac1bcbcd
Attempt at implementing column click events. Doesn't seem to work yet but needed to commit before switching to laptop.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
802
diff
changeset
|
351 int (*clickcolumnfunc)(HWND, int, void *) = handler->signalfunction; |
8555ac1bcbcd
Attempt at implementing column click events. Doesn't seem to work yet but needed to commit before switching to laptop.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
802
diff
changeset
|
352 int column_num = (int)event; |
8555ac1bcbcd
Attempt at implementing column click events. Doesn't seem to work yet but needed to commit before switching to laptop.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
802
diff
changeset
|
353 |
8555ac1bcbcd
Attempt at implementing column click events. Doesn't seem to work yet but needed to commit before switching to laptop.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
802
diff
changeset
|
354 return clickcolumnfunc(handler->window, column_num, handler->data); |
8555ac1bcbcd
Attempt at implementing column click events. Doesn't seem to work yet but needed to commit before switching to laptop.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
802
diff
changeset
|
355 } |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
356 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
357 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
358 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
|
359 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
360 |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
361 /* Subclass for the Timer type */ |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
362 @interface DWTimerHandler : NSObject { } |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
363 -(void)runTimer:(id)sender; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
364 @end |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
365 |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
366 @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
|
367 -(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
|
368 @end |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
369 |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
370 NSApplication *DWApp; |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
371 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
|
372 NSFont *DWDefaultFont; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
373 DWTimerHandler *DWHandler; |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
374 #if !defined(GARBAGE_COLLECT) |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
375 NSAutoreleasePool *pool; |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
376 #endif |
661
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
377 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
|
378 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
|
379 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
|
380 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
|
381 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
|
382 DWTID _dw_mutex_locked = (DWTID)-1; |
754
0d0dc78c589d
Clang complains about the types I used for the OS version.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
753
diff
changeset
|
383 SInt32 DWOSMajor, DWOSMinor, DWOSBuild; |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
384 |
699
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
385 /* 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
|
386 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
|
387 { |
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
388 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
|
389 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
|
390 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
|
391 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
|
392 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
|
393 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
|
394 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
|
395 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
|
396 } DWBitBlt; |
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
397 |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
398 /* 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
|
399 @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
|
400 -(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
|
401 -(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
|
402 -(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
|
403 -(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
|
404 @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
|
405 |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
406 @implementation DWObject |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
407 -(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
|
408 -(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
|
409 { |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
410 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
|
411 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
|
412 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
|
413 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
|
414 } |
699
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
415 -(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
|
416 { |
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
417 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
|
418 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
|
419 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
|
420 id bltsrc = bltinfo->src; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
421 |
909
c092eab43ae3
Experimental change to pixmap rendering. Switch from using NSImage to NSBitmapImageRef to store the image.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
902
diff
changeset
|
422 if([bltdest isMemberOfClass:[NSBitmapImageRep class]]) |
c092eab43ae3
Experimental change to pixmap rendering. Switch from using NSImage to NSBitmapImageRef to store the image.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
902
diff
changeset
|
423 { |
c092eab43ae3
Experimental change to pixmap rendering. Switch from using NSImage to NSBitmapImageRef to store the image.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
902
diff
changeset
|
424 [NSGraphicsContext saveGraphicsState]; |
c092eab43ae3
Experimental change to pixmap rendering. Switch from using NSImage to NSBitmapImageRef to store the image.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
902
diff
changeset
|
425 [NSGraphicsContext setCurrentContext:[NSGraphicsContext |
915
361d80388dc9
Test fix at the partial bitblt issue on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
911
diff
changeset
|
426 graphicsContextWithGraphicsPort:[[NSGraphicsContext graphicsContextWithBitmapImageRep:bltdest] graphicsPort] flipped:YES]]; |
909
c092eab43ae3
Experimental change to pixmap rendering. Switch from using NSImage to NSBitmapImageRef to store the image.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
902
diff
changeset
|
427 [[NSDictionary alloc] initWithObjectsAndKeys:bltdest, NSGraphicsContextDestinationAttributeName, nil]; |
699
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
428 } |
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
429 else |
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
430 { |
747
a4f99795ff26
Abort drawing functions if we fail to lock focus on a render control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
745
diff
changeset
|
431 if([bltdest lockFocusIfCanDraw] == NO) |
a4f99795ff26
Abort drawing functions if we fail to lock focus on a render control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
745
diff
changeset
|
432 { |
917
8567c9ac089d
Switched back to using the dealloc() method in dw_pixmap_destroy() to stop a memory leak on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
916
diff
changeset
|
433 free(bltinfo); |
747
a4f99795ff26
Abort drawing functions if we fail to lock focus on a render control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
745
diff
changeset
|
434 return; |
a4f99795ff26
Abort drawing functions if we fail to lock focus on a render control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
745
diff
changeset
|
435 } |
699
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
436 _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
|
437 } |
909
c092eab43ae3
Experimental change to pixmap rendering. Switch from using NSImage to NSBitmapImageRef to store the image.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
902
diff
changeset
|
438 if([bltsrc isMemberOfClass:[NSBitmapImageRep class]]) |
c092eab43ae3
Experimental change to pixmap rendering. Switch from using NSImage to NSBitmapImageRef to store the image.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
902
diff
changeset
|
439 { |
910
329f2ca62f1b
Switched to using a different potentially slower NSImage conversion to support Leopard.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
909
diff
changeset
|
440 NSBitmapImageRep *rep = bltsrc; |
329f2ca62f1b
Switched to using a different potentially slower NSImage conversion to support Leopard.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
909
diff
changeset
|
441 NSImage *image; |
329f2ca62f1b
Switched to using a different potentially slower NSImage conversion to support Leopard.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
909
diff
changeset
|
442 |
329f2ca62f1b
Switched to using a different potentially slower NSImage conversion to support Leopard.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
909
diff
changeset
|
443 if(DWOSMinor > 5) |
329f2ca62f1b
Switched to using a different potentially slower NSImage conversion to support Leopard.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
909
diff
changeset
|
444 { |
329f2ca62f1b
Switched to using a different potentially slower NSImage conversion to support Leopard.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
909
diff
changeset
|
445 image = [[NSImage alloc] initWithCGImage:[rep CGImage] size:NSZeroSize]; |
329f2ca62f1b
Switched to using a different potentially slower NSImage conversion to support Leopard.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
909
diff
changeset
|
446 } |
329f2ca62f1b
Switched to using a different potentially slower NSImage conversion to support Leopard.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
909
diff
changeset
|
447 else |
329f2ca62f1b
Switched to using a different potentially slower NSImage conversion to support Leopard.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
909
diff
changeset
|
448 { |
329f2ca62f1b
Switched to using a different potentially slower NSImage conversion to support Leopard.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
909
diff
changeset
|
449 image = [[NSImage alloc] initWithSize:[rep size]]; |
329f2ca62f1b
Switched to using a different potentially slower NSImage conversion to support Leopard.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
909
diff
changeset
|
450 [image addRepresentation:rep]; |
329f2ca62f1b
Switched to using a different potentially slower NSImage conversion to support Leopard.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
909
diff
changeset
|
451 } |
909
c092eab43ae3
Experimental change to pixmap rendering. Switch from using NSImage to NSBitmapImageRef to store the image.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
902
diff
changeset
|
452 // make a new transform: |
c092eab43ae3
Experimental change to pixmap rendering. Switch from using NSImage to NSBitmapImageRef to store the image.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
902
diff
changeset
|
453 NSAffineTransform *t = [NSAffineTransform transform]; |
c092eab43ae3
Experimental change to pixmap rendering. Switch from using NSImage to NSBitmapImageRef to store the image.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
902
diff
changeset
|
454 |
c092eab43ae3
Experimental change to pixmap rendering. Switch from using NSImage to NSBitmapImageRef to store the image.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
902
diff
changeset
|
455 // by scaling Y negatively, we effectively flip the image: |
c092eab43ae3
Experimental change to pixmap rendering. Switch from using NSImage to NSBitmapImageRef to store the image.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
902
diff
changeset
|
456 [t scaleXBy:1.0 yBy:-1.0]; |
c092eab43ae3
Experimental change to pixmap rendering. Switch from using NSImage to NSBitmapImageRef to store the image.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
902
diff
changeset
|
457 |
c092eab43ae3
Experimental change to pixmap rendering. Switch from using NSImage to NSBitmapImageRef to store the image.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
902
diff
changeset
|
458 // but we also have to translate it back by its height: |
915
361d80388dc9
Test fix at the partial bitblt issue on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
911
diff
changeset
|
459 [t translateXBy:0.0 yBy:-[rep size].height]; |
909
c092eab43ae3
Experimental change to pixmap rendering. Switch from using NSImage to NSBitmapImageRef to store the image.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
902
diff
changeset
|
460 |
c092eab43ae3
Experimental change to pixmap rendering. Switch from using NSImage to NSBitmapImageRef to store the image.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
902
diff
changeset
|
461 // apply the transform: |
c092eab43ae3
Experimental change to pixmap rendering. Switch from using NSImage to NSBitmapImageRef to store the image.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
902
diff
changeset
|
462 [t concat]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
463 [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
|
464 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
|
465 [bltsrc release]; |
909
c092eab43ae3
Experimental change to pixmap rendering. Switch from using NSImage to NSBitmapImageRef to store the image.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
902
diff
changeset
|
466 [image release]; |
c092eab43ae3
Experimental change to pixmap rendering. Switch from using NSImage to NSBitmapImageRef to store the image.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
902
diff
changeset
|
467 } |
c092eab43ae3
Experimental change to pixmap rendering. Switch from using NSImage to NSBitmapImageRef to store the image.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
902
diff
changeset
|
468 if([bltdest isMemberOfClass:[NSBitmapImageRep class]]) |
c092eab43ae3
Experimental change to pixmap rendering. Switch from using NSImage to NSBitmapImageRef to store the image.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
902
diff
changeset
|
469 { |
c092eab43ae3
Experimental change to pixmap rendering. Switch from using NSImage to NSBitmapImageRef to store the image.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
902
diff
changeset
|
470 [NSGraphicsContext restoreGraphicsState]; |
c092eab43ae3
Experimental change to pixmap rendering. Switch from using NSImage to NSBitmapImageRef to store the image.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
902
diff
changeset
|
471 } |
c092eab43ae3
Experimental change to pixmap rendering. Switch from using NSImage to NSBitmapImageRef to store the image.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
902
diff
changeset
|
472 else |
c092eab43ae3
Experimental change to pixmap rendering. Switch from using NSImage to NSBitmapImageRef to store the image.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
902
diff
changeset
|
473 { |
c092eab43ae3
Experimental change to pixmap rendering. Switch from using NSImage to NSBitmapImageRef to store the image.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
902
diff
changeset
|
474 [bltdest unlockFocus]; |
c092eab43ae3
Experimental change to pixmap rendering. Switch from using NSImage to NSBitmapImageRef to store the image.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
902
diff
changeset
|
475 } |
699
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
476 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
|
477 } |
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
478 -(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
|
479 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
480 if(_DWLastDrawable) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
481 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
482 id object = _DWLastDrawable; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
483 NSWindow *window = [object window]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
484 [window flushWindow]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
485 } |
699
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
486 } |
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
|
487 -(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
|
488 { |
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
|
489 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
|
490 void **params = (void **)[v pointerValue]; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
491 void (* windowfunc)(void *); |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
492 |
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
|
493 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
|
494 { |
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
|
495 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
|
496 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
|
497 { |
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
|
498 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
|
499 } |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
500 } |
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
|
501 } |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
502 @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
|
503 |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
504 DWObject *DWObj; |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
505 |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
506 /* 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
|
507 * 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
|
508 * basically everything. Was hoping to add methods |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
509 * 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
|
510 * 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
|
511 * going to work. -Brian |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
512 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
513 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
514 /* Subclass for a box type */ |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
515 @interface DWBox : NSView |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
516 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
517 Box *box; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
518 void *userdata; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
519 NSColor *bgcolor; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
520 } |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
521 -(id)init; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
522 -(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
|
523 -(Box *)box; |
792
fc6a626a96cc
Initial groupbox support. Sizing of the content frame is not quite right yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
768
diff
changeset
|
524 -(id)contentView; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
525 -(void *)userdata; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
526 -(void)setUserdata:(void *)input; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
527 -(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
|
528 -(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
|
529 -(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
|
530 -(void)mouseUp:(NSEvent *)theEvent; |
701
c91a1b345f2e
Fix for button press and context menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
700
diff
changeset
|
531 -(NSMenu *)menuForEvent:(NSEvent *)theEvent; |
c91a1b345f2e
Fix for button press and context menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
700
diff
changeset
|
532 -(void)rightMouseUp:(NSEvent *)theEvent; |
c91a1b345f2e
Fix for button press and context menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
700
diff
changeset
|
533 -(void)otherMouseDown:(NSEvent *)theEvent; |
c91a1b345f2e
Fix for button press and context menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
700
diff
changeset
|
534 -(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
|
535 -(void)keyDown:(NSEvent *)theEvent; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
536 -(void)setColor:(unsigned long)input; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
537 @end |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
538 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
539 @implementation DWBox |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
540 -(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
|
541 { |
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
542 self = [super init]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
543 |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
544 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
|
545 { |
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
546 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
|
547 } |
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
548 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
|
549 } |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
550 -(void)dealloc |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
551 { |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
552 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
|
553 free(box); |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
554 _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
|
555 [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
|
556 } |
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
557 -(Box *)box { return box; } |
792
fc6a626a96cc
Initial groupbox support. Sizing of the content frame is not quite right yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
768
diff
changeset
|
558 -(id)contentView { return self; } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
559 -(void *)userdata { return userdata; } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
560 -(void)setUserdata:(void *)input { userdata = input; } |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
561 -(void)drawRect:(NSRect)rect |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
562 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
563 if(bgcolor) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
564 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
565 [bgcolor set]; |
755
f574028932cc
Fix for crash when changing background colors, needed retain and release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
754
diff
changeset
|
566 NSRectFill([self bounds]); |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
567 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
568 } |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
569 -(BOOL)isFlipped { return YES; } |
701
c91a1b345f2e
Fix for button press and context menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
700
diff
changeset
|
570 -(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
|
571 -(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
|
572 -(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
|
573 -(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
|
574 -(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
|
575 -(void)otherMouseUp:(NSEvent *)theEvent { _event_handler(self, (void *)3, 4); } |
894
d1d7e5c51860
Added a DWWindow subclass to trap key events on the main window for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
891
diff
changeset
|
576 -(void)keyDown:(NSEvent *)theEvent { _event_handler(self, theEvent, 2); } |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
577 -(void)setColor:(unsigned long)input |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
578 { |
755
f574028932cc
Fix for crash when changing background colors, needed retain and release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
754
diff
changeset
|
579 id orig = bgcolor; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
580 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
581 if(input == _colors[DW_CLR_DEFAULT]) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
582 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
583 bgcolor = nil; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
584 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
585 else |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
586 { |
755
f574028932cc
Fix for crash when changing background colors, needed retain and release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
754
diff
changeset
|
587 bgcolor = [[NSColor colorWithDeviceRed: DW_RED_VALUE(input)/255.0 green: DW_GREEN_VALUE(input)/255.0 blue: DW_BLUE_VALUE(input)/255.0 alpha: 1] retain]; |
812
f8bfb19090f9
dw_window_set_color() now affects boxes immediately (no longer on the next window refresh).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
811
diff
changeset
|
588 [bgcolor set]; |
f8bfb19090f9
dw_window_set_color() now affects boxes immediately (no longer on the next window refresh).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
811
diff
changeset
|
589 NSRectFill([self bounds]); |
f8bfb19090f9
dw_window_set_color() now affects boxes immediately (no longer on the next window refresh).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
811
diff
changeset
|
590 [self setNeedsDisplay:YES]; |
755
f574028932cc
Fix for crash when changing background colors, needed retain and release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
754
diff
changeset
|
591 } |
f574028932cc
Fix for crash when changing background colors, needed retain and release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
754
diff
changeset
|
592 [orig release]; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
593 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
594 @end |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
595 |
792
fc6a626a96cc
Initial groupbox support. Sizing of the content frame is not quite right yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
768
diff
changeset
|
596 /* Subclass for a group box type */ |
fc6a626a96cc
Initial groupbox support. Sizing of the content frame is not quite right yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
768
diff
changeset
|
597 @interface DWGroupBox : NSBox |
fc6a626a96cc
Initial groupbox support. Sizing of the content frame is not quite right yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
768
diff
changeset
|
598 { |
fc6a626a96cc
Initial groupbox support. Sizing of the content frame is not quite right yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
768
diff
changeset
|
599 void *userdata; |
fc6a626a96cc
Initial groupbox support. Sizing of the content frame is not quite right yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
768
diff
changeset
|
600 NSColor *bgcolor; |
fc6a626a96cc
Initial groupbox support. Sizing of the content frame is not quite right yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
768
diff
changeset
|
601 } |
fc6a626a96cc
Initial groupbox support. Sizing of the content frame is not quite right yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
768
diff
changeset
|
602 -(Box *)box; |
fc6a626a96cc
Initial groupbox support. Sizing of the content frame is not quite right yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
768
diff
changeset
|
603 -(void *)userdata; |
fc6a626a96cc
Initial groupbox support. Sizing of the content frame is not quite right yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
768
diff
changeset
|
604 -(void)setUserdata:(void *)input; |
fc6a626a96cc
Initial groupbox support. Sizing of the content frame is not quite right yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
768
diff
changeset
|
605 @end |
fc6a626a96cc
Initial groupbox support. Sizing of the content frame is not quite right yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
768
diff
changeset
|
606 |
fc6a626a96cc
Initial groupbox support. Sizing of the content frame is not quite right yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
768
diff
changeset
|
607 @implementation DWGroupBox |
fc6a626a96cc
Initial groupbox support. Sizing of the content frame is not quite right yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
768
diff
changeset
|
608 -(Box *)box { return [[self contentView] box]; } |
fc6a626a96cc
Initial groupbox support. Sizing of the content frame is not quite right yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
768
diff
changeset
|
609 -(void *)userdata { return userdata; } |
fc6a626a96cc
Initial groupbox support. Sizing of the content frame is not quite right yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
768
diff
changeset
|
610 -(void)setUserdata:(void *)input { userdata = input; } |
fc6a626a96cc
Initial groupbox support. Sizing of the content frame is not quite right yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
768
diff
changeset
|
611 @end |
fc6a626a96cc
Initial groupbox support. Sizing of the content frame is not quite right yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
768
diff
changeset
|
612 |
894
d1d7e5c51860
Added a DWWindow subclass to trap key events on the main window for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
891
diff
changeset
|
613 @interface DWWindow : NSWindow |
898
bf2ca780f62d
One more try at window key handling... since I can't seem to trap keyDown events in most places that get focus...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
895
diff
changeset
|
614 -(void)sendEvent:(NSEvent *)theEvent; |
894
d1d7e5c51860
Added a DWWindow subclass to trap key events on the main window for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
891
diff
changeset
|
615 -(void)keyDown:(NSEvent *)theEvent; |
d1d7e5c51860
Added a DWWindow subclass to trap key events on the main window for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
891
diff
changeset
|
616 @end |
d1d7e5c51860
Added a DWWindow subclass to trap key events on the main window for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
891
diff
changeset
|
617 |
d1d7e5c51860
Added a DWWindow subclass to trap key events on the main window for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
891
diff
changeset
|
618 @implementation DWWindow |
898
bf2ca780f62d
One more try at window key handling... since I can't seem to trap keyDown events in most places that get focus...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
895
diff
changeset
|
619 -(void)sendEvent:(NSEvent *)theEvent { if([theEvent type] == NSKeyDown) { _event_handler(self, theEvent, 2); } [super sendEvent:theEvent]; } |
bf2ca780f62d
One more try at window key handling... since I can't seem to trap keyDown events in most places that get focus...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
895
diff
changeset
|
620 -(void)keyDown:(NSEvent *)theEvent { } |
894
d1d7e5c51860
Added a DWWindow subclass to trap key events on the main window for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
891
diff
changeset
|
621 @end |
d1d7e5c51860
Added a DWWindow subclass to trap key events on the main window for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
891
diff
changeset
|
622 |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
623 /* Subclass for a top-level window */ |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
624 @interface DWView : DWBox |
854
d44bb4c4902d
Fixed an error on the close event handler on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
853
diff
changeset
|
625 #ifdef BUILDING_FOR_SNOW_LEOPARD |
d44bb4c4902d
Fixed an error on the close event handler on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
853
diff
changeset
|
626 <NSWindowDelegate> |
d44bb4c4902d
Fixed an error on the close event handler on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
853
diff
changeset
|
627 #endif |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
628 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
629 NSMenu *windowmenu; |
916
44a0f9a2e8f9
Experimental change, pulling the resize event handling out of the resizer code on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
915
diff
changeset
|
630 NSSize oldsize; |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
631 } |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
632 -(BOOL)windowShouldClose:(id)sender; |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
633 -(void)setMenu:(NSMenu *)input; |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
634 -(void)windowDidBecomeMain:(id)sender; |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
635 -(void)menuHandler:(id)sender; |
886
d94a4fa0359e
Implemented the motion notify event on Mac. Most of it was there except the event handler.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
882
diff
changeset
|
636 -(void)mouseMoved:(NSEvent *)theEvent; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
637 @end |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
638 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
639 @implementation DWView |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
640 -(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
|
641 { |
854
d44bb4c4902d
Fixed an error on the close event handler on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
853
diff
changeset
|
642 if(_event_handler(sender, nil, 6) == FALSE) |
d44bb4c4902d
Fixed an error on the close event handler on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
853
diff
changeset
|
643 return YES; |
d44bb4c4902d
Fixed an error on the close event handler on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
853
diff
changeset
|
644 return NO; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
645 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
646 - (void)viewDidMoveToWindow |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
647 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
648 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(windowResized:) name:NSWindowDidResizeNotification object:[self window]]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
649 [[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
|
650 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
651 - (void)dealloc |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
652 { |
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
|
653 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
|
654 { |
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
|
655 [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
|
656 } |
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
|
657 [[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
|
658 [super dealloc]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
659 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
660 - (void)windowResized:(NSNotification *)notification; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
661 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
662 NSSize size = [self frame].size; |
916
44a0f9a2e8f9
Experimental change, pulling the resize event handling out of the resizer code on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
915
diff
changeset
|
663 |
44a0f9a2e8f9
Experimental change, pulling the resize event handling out of the resizer code on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
915
diff
changeset
|
664 if(oldsize.width != size.width || oldsize.height != size.height) |
44a0f9a2e8f9
Experimental change, pulling the resize event handling out of the resizer code on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
915
diff
changeset
|
665 { |
44a0f9a2e8f9
Experimental change, pulling the resize event handling out of the resizer code on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
915
diff
changeset
|
666 _do_resize(box, size.width, size.height); |
44a0f9a2e8f9
Experimental change, pulling the resize event handling out of the resizer code on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
915
diff
changeset
|
667 _do_resize(box, size.width, size.height); |
44a0f9a2e8f9
Experimental change, pulling the resize event handling out of the resizer code on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
915
diff
changeset
|
668 _event_handler([self window], nil, 1); |
44a0f9a2e8f9
Experimental change, pulling the resize event handling out of the resizer code on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
915
diff
changeset
|
669 oldsize.width = size.width; |
44a0f9a2e8f9
Experimental change, pulling the resize event handling out of the resizer code on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
915
diff
changeset
|
670 oldsize.height = size.height; |
44a0f9a2e8f9
Experimental change, pulling the resize event handling out of the resizer code on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
915
diff
changeset
|
671 _handle_resize_events(box); |
44a0f9a2e8f9
Experimental change, pulling the resize event handling out of the resizer code on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
915
diff
changeset
|
672 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
673 } |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
674 -(void)windowDidBecomeMain:(id)sender |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
675 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
676 if(windowmenu) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
677 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
678 [DWApp setMainMenu:windowmenu]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
679 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
680 else |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
681 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
682 [DWApp setMainMenu:DWMainMenu]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
683 } |
703
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
684 _event_handler(self, nil, 13); |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
685 } |
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
|
686 -(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
|
687 -(void)menuHandler:(id)sender { _event_handler(sender, nil, 8); } |
886
d94a4fa0359e
Implemented the motion notify event on Mac. Most of it was there except the event handler.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
882
diff
changeset
|
688 -(void)mouseMoved:(NSEvent *)theEvent { _event_handler(self, theEvent, 5); } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
689 @end |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
690 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
691 /* Subclass for a button type */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
692 @interface DWButton : NSButton |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
693 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
694 void *userdata; |
793
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
695 NSButtonType buttonType; |
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
696 DWBox *parent; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
697 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
698 -(void *)userdata; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
699 -(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
|
700 -(void)buttonClicked:(id)sender; |
793
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
701 -(void)setButtonType:(NSButtonType)input; |
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
702 -(NSButtonType)buttonType; |
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
703 -(void)setParent:(DWBox *)input; |
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
704 -(DWBox *)parent; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
705 @end |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
706 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
707 @implementation DWButton |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
708 -(void *)userdata { return userdata; } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
709 -(void)setUserdata:(void *)input { userdata = input; } |
793
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
710 -(void)buttonClicked:(id)sender |
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
711 { |
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
712 _event_handler(self, nil, 8); |
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
713 if([self buttonType] == NSRadioButton) |
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
714 { |
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
715 DWBox *viewbox = [self parent]; |
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
716 Box *thisbox = [viewbox box]; |
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
717 int z; |
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
718 |
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
719 for(z=0;z<thisbox->count;z++) |
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
720 { |
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
721 if(thisbox->items[z].type != TYPEBOX) |
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
722 { |
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
723 id object = thisbox->items[z].hwnd; |
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
724 |
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
725 if([object isMemberOfClass:[DWButton class]]) |
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
726 { |
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
727 DWButton *button = object; |
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
728 |
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
729 if(button != self && [button buttonType] == NSRadioButton) |
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
730 { |
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
731 [button setState:NSOffState]; |
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
732 } |
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
733 } |
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
734 } |
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
735 } |
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
736 } |
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
737 } |
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
738 -(void)setButtonType:(NSButtonType)input { buttonType = input; [super setButtonType:input]; } |
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
739 -(NSButtonType)buttonType { return buttonType; } |
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
740 -(void)setParent:(DWBox *)input { parent = input; } |
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
741 -(DWBox *)parent { return parent; } |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
742 -(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
|
743 @end |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
744 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
745 /* Subclass for a progress type */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
746 @interface DWPercent : NSProgressIndicator |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
747 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
748 void *userdata; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
749 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
750 -(void *)userdata; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
751 -(void)setUserdata:(void *)input; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
752 @end |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
753 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
754 @implementation DWPercent |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
755 -(void *)userdata { return userdata; } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
756 -(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
|
757 -(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
|
758 @end |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
759 |
837
89d4bad9c96e
Initial attempt at implementing the scrollbox on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
831
diff
changeset
|
760 /* Subclass for a scrollbox type */ |
89d4bad9c96e
Initial attempt at implementing the scrollbox on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
831
diff
changeset
|
761 @interface DWScrollBox : NSScrollView |
89d4bad9c96e
Initial attempt at implementing the scrollbox on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
831
diff
changeset
|
762 { |
89d4bad9c96e
Initial attempt at implementing the scrollbox on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
831
diff
changeset
|
763 void *userdata; |
840
2967934fb587
Implemented the fix for the scrollbox problem on the Mac (that was discovered on Windows)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
838
diff
changeset
|
764 id box; |
837
89d4bad9c96e
Initial attempt at implementing the scrollbox on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
831
diff
changeset
|
765 } |
89d4bad9c96e
Initial attempt at implementing the scrollbox on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
831
diff
changeset
|
766 -(void *)userdata; |
89d4bad9c96e
Initial attempt at implementing the scrollbox on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
831
diff
changeset
|
767 -(void)setUserdata:(void *)input; |
840
2967934fb587
Implemented the fix for the scrollbox problem on the Mac (that was discovered on Windows)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
838
diff
changeset
|
768 -(void)setBox:(void *)input; |
2967934fb587
Implemented the fix for the scrollbox problem on the Mac (that was discovered on Windows)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
838
diff
changeset
|
769 -(id)box; |
837
89d4bad9c96e
Initial attempt at implementing the scrollbox on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
831
diff
changeset
|
770 @end |
89d4bad9c96e
Initial attempt at implementing the scrollbox on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
831
diff
changeset
|
771 |
89d4bad9c96e
Initial attempt at implementing the scrollbox on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
831
diff
changeset
|
772 @implementation DWScrollBox |
89d4bad9c96e
Initial attempt at implementing the scrollbox on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
831
diff
changeset
|
773 -(void *)userdata { return userdata; } |
89d4bad9c96e
Initial attempt at implementing the scrollbox on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
831
diff
changeset
|
774 -(void)setUserdata:(void *)input { userdata = input; } |
840
2967934fb587
Implemented the fix for the scrollbox problem on the Mac (that was discovered on Windows)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
838
diff
changeset
|
775 -(void)setBox:(void *)input { box = input; } |
2967934fb587
Implemented the fix for the scrollbox problem on the Mac (that was discovered on Windows)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
838
diff
changeset
|
776 -(id)box { return box; } |
837
89d4bad9c96e
Initial attempt at implementing the scrollbox on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
831
diff
changeset
|
777 -(void)dealloc { UserData *root = userdata; _remove_userdata(&root, NULL, TRUE); [super dealloc]; } |
89d4bad9c96e
Initial attempt at implementing the scrollbox on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
831
diff
changeset
|
778 @end |
89d4bad9c96e
Initial attempt at implementing the scrollbox on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
831
diff
changeset
|
779 |
859
80a88c91ccf6
Implemented vertical centering on text fields.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
858
diff
changeset
|
780 /* Subclass for a textfield that supports vertical centering */ |
80a88c91ccf6
Implemented vertical centering on text fields.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
858
diff
changeset
|
781 @interface DWTextFieldCell : NSTextFieldCell |
80a88c91ccf6
Implemented vertical centering on text fields.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
858
diff
changeset
|
782 { |
860
93ac372941c4
Formatting cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
859
diff
changeset
|
783 BOOL vcenter; |
859
80a88c91ccf6
Implemented vertical centering on text fields.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
858
diff
changeset
|
784 } |
80a88c91ccf6
Implemented vertical centering on text fields.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
858
diff
changeset
|
785 -(NSRect)drawingRectForBounds:(NSRect)theRect; |
80a88c91ccf6
Implemented vertical centering on text fields.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
858
diff
changeset
|
786 -(void)setVCenter:(BOOL)input; |
80a88c91ccf6
Implemented vertical centering on text fields.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
858
diff
changeset
|
787 @end |
80a88c91ccf6
Implemented vertical centering on text fields.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
858
diff
changeset
|
788 |
80a88c91ccf6
Implemented vertical centering on text fields.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
858
diff
changeset
|
789 @implementation DWTextFieldCell |
80a88c91ccf6
Implemented vertical centering on text fields.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
858
diff
changeset
|
790 -(NSRect)drawingRectForBounds:(NSRect)theRect |
80a88c91ccf6
Implemented vertical centering on text fields.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
858
diff
changeset
|
791 { |
860
93ac372941c4
Formatting cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
859
diff
changeset
|
792 /* Get the parent's idea of where we should draw */ |
93ac372941c4
Formatting cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
859
diff
changeset
|
793 NSRect newRect = [super drawingRectForBounds:theRect]; |
859
80a88c91ccf6
Implemented vertical centering on text fields.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
858
diff
changeset
|
794 |
80a88c91ccf6
Implemented vertical centering on text fields.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
858
diff
changeset
|
795 /* If we are being vertically centered */ |
80a88c91ccf6
Implemented vertical centering on text fields.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
858
diff
changeset
|
796 if(vcenter) |
80a88c91ccf6
Implemented vertical centering on text fields.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
858
diff
changeset
|
797 { |
80a88c91ccf6
Implemented vertical centering on text fields.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
858
diff
changeset
|
798 /* Get our ideal size for current text */ |
80a88c91ccf6
Implemented vertical centering on text fields.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
858
diff
changeset
|
799 NSSize textSize = [self cellSizeForBounds:theRect]; |
80a88c91ccf6
Implemented vertical centering on text fields.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
858
diff
changeset
|
800 |
860
93ac372941c4
Formatting cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
859
diff
changeset
|
801 /* Center that in the proposed rect */ |
93ac372941c4
Formatting cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
859
diff
changeset
|
802 float heightDelta = newRect.size.height - textSize.height; |
93ac372941c4
Formatting cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
859
diff
changeset
|
803 if (heightDelta > 0) |
93ac372941c4
Formatting cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
859
diff
changeset
|
804 { |
93ac372941c4
Formatting cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
859
diff
changeset
|
805 newRect.size.height -= heightDelta; |
93ac372941c4
Formatting cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
859
diff
changeset
|
806 newRect.origin.y += (heightDelta / 2); |
93ac372941c4
Formatting cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
859
diff
changeset
|
807 } |
93ac372941c4
Formatting cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
859
diff
changeset
|
808 } |
859
80a88c91ccf6
Implemented vertical centering on text fields.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
858
diff
changeset
|
809 |
860
93ac372941c4
Formatting cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
859
diff
changeset
|
810 return newRect; |
859
80a88c91ccf6
Implemented vertical centering on text fields.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
858
diff
changeset
|
811 } |
80a88c91ccf6
Implemented vertical centering on text fields.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
858
diff
changeset
|
812 -(void)setVCenter:(BOOL)input { vcenter = input; } |
80a88c91ccf6
Implemented vertical centering on text fields.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
858
diff
changeset
|
813 @end |
80a88c91ccf6
Implemented vertical centering on text fields.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
858
diff
changeset
|
814 |
887
29d8ae25a78c
Implemented dw_entryfield_set_limit() on the Mac using a custom formatter class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
886
diff
changeset
|
815 @interface DWEntryFieldFormatter : NSFormatter |
29d8ae25a78c
Implemented dw_entryfield_set_limit() on the Mac using a custom formatter class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
886
diff
changeset
|
816 { |
29d8ae25a78c
Implemented dw_entryfield_set_limit() on the Mac using a custom formatter class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
886
diff
changeset
|
817 int maxLength; |
29d8ae25a78c
Implemented dw_entryfield_set_limit() on the Mac using a custom formatter class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
886
diff
changeset
|
818 } |
29d8ae25a78c
Implemented dw_entryfield_set_limit() on the Mac using a custom formatter class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
886
diff
changeset
|
819 - (void)setMaximumLength:(int)len; |
29d8ae25a78c
Implemented dw_entryfield_set_limit() on the Mac using a custom formatter class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
886
diff
changeset
|
820 - (int)maximumLength; |
29d8ae25a78c
Implemented dw_entryfield_set_limit() on the Mac using a custom formatter class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
886
diff
changeset
|
821 @end |
29d8ae25a78c
Implemented dw_entryfield_set_limit() on the Mac using a custom formatter class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
886
diff
changeset
|
822 |
29d8ae25a78c
Implemented dw_entryfield_set_limit() on the Mac using a custom formatter class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
886
diff
changeset
|
823 /* This formatter subclass will allow us to limit |
29d8ae25a78c
Implemented dw_entryfield_set_limit() on the Mac using a custom formatter class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
886
diff
changeset
|
824 * the text length in an entryfield. |
29d8ae25a78c
Implemented dw_entryfield_set_limit() on the Mac using a custom formatter class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
886
diff
changeset
|
825 */ |
29d8ae25a78c
Implemented dw_entryfield_set_limit() on the Mac using a custom formatter class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
886
diff
changeset
|
826 @implementation DWEntryFieldFormatter |
29d8ae25a78c
Implemented dw_entryfield_set_limit() on the Mac using a custom formatter class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
886
diff
changeset
|
827 -(id)init |
29d8ae25a78c
Implemented dw_entryfield_set_limit() on the Mac using a custom formatter class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
886
diff
changeset
|
828 { |
29d8ae25a78c
Implemented dw_entryfield_set_limit() on the Mac using a custom formatter class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
886
diff
changeset
|
829 [super init]; |
29d8ae25a78c
Implemented dw_entryfield_set_limit() on the Mac using a custom formatter class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
886
diff
changeset
|
830 maxLength = INT_MAX; |
29d8ae25a78c
Implemented dw_entryfield_set_limit() on the Mac using a custom formatter class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
886
diff
changeset
|
831 return self; |
29d8ae25a78c
Implemented dw_entryfield_set_limit() on the Mac using a custom formatter class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
886
diff
changeset
|
832 } |
29d8ae25a78c
Implemented dw_entryfield_set_limit() on the Mac using a custom formatter class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
886
diff
changeset
|
833 -(void)setMaximumLength:(int)len { maxLength = len; } |
29d8ae25a78c
Implemented dw_entryfield_set_limit() on the Mac using a custom formatter class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
886
diff
changeset
|
834 -(int)maximumLength { return maxLength; } |
29d8ae25a78c
Implemented dw_entryfield_set_limit() on the Mac using a custom formatter class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
886
diff
changeset
|
835 -(NSString *)stringForObjectValue:(id)object { return (NSString *)object; } |
29d8ae25a78c
Implemented dw_entryfield_set_limit() on the Mac using a custom formatter class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
886
diff
changeset
|
836 -(BOOL)getObjectValue:(id *)object forString:(NSString *)string errorDescription:(NSString **)error { *object = string; return YES; } |
29d8ae25a78c
Implemented dw_entryfield_set_limit() on the Mac using a custom formatter class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
886
diff
changeset
|
837 -(BOOL)isPartialStringValid:(NSString **)partialStringPtr |
29d8ae25a78c
Implemented dw_entryfield_set_limit() on the Mac using a custom formatter class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
886
diff
changeset
|
838 proposedSelectedRange:(NSRangePointer)proposedSelRangePtr |
29d8ae25a78c
Implemented dw_entryfield_set_limit() on the Mac using a custom formatter class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
886
diff
changeset
|
839 originalString:(NSString *)origString |
29d8ae25a78c
Implemented dw_entryfield_set_limit() on the Mac using a custom formatter class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
886
diff
changeset
|
840 originalSelectedRange:(NSRange)origSelRange |
29d8ae25a78c
Implemented dw_entryfield_set_limit() on the Mac using a custom formatter class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
886
diff
changeset
|
841 errorDescription:(NSString **)error |
29d8ae25a78c
Implemented dw_entryfield_set_limit() on the Mac using a custom formatter class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
886
diff
changeset
|
842 { |
29d8ae25a78c
Implemented dw_entryfield_set_limit() on the Mac using a custom formatter class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
886
diff
changeset
|
843 if([*partialStringPtr length] > maxLength) |
29d8ae25a78c
Implemented dw_entryfield_set_limit() on the Mac using a custom formatter class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
886
diff
changeset
|
844 { |
29d8ae25a78c
Implemented dw_entryfield_set_limit() on the Mac using a custom formatter class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
886
diff
changeset
|
845 return NO; |
29d8ae25a78c
Implemented dw_entryfield_set_limit() on the Mac using a custom formatter class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
886
diff
changeset
|
846 } |
29d8ae25a78c
Implemented dw_entryfield_set_limit() on the Mac using a custom formatter class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
886
diff
changeset
|
847 return YES; |
29d8ae25a78c
Implemented dw_entryfield_set_limit() on the Mac using a custom formatter class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
886
diff
changeset
|
848 } |
29d8ae25a78c
Implemented dw_entryfield_set_limit() on the Mac using a custom formatter class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
886
diff
changeset
|
849 -(NSAttributedString *)attributedStringForObjectValue:(id)anObject withDefaultAttributes:(NSDictionary *)attributes { return nil; } |
29d8ae25a78c
Implemented dw_entryfield_set_limit() on the Mac using a custom formatter class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
886
diff
changeset
|
850 @end |
29d8ae25a78c
Implemented dw_entryfield_set_limit() on the Mac using a custom formatter class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
886
diff
changeset
|
851 |
651
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
852 /* Subclass for a entryfield type */ |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
853 @interface DWEntryField : NSTextField |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
854 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
855 void *userdata; |
768
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
856 id clickDefault; |
651
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
857 } |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
858 -(void *)userdata; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
859 -(void)setUserdata:(void *)input; |
768
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
860 -(void)setClickDefault:(id)input; |
651
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
861 @end |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
862 |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
863 @implementation DWEntryField |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
864 -(void *)userdata { return userdata; } |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
865 -(void)setUserdata:(void *)input { userdata = input; } |
768
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
866 -(void)setClickDefault:(id)input { clickDefault = input; } |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
867 -(void)keyUp:(NSEvent *)theEvent |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
868 { |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
869 unichar vk = [[theEvent charactersIgnoringModifiers] characterAtIndex:0]; |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
870 if(clickDefault && vk == VK_RETURN) |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
871 { |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
872 [[self window] makeFirstResponder:clickDefault]; |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
873 } else |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
874 { |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
875 [super keyUp:theEvent]; |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
876 } |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
877 } |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
878 -(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
|
879 @end |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
880 |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
881 /* Subclass for a entryfield password type */ |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
882 @interface DWEntryFieldPassword : NSSecureTextField |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
883 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
884 void *userdata; |
768
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
885 id clickDefault; |
651
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
886 } |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
887 -(void *)userdata; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
888 -(void)setUserdata:(void *)input; |
768
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
889 -(void)setClickDefault:(id)input; |
651
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
890 @end |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
891 |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
892 @implementation DWEntryFieldPassword |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
893 -(void *)userdata { return userdata; } |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
894 -(void)setUserdata:(void *)input { userdata = input; } |
768
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
895 -(void)setClickDefault:(id)input { clickDefault = input; } |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
896 -(void)keyUp:(NSEvent *)theEvent |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
897 { |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
898 if(clickDefault && [[theEvent charactersIgnoringModifiers] characterAtIndex:0] == VK_RETURN) |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
899 { |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
900 [[self window] makeFirstResponder:clickDefault]; |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
901 } else |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
902 { |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
903 [super keyUp:theEvent]; |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
904 } |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
905 } |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
906 -(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
|
907 @end |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
908 |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
909 /* Subclass for a Notebook control type */ |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
910 @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
|
911 #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
|
912 <NSTabViewDelegate> |
17923b931393
Fixes for building for MacOS 10.5 and PPC
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
715
diff
changeset
|
913 #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
|
914 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
915 void *userdata; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
916 int pageid; |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
917 } |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
918 -(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
|
919 -(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
|
920 -(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
|
921 -(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
|
922 -(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
|
923 @end |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
924 |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
925 /* 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
|
926 @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
|
927 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
928 void *userdata; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
929 int pageid; |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
930 } |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
931 -(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
|
932 -(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
|
933 -(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
|
934 -(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
|
935 @end |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
936 |
703
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
937 @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
|
938 -(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
|
939 -(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
|
940 -(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
|
941 -(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
|
942 -(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
|
943 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
944 id object = [notepage view]; |
703
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
945 DWNotebookPage *page = (DWNotebookPage *)notepage; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
946 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
947 if([object isMemberOfClass:[DWBox class]]) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
948 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
949 DWBox *view = object; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
950 Box *box = [view box]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
951 NSSize size = [view frame].size; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
952 _do_resize(box, size.width, size.height); |
916
44a0f9a2e8f9
Experimental change, pulling the resize event handling out of the resizer code on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
915
diff
changeset
|
953 _handle_resize_events(box); |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
954 } |
703
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
955 _event_handler(self, (void *)[page pageid], 15); |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
956 } |
703
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
957 -(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
|
958 @end |
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
959 |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
960 @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
|
961 -(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
|
962 -(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
|
963 -(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
|
964 -(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
|
965 -(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
|
966 @end |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
967 |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
968 /* Subclass for a color chooser type */ |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
969 @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
|
970 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
971 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
|
972 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
|
973 } |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
974 -(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
|
975 -(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
|
976 -(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
|
977 @end |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
978 |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
979 @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
|
980 -(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
|
981 -(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
|
982 -(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
|
983 -(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
|
984 @end |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
985 |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
986 /* Subclass for a splitbar type */ |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
987 @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
|
988 #ifdef BUILDING_FOR_SNOW_LEOPARD |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
989 <NSSplitViewDelegate> |
717
17923b931393
Fixes for building for MacOS 10.5 and PPC
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
715
diff
changeset
|
990 #endif |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
991 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
992 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
|
993 float percent; |
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
994 } |
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
995 -(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
|
996 -(void *)userdata; |
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
997 -(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
|
998 -(float)percent; |
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
999 -(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
|
1000 @end |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
1001 |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
1002 @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
|
1003 -(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
|
1004 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1005 NSArray *views = [self subviews]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1006 id object; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
1007 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1008 for(object in views) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1009 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1010 if([object isMemberOfClass:[DWBox class]]) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1011 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1012 DWBox *view = object; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1013 Box *box = [view box]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1014 NSSize size = [view frame].size; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1015 _do_resize(box, size.width, size.height); |
916
44a0f9a2e8f9
Experimental change, pulling the resize event handling out of the resizer code on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
915
diff
changeset
|
1016 _handle_resize_events(box); |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1017 } |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
1018 } |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
1019 } |
677
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
1020 -(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
|
1021 -(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
|
1022 -(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
|
1023 -(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
|
1024 -(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
|
1025 @end |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
1026 |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
1027 /* 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
|
1028 @interface DWSlider : NSSlider |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
1029 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1030 void *userdata; |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
1031 } |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
1032 -(void *)userdata; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
1033 -(void)setUserdata:(void *)input; |
704
336800e9e648
Fixes to the slider control so events happen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
703
diff
changeset
|
1034 -(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
|
1035 @end |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
1036 |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
1037 @implementation DWSlider |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
1038 -(void *)userdata { return userdata; } |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
1039 -(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
|
1040 -(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
|
1041 -(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
|
1042 @end |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
1043 |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
1044 /* 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
|
1045 @interface DWScrollbar : NSScroller |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
1046 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1047 void *userdata; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1048 float range; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1049 float visible; |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
1050 } |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
1051 -(void *)userdata; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
1052 -(void)setUserdata:(void *)input; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
1053 -(float)range; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
1054 -(float)visible; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
1055 -(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
|
1056 -(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
|
1057 @end |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
1058 |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
1059 @implementation DWScrollbar |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
1060 -(void *)userdata { return userdata; } |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
1061 -(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
|
1062 -(float)range { return range; } |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
1063 -(float)visible { return visible; } |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
1064 -(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
|
1065 -(void)scrollerChanged:(id)sender |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1066 { |
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
|
1067 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
|
1068 int page = (int)(proportion * range); |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1069 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
|
1070 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
|
1071 int newpos = result; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1072 |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1073 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
|
1074 { |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1075 |
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
|
1076 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
|
1077 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
|
1078 { |
86d76fc09237
Added support for scrollbar line and page scrolling. Need to check the calculations...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
706
diff
changeset
|
1079 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
|
1080 } |
86d76fc09237
Added support for scrollbar line and page scrolling. Need to check the calculations...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
706
diff
changeset
|
1081 break; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1082 |
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
|
1083 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
|
1084 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
|
1085 { |
86d76fc09237
Added support for scrollbar line and page scrolling. Need to check the calculations...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
706
diff
changeset
|
1086 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
|
1087 } |
86d76fc09237
Added support for scrollbar line and page scrolling. Need to check the calculations...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
706
diff
changeset
|
1088 break; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1089 |
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
|
1090 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
|
1091 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
|
1092 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
|
1093 { |
86d76fc09237
Added support for scrollbar line and page scrolling. Need to check the calculations...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
706
diff
changeset
|
1094 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
|
1095 } |
86d76fc09237
Added support for scrollbar line and page scrolling. Need to check the calculations...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
706
diff
changeset
|
1096 break; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1097 |
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
|
1098 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
|
1099 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
|
1100 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
|
1101 { |
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
|
1102 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
|
1103 } |
86d76fc09237
Added support for scrollbar line and page scrolling. Need to check the calculations...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
706
diff
changeset
|
1104 break; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1105 |
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
|
1106 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
|
1107 ; /* 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
|
1108 } |
86d76fc09237
Added support for scrollbar line and page scrolling. Need to check the calculations...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
706
diff
changeset
|
1109 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
|
1110 { |
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
|
1111 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
|
1112 [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
|
1113 } |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1114 _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
|
1115 } |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1116 -(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
|
1117 @end |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
1118 |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
1119 /* Subclass for a render area type */ |
850
1a7c8d210b18
Changed the Render widget superclass from NSView to NSControl to allow it to function more like a normal control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
844
diff
changeset
|
1120 @interface DWRender : NSControl |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
1121 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1122 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
|
1123 NSFont *font; |
851
5b663261b76c
Added code to prevent configure events from being sent with the same size.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
850
diff
changeset
|
1124 NSSize size; |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
1125 } |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
1126 -(void *)userdata; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
1127 -(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
|
1128 -(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
|
1129 -(NSFont *)font; |
851
5b663261b76c
Added code to prevent configure events from being sent with the same size.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
850
diff
changeset
|
1130 -(void)setSize:(NSSize)input; |
5b663261b76c
Added code to prevent configure events from being sent with the same size.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
850
diff
changeset
|
1131 -(NSSize)size; |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
1132 -(void)mouseDown:(NSEvent *)theEvent; |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
1133 -(void)mouseUp:(NSEvent *)theEvent; |
701
c91a1b345f2e
Fix for button press and context menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
700
diff
changeset
|
1134 -(NSMenu *)menuForEvent:(NSEvent *)theEvent; |
c91a1b345f2e
Fix for button press and context menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
700
diff
changeset
|
1135 -(void)rightMouseUp:(NSEvent *)theEvent; |
c91a1b345f2e
Fix for button press and context menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
700
diff
changeset
|
1136 -(void)otherMouseDown:(NSEvent *)theEvent; |
c91a1b345f2e
Fix for button press and context menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
700
diff
changeset
|
1137 -(void)otherMouseUp:(NSEvent *)theEvent; |
c91a1b345f2e
Fix for button press and context menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
700
diff
changeset
|
1138 -(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
|
1139 -(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
|
1140 -(BOOL)isFlipped; |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
1141 @end |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
1142 |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
1143 @implementation DWRender |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
1144 -(void *)userdata { return userdata; } |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
1145 -(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
|
1146 -(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
|
1147 -(NSFont *)font { return font; } |
851
5b663261b76c
Added code to prevent configure events from being sent with the same size.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
850
diff
changeset
|
1148 -(void)setSize:(NSSize)input { size = input; } |
5b663261b76c
Added code to prevent configure events from being sent with the same size.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
850
diff
changeset
|
1149 -(NSSize)size { return size; } |
701
c91a1b345f2e
Fix for button press and context menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
700
diff
changeset
|
1150 -(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
|
1151 -(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
|
1152 -(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
|
1153 -(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
|
1154 -(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
|
1155 -(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
|
1156 -(void)drawRect:(NSRect)rect { _event_handler(self, nil, 7); } |
894
d1d7e5c51860
Added a DWWindow subclass to trap key events on the main window for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
891
diff
changeset
|
1157 -(void)keyDown:(NSEvent *)theEvent { _event_handler(self, 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
|
1158 -(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
|
1159 -(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
|
1160 @end |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
1161 |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
1162 /* Subclass for a MLE type */ |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1163 @interface DWMLE : NSTextView |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
1164 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1165 void *userdata; |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
1166 } |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
1167 -(void *)userdata; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
1168 -(void)setUserdata:(void *)input; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
1169 @end |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
1170 |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
1171 @implementation DWMLE |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
1172 -(void *)userdata { return userdata; } |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
1173 -(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
|
1174 -(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
|
1175 @end |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
1176 |
655
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
1177 /* Subclass for a Container/List type */ |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1178 @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
|
1179 #ifdef BUILDING_FOR_SNOW_LEOPARD |
813
7fa26d8cc8d0
Fix for column click handler not working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
812
diff
changeset
|
1180 <NSTableViewDataSource,NSTableViewDelegate> |
717
17923b931393
Fixes for building for MacOS 10.5 and PPC
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
715
diff
changeset
|
1181 #endif |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
1182 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1183 void *userdata; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1184 NSMutableArray *tvcols; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1185 NSMutableArray *data; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1186 NSMutableArray *types; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1187 NSPointerArray *titles; |
810
746cdd753e7a
Added coloring support for the Container/Tree/Listbox controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
809
diff
changeset
|
1188 NSColor *fgcolor; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1189 int lastAddPoint, lastQueryPoint; |
668
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
1190 id scrollview; |
813
7fa26d8cc8d0
Fix for column click handler not working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
812
diff
changeset
|
1191 int filesystem; |
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
|
1192 } |
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
1193 -(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
|
1194 -(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
|
1195 -(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
|
1196 -(void *)userdata; |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
1197 -(void)setUserdata:(void *)input; |
813
7fa26d8cc8d0
Fix for column click handler not working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
812
diff
changeset
|
1198 -(void)setFilesystem:(int)input; |
831
168b9db65825
Minor fix for dw_container_column_set_width() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
829
diff
changeset
|
1199 -(int)filesystem; |
668
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
1200 -(id)scrollview; |
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
1201 -(void)setScrollview:(id)input; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
1202 -(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
|
1203 -(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
|
1204 -(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
|
1205 -(int)addRows:(int)number; |
882
1e7b7f870d88
Experimental change to use a single column for holding the filename and icon on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
881
diff
changeset
|
1206 -(void)tableView:(NSTableView *)tableView willDisplayCell:(id)cell forTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
1207 -(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
|
1208 -(void)removeRow:(int)row; |
659
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
1209 -(void)setRow:(int)row title:(void *)input; |
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
1210 -(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
|
1211 -(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
|
1212 -(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
|
1213 -(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
|
1214 -(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
|
1215 -(void)setLastQueryPoint:(int)input; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
1216 -(void)clear; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
1217 -(void)setup; |
856
9dc45928a75f
Added method to do column optimizations like on other platforms. Figure out the maximum width for a column and sizing to that.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
855
diff
changeset
|
1218 -(void)optimize; |
810
746cdd753e7a
Added coloring support for the Container/Tree/Listbox controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
809
diff
changeset
|
1219 -(void)setForegroundColor:(NSColor *)input; |
708
5fe2ca5ef88b
Fixes for container event handling. Also made container/listbox cells non-editable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
707
diff
changeset
|
1220 -(void)doubleClicked:(id)sender; |
829
f7b6c88bac47
Implemented Enter/Return triggering the item enter event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
828
diff
changeset
|
1221 -(void)keyUp:(NSEvent *)theEvent; |
867
139acecd6ca0
Guess I wanted to trap didClickTableColumn instead of mouseDownInHeaderOfTableColumn to avoid spurious events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
866
diff
changeset
|
1222 -(void)tableView:(NSTableView *)tableView didClickTableColumn:(NSTableColumn *)tableColumn; |
659
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
1223 -(void)selectionChanged:(id)sender; |
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
1224 -(NSMenu *)menuForEvent:(NSEvent *)event; |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
1225 @end |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
1226 |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
1227 @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
|
1228 -(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
|
1229 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1230 if(tvcols && data) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1231 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1232 int cols = (int)[tvcols count]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1233 if(cols) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1234 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1235 return [data count] / cols; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1236 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1237 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1238 return 0; |
658
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
1239 } |
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
1240 -(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
|
1241 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1242 if(tvcols) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1243 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1244 int z, col = -1; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1245 int count = (int)[tvcols count]; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
1246 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1247 for(z=0;z<count;z++) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1248 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1249 if([tvcols objectAtIndex:z] == aCol) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1250 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1251 col = z; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1252 break; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1253 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1254 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1255 if(col != -1) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1256 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1257 int index = (int)(aRow * count) + col; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1258 id this = [data objectAtIndex:index]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1259 return ([this isKindOfClass:[NSNull class]]) ? nil : this; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1260 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1261 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1262 return nil; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
1263 } |
708
5fe2ca5ef88b
Fixes for container event handling. Also made container/listbox cells non-editable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
707
diff
changeset
|
1264 -(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
|
1265 -(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
|
1266 -(void)setUserdata:(void *)input { userdata = input; } |
813
7fa26d8cc8d0
Fix for column click handler not working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
812
diff
changeset
|
1267 -(void)setFilesystem:(int)input { filesystem = input; } |
831
168b9db65825
Minor fix for dw_container_column_set_width() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
829
diff
changeset
|
1268 -(int)filesystem { return filesystem; } |
717
17923b931393
Fixes for building for MacOS 10.5 and PPC
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
715
diff
changeset
|
1269 -(id)scrollview { return scrollview; } |
17923b931393
Fixes for building for MacOS 10.5 and PPC
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
715
diff
changeset
|
1270 -(void)setScrollview:(id)input { scrollview = input; } |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
1271 -(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
|
1272 -(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
|
1273 -(int)insertRow:(NSArray *)input at:(int)index |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1274 { |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1275 if(data) |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1276 { |
687
5dde8d34bc69
Implemented dw_listbox_insert for containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
686
diff
changeset
|
1277 unsigned long start = [tvcols count] * index; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1278 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
|
1279 if(index < lastAddPoint) |
5dde8d34bc69
Implemented dw_listbox_insert for containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
686
diff
changeset
|
1280 { |
5dde8d34bc69
Implemented dw_listbox_insert for containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
686
diff
changeset
|
1281 lastAddPoint++; |
5dde8d34bc69
Implemented dw_listbox_insert for containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
686
diff
changeset
|
1282 } |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1283 [data insertObjects:input atIndexes:set]; |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1284 [titles insertPointer:NULL atIndex:index]; |
687
5dde8d34bc69
Implemented dw_listbox_insert for containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
686
diff
changeset
|
1285 [set release]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1286 return (int)[titles count]; |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1287 } |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1288 return 0; |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1289 } |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1290 -(int)addRow:(NSArray *)input |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1291 { |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1292 if(data) |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1293 { |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1294 lastAddPoint = (int)[titles count]; |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1295 [data addObjectsFromArray:input]; |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1296 [titles addPointer:NULL]; |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1297 return (int)[titles count]; |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1298 } |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1299 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
|
1300 } |
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
|
1301 -(int)addRows:(int)number |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
1302 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1303 if(tvcols) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1304 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1305 int count = (int)(number * [tvcols count]); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1306 int z; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
1307 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1308 lastAddPoint = (int)[titles count]; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
1309 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1310 for(z=0;z<count;z++) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1311 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1312 [data addObject:[NSNull null]]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1313 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1314 for(z=0;z<number;z++) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1315 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1316 [titles addPointer:NULL]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1317 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1318 return (int)[titles count]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1319 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1320 return 0; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
1321 } |
882
1e7b7f870d88
Experimental change to use a single column for holding the filename and icon on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
881
diff
changeset
|
1322 -(void)tableView:(NSTableView *)tableView willDisplayCell:(id)cell forTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row |
1e7b7f870d88
Experimental change to use a single column for holding the filename and icon on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
881
diff
changeset
|
1323 { |
1e7b7f870d88
Experimental change to use a single column for holding the filename and icon on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
881
diff
changeset
|
1324 if([cell isMemberOfClass:[NSBrowserCell class]]) |
1e7b7f870d88
Experimental change to use a single column for holding the filename and icon on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
881
diff
changeset
|
1325 { |
1e7b7f870d88
Experimental change to use a single column for holding the filename and icon on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
881
diff
changeset
|
1326 int index = (int)(row * [tvcols count]); |
1e7b7f870d88
Experimental change to use a single column for holding the filename and icon on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
881
diff
changeset
|
1327 NSBrowserCell *browsercell = [data objectAtIndex:index]; |
1e7b7f870d88
Experimental change to use a single column for holding the filename and icon on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
881
diff
changeset
|
1328 NSImage *img = [browsercell image]; |
1e7b7f870d88
Experimental change to use a single column for holding the filename and icon on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
881
diff
changeset
|
1329 [(NSBrowserCell*)cell setImage:img]; |
1e7b7f870d88
Experimental change to use a single column for holding the filename and icon on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
881
diff
changeset
|
1330 } |
1e7b7f870d88
Experimental change to use a single column for holding the filename and icon on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
881
diff
changeset
|
1331 } |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
1332 -(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
|
1333 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1334 if(tvcols && input) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1335 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1336 int index = (int)(row * [tvcols count]) + col; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1337 [data replaceObjectAtIndex:index withObject:input]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1338 } |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
1339 } |
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
|
1340 -(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
|
1341 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1342 if(tvcols) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1343 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1344 int z, start, end; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1345 int count = (int)[tvcols count]; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
1346 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1347 start = count * row; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1348 end = start + count; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
1349 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1350 for(z=start;z<end;z++) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1351 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1352 [data removeObjectAtIndex:z]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1353 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1354 [titles removePointerAtIndex:row]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1355 if(lastAddPoint > 0 && lastAddPoint < row) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1356 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1357 lastAddPoint--; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1358 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1359 } |
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
|
1360 } |
659
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
1361 -(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
|
1362 -(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
|
1363 -(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
|
1364 -(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
|
1365 -(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
|
1366 -(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
|
1367 -(void)setLastQueryPoint:(int)input { lastQueryPoint = input; } |
659
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
1368 -(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
|
1369 -(void)setup |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1370 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1371 tvcols = [[[NSMutableArray alloc] init] retain]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1372 data = [[[NSMutableArray alloc] init] retain]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1373 types = [[[NSMutableArray alloc] init] retain]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1374 titles = [[NSPointerArray pointerArrayWithWeakObjects] retain]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1375 [[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
|
1376 } |
856
9dc45928a75f
Added method to do column optimizations like on other platforms. Figure out the maximum width for a column and sizing to that.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
855
diff
changeset
|
1377 -(void)optimize |
9dc45928a75f
Added method to do column optimizations like on other platforms. Figure out the maximum width for a column and sizing to that.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
855
diff
changeset
|
1378 { |
9dc45928a75f
Added method to do column optimizations like on other platforms. Figure out the maximum width for a column and sizing to that.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
855
diff
changeset
|
1379 if(tvcols) |
9dc45928a75f
Added method to do column optimizations like on other platforms. Figure out the maximum width for a column and sizing to that.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
855
diff
changeset
|
1380 { |
9dc45928a75f
Added method to do column optimizations like on other platforms. Figure out the maximum width for a column and sizing to that.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
855
diff
changeset
|
1381 int z; |
9dc45928a75f
Added method to do column optimizations like on other platforms. Figure out the maximum width for a column and sizing to that.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
855
diff
changeset
|
1382 int colcount = (int)[tvcols count]; |
9dc45928a75f
Added method to do column optimizations like on other platforms. Figure out the maximum width for a column and sizing to that.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
855
diff
changeset
|
1383 int rowcount = (int)[self numberOfRowsInTableView:self]; |
9dc45928a75f
Added method to do column optimizations like on other platforms. Figure out the maximum width for a column and sizing to that.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
855
diff
changeset
|
1384 |
9dc45928a75f
Added method to do column optimizations like on other platforms. Figure out the maximum width for a column and sizing to that.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
855
diff
changeset
|
1385 for(z=0;z<colcount;z++) |
9dc45928a75f
Added method to do column optimizations like on other platforms. Figure out the maximum width for a column and sizing to that.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
855
diff
changeset
|
1386 { |
9dc45928a75f
Added method to do column optimizations like on other platforms. Figure out the maximum width for a column and sizing to that.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
855
diff
changeset
|
1387 NSTableColumn *column = [tvcols objectAtIndex:z]; |
9dc45928a75f
Added method to do column optimizations like on other platforms. Figure out the maximum width for a column and sizing to that.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
855
diff
changeset
|
1388 if([column resizingMask] != NSTableColumnNoResizing) |
9dc45928a75f
Added method to do column optimizations like on other platforms. Figure out the maximum width for a column and sizing to that.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
855
diff
changeset
|
1389 { |
9dc45928a75f
Added method to do column optimizations like on other platforms. Figure out the maximum width for a column and sizing to that.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
855
diff
changeset
|
1390 if(rowcount > 0) |
9dc45928a75f
Added method to do column optimizations like on other platforms. Figure out the maximum width for a column and sizing to that.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
855
diff
changeset
|
1391 { |
9dc45928a75f
Added method to do column optimizations like on other platforms. Figure out the maximum width for a column and sizing to that.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
855
diff
changeset
|
1392 int x; |
9dc45928a75f
Added method to do column optimizations like on other platforms. Figure out the maximum width for a column and sizing to that.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
855
diff
changeset
|
1393 int width = 0; |
9dc45928a75f
Added method to do column optimizations like on other platforms. Figure out the maximum width for a column and sizing to that.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
855
diff
changeset
|
1394 |
9dc45928a75f
Added method to do column optimizations like on other platforms. Figure out the maximum width for a column and sizing to that.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
855
diff
changeset
|
1395 for(x=0;x<rowcount;x++) |
9dc45928a75f
Added method to do column optimizations like on other platforms. Figure out the maximum width for a column and sizing to that.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
855
diff
changeset
|
1396 { |
9dc45928a75f
Added method to do column optimizations like on other platforms. Figure out the maximum width for a column and sizing to that.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
855
diff
changeset
|
1397 NSCell *cell = [self preparedCellAtColumn:z row:x]; |
9dc45928a75f
Added method to do column optimizations like on other platforms. Figure out the maximum width for a column and sizing to that.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
855
diff
changeset
|
1398 int thiswidth = [cell cellSize].width; |
866
ba9d38b8d0bc
Added code to check the image size inside the cell during optimize.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
864
diff
changeset
|
1399 |
ba9d38b8d0bc
Added code to check the image size inside the cell during optimize.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
864
diff
changeset
|
1400 /* Check the image inside the cell to get its width */ |
ba9d38b8d0bc
Added code to check the image size inside the cell during optimize.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
864
diff
changeset
|
1401 if([cell isMemberOfClass:[NSImageCell class]]) |
ba9d38b8d0bc
Added code to check the image size inside the cell during optimize.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
864
diff
changeset
|
1402 { |
ba9d38b8d0bc
Added code to check the image size inside the cell during optimize.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
864
diff
changeset
|
1403 int index = (int)(x * [tvcols count]) + z; |
ba9d38b8d0bc
Added code to check the image size inside the cell during optimize.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
864
diff
changeset
|
1404 NSImage *image = [data objectAtIndex:index]; |
ba9d38b8d0bc
Added code to check the image size inside the cell during optimize.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
864
diff
changeset
|
1405 if([image isMemberOfClass:[NSImage class]]) |
ba9d38b8d0bc
Added code to check the image size inside the cell during optimize.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
864
diff
changeset
|
1406 { |
ba9d38b8d0bc
Added code to check the image size inside the cell during optimize.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
864
diff
changeset
|
1407 thiswidth = [image size].width; |
ba9d38b8d0bc
Added code to check the image size inside the cell during optimize.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
864
diff
changeset
|
1408 } |
ba9d38b8d0bc
Added code to check the image size inside the cell during optimize.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
864
diff
changeset
|
1409 } |
856
9dc45928a75f
Added method to do column optimizations like on other platforms. Figure out the maximum width for a column and sizing to that.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
855
diff
changeset
|
1410 |
9dc45928a75f
Added method to do column optimizations like on other platforms. Figure out the maximum width for a column and sizing to that.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
855
diff
changeset
|
1411 if(thiswidth > width) |
9dc45928a75f
Added method to do column optimizations like on other platforms. Figure out the maximum width for a column and sizing to that.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
855
diff
changeset
|
1412 { |
9dc45928a75f
Added method to do column optimizations like on other platforms. Figure out the maximum width for a column and sizing to that.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
855
diff
changeset
|
1413 width = thiswidth; |
9dc45928a75f
Added method to do column optimizations like on other platforms. Figure out the maximum width for a column and sizing to that.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
855
diff
changeset
|
1414 } |
9dc45928a75f
Added method to do column optimizations like on other platforms. Figure out the maximum width for a column and sizing to that.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
855
diff
changeset
|
1415 } |
866
ba9d38b8d0bc
Added code to check the image size inside the cell during optimize.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
864
diff
changeset
|
1416 /* If the image is missing default the optimized width to 16. */ |
864
ca01c7d95b80
Added some sanity checks for a couple of problem functions and default optimized container column width to 16 for image columns.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
860
diff
changeset
|
1417 if(!width && [[types objectAtIndex:z] intValue] & DW_CFA_BITMAPORICON) |
ca01c7d95b80
Added some sanity checks for a couple of problem functions and default optimized container column width to 16 for image columns.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
860
diff
changeset
|
1418 { |
ca01c7d95b80
Added some sanity checks for a couple of problem functions and default optimized container column width to 16 for image columns.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
860
diff
changeset
|
1419 width = 16; |
ca01c7d95b80
Added some sanity checks for a couple of problem functions and default optimized container column width to 16 for image columns.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
860
diff
changeset
|
1420 } |
ca01c7d95b80
Added some sanity checks for a couple of problem functions and default optimized container column width to 16 for image columns.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
860
diff
changeset
|
1421 /* Sanity check... don't set the width to 0 */ |
ca01c7d95b80
Added some sanity checks for a couple of problem functions and default optimized container column width to 16 for image columns.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
860
diff
changeset
|
1422 if(width) |
ca01c7d95b80
Added some sanity checks for a couple of problem functions and default optimized container column width to 16 for image columns.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
860
diff
changeset
|
1423 { |
ca01c7d95b80
Added some sanity checks for a couple of problem functions and default optimized container column width to 16 for image columns.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
860
diff
changeset
|
1424 [column setWidth:width]; |
ca01c7d95b80
Added some sanity checks for a couple of problem functions and default optimized container column width to 16 for image columns.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
860
diff
changeset
|
1425 } |
856
9dc45928a75f
Added method to do column optimizations like on other platforms. Figure out the maximum width for a column and sizing to that.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
855
diff
changeset
|
1426 } |
9dc45928a75f
Added method to do column optimizations like on other platforms. Figure out the maximum width for a column and sizing to that.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
855
diff
changeset
|
1427 else |
9dc45928a75f
Added method to do column optimizations like on other platforms. Figure out the maximum width for a column and sizing to that.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
855
diff
changeset
|
1428 { |
9dc45928a75f
Added method to do column optimizations like on other platforms. Figure out the maximum width for a column and sizing to that.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
855
diff
changeset
|
1429 [column sizeToFit]; |
9dc45928a75f
Added method to do column optimizations like on other platforms. Figure out the maximum width for a column and sizing to that.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
855
diff
changeset
|
1430 } |
9dc45928a75f
Added method to do column optimizations like on other platforms. Figure out the maximum width for a column and sizing to that.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
855
diff
changeset
|
1431 } |
9dc45928a75f
Added method to do column optimizations like on other platforms. Figure out the maximum width for a column and sizing to that.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
855
diff
changeset
|
1432 } |
9dc45928a75f
Added method to do column optimizations like on other platforms. Figure out the maximum width for a column and sizing to that.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
855
diff
changeset
|
1433 } |
9dc45928a75f
Added method to do column optimizations like on other platforms. Figure out the maximum width for a column and sizing to that.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
855
diff
changeset
|
1434 } |
810
746cdd753e7a
Added coloring support for the Container/Tree/Listbox controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
809
diff
changeset
|
1435 -(void)setForegroundColor:(NSColor *)input |
746cdd753e7a
Added coloring support for the Container/Tree/Listbox controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
809
diff
changeset
|
1436 { |
746cdd753e7a
Added coloring support for the Container/Tree/Listbox controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
809
diff
changeset
|
1437 int z, count = (int)[tvcols count]; |
746cdd753e7a
Added coloring support for the Container/Tree/Listbox controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
809
diff
changeset
|
1438 |
746cdd753e7a
Added coloring support for the Container/Tree/Listbox controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
809
diff
changeset
|
1439 fgcolor = input; |
746cdd753e7a
Added coloring support for the Container/Tree/Listbox controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
809
diff
changeset
|
1440 [fgcolor retain]; |
746cdd753e7a
Added coloring support for the Container/Tree/Listbox controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
809
diff
changeset
|
1441 |
746cdd753e7a
Added coloring support for the Container/Tree/Listbox controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
809
diff
changeset
|
1442 for(z=0;z<count;z++) |
746cdd753e7a
Added coloring support for the Container/Tree/Listbox controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
809
diff
changeset
|
1443 { |
746cdd753e7a
Added coloring support for the Container/Tree/Listbox controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
809
diff
changeset
|
1444 NSTableColumn *tableColumn = [tvcols objectAtIndex:z]; |
746cdd753e7a
Added coloring support for the Container/Tree/Listbox controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
809
diff
changeset
|
1445 NSTextFieldCell *cell = [tableColumn dataCell]; |
746cdd753e7a
Added coloring support for the Container/Tree/Listbox controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
809
diff
changeset
|
1446 [cell setTextColor:fgcolor]; |
746cdd753e7a
Added coloring support for the Container/Tree/Listbox controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
809
diff
changeset
|
1447 } |
746cdd753e7a
Added coloring support for the Container/Tree/Listbox controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
809
diff
changeset
|
1448 } |
708
5fe2ca5ef88b
Fixes for container event handling. Also made container/listbox cells non-editable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
707
diff
changeset
|
1449 -(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
|
1450 { |
5fe2ca5ef88b
Fixes for container event handling. Also made container/listbox cells non-editable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
707
diff
changeset
|
1451 /* Handler for container class */ |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1452 _event_handler(self, (NSEvent *)[self getRowTitle:(int)[self selectedRow]], 9); |
708
5fe2ca5ef88b
Fixes for container event handling. Also made container/listbox cells non-editable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
707
diff
changeset
|
1453 } |
829
f7b6c88bac47
Implemented Enter/Return triggering the item enter event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
828
diff
changeset
|
1454 -(void)keyUp:(NSEvent *)theEvent |
f7b6c88bac47
Implemented Enter/Return triggering the item enter event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
828
diff
changeset
|
1455 { |
f7b6c88bac47
Implemented Enter/Return triggering the item enter event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
828
diff
changeset
|
1456 if([[theEvent charactersIgnoringModifiers] characterAtIndex:0] == VK_RETURN) |
f7b6c88bac47
Implemented Enter/Return triggering the item enter event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
828
diff
changeset
|
1457 { |
f7b6c88bac47
Implemented Enter/Return triggering the item enter event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
828
diff
changeset
|
1458 _event_handler(self, (NSEvent *)[self getRowTitle:(int)[self selectedRow]], 9); |
f7b6c88bac47
Implemented Enter/Return triggering the item enter event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
828
diff
changeset
|
1459 } |
f7b6c88bac47
Implemented Enter/Return triggering the item enter event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
828
diff
changeset
|
1460 [super keyUp:theEvent]; |
f7b6c88bac47
Implemented Enter/Return triggering the item enter event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
828
diff
changeset
|
1461 } |
f7b6c88bac47
Implemented Enter/Return triggering the item enter event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
828
diff
changeset
|
1462 |
867
139acecd6ca0
Guess I wanted to trap didClickTableColumn instead of mouseDownInHeaderOfTableColumn to avoid spurious events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
866
diff
changeset
|
1463 -(void)tableView:(NSTableView *)tableView didClickTableColumn:(NSTableColumn *)tableColumn |
813
7fa26d8cc8d0
Fix for column click handler not working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
812
diff
changeset
|
1464 { |
7fa26d8cc8d0
Fix for column click handler not working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
812
diff
changeset
|
1465 NSUInteger index = [tvcols indexOfObject:tableColumn]; |
7fa26d8cc8d0
Fix for column click handler not working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
812
diff
changeset
|
1466 |
803
8555ac1bcbcd
Attempt at implementing column click events. Doesn't seem to work yet but needed to commit before switching to laptop.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
802
diff
changeset
|
1467 /* Handler for column click class */ |
813
7fa26d8cc8d0
Fix for column click handler not working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
812
diff
changeset
|
1468 _event_handler(self, (NSEvent *)index, 17); |
803
8555ac1bcbcd
Attempt at implementing column click events. Doesn't seem to work yet but needed to commit before switching to laptop.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
802
diff
changeset
|
1469 } |
659
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
1470 -(void)selectionChanged:(id)sender |
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
1471 { |
703
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
1472 /* Handler for container class */ |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1473 _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
|
1474 /* Handler for listbox class */ |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1475 _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
|
1476 } |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1477 -(NSMenu *)menuForEvent:(NSEvent *)event |
659
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
1478 { |
710
78460ff977c1
Finishing up tree event/signal handlers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
709
diff
changeset
|
1479 int row; |
78460ff977c1
Finishing up tree event/signal handlers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
709
diff
changeset
|
1480 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
|
1481 row = (int)[self rowAtPoint:where]; |
78460ff977c1
Finishing up tree event/signal handlers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
709
diff
changeset
|
1482 _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
|
1483 return nil; |
659
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
1484 } |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1485 -(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
|
1486 @end |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1487 |
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
|
1488 /* 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
|
1489 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
|
1490 { |
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
|
1491 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
|
1492 { |
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
|
1493 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
|
1494 int z; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1495 |
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
|
1496 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
|
1497 { |
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
|
1498 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
|
1499 NSMutableArray *children = (NSMutableArray *)[pnt pointerAtIndex:3]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1500 |
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
|
1501 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
|
1502 { |
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
|
1503 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
|
1504 { |
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
|
1505 _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
|
1506 } |
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
|
1507 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
|
1508 { |
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
|
1509 _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
|
1510 } |
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
|
1511 } |
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
|
1512 } |
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
|
1513 } |
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
|
1514 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
|
1515 { |
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
|
1516 [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
|
1517 } |
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
|
1518 } |
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
|
1519 |
680
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1520 /* Subclass for a Tree type */ |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1521 @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
|
1522 #ifdef BUILDING_FOR_SNOW_LEOPARD |
813
7fa26d8cc8d0
Fix for column click handler not working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
812
diff
changeset
|
1523 <NSOutlineViewDataSource,NSOutlineViewDelegate> |
717
17923b931393
Fixes for building for MacOS 10.5 and PPC
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
715
diff
changeset
|
1524 #endif |
680
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1525 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1526 void *userdata; |
882
1e7b7f870d88
Experimental change to use a single column for holding the filename and icon on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
881
diff
changeset
|
1527 NSTableColumn *treecol; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1528 NSMutableArray *data; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1529 /* 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
|
1530 * 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
|
1531 */ |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1532 id scrollview; |
810
746cdd753e7a
Added coloring support for the Container/Tree/Listbox controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
809
diff
changeset
|
1533 NSColor *fgcolor; |
680
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1534 } |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1535 -(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
|
1536 -(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
|
1537 -(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
|
1538 -(id)outlineView:(NSOutlineView *)outlineView objectValueForTableColumn:(NSTableColumn *)tableColumn byItem:(id)item; |
882
1e7b7f870d88
Experimental change to use a single column for holding the filename and icon on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
881
diff
changeset
|
1539 -(void)outlineView:(NSOutlineView *)outlineView willDisplayCell:(id)cell forTableColumn:(NSTableColumn *)tableColumn item:(id)item; |
710
78460ff977c1
Finishing up tree event/signal handlers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
709
diff
changeset
|
1540 -(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
|
1541 -(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
|
1542 -(void *)userdata; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1543 -(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
|
1544 -(void)treeSelectionChanged:(id)sender; |
722
5a8d5161651d
Implemented tree expand event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
721
diff
changeset
|
1545 -(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
|
1546 -(NSScrollView *)scrollview; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1547 -(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
|
1548 -(void)deleteNode:(NSPointerArray *)item; |
810
746cdd753e7a
Added coloring support for the Container/Tree/Listbox controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
809
diff
changeset
|
1549 -(void)setForegroundColor:(NSColor *)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
|
1550 -(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
|
1551 @end |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1552 |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1553 @implementation DWTree |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1554 -(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
|
1555 { |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1556 self = [super init]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1557 |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1558 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
|
1559 { |
882
1e7b7f870d88
Experimental change to use a single column for holding the filename and icon on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
881
diff
changeset
|
1560 treecol = [[NSTableColumn alloc] init]; |
1e7b7f870d88
Experimental change to use a single column for holding the filename and icon on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
881
diff
changeset
|
1561 NSBrowserCell *browsercell = [[[NSBrowserCell alloc] init] autorelease]; |
1e7b7f870d88
Experimental change to use a single column for holding the filename and icon on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
881
diff
changeset
|
1562 [browsercell setLeaf:YES]; |
1e7b7f870d88
Experimental change to use a single column for holding the filename and icon on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
881
diff
changeset
|
1563 [treecol setDataCell:browsercell]; |
1e7b7f870d88
Experimental change to use a single column for holding the filename and icon on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
881
diff
changeset
|
1564 [self addTableColumn:treecol]; |
1e7b7f870d88
Experimental change to use a single column for holding the filename and icon on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
881
diff
changeset
|
1565 [self setOutlineTableColumn:treecol]; |
743
4462bc7de1e3
Possible fix for container (and possibly tree) controls picking up combobox events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
742
diff
changeset
|
1566 [[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
|
1567 [[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
|
1568 } |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1569 return self; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1570 } |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1571 -(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
|
1572 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1573 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
|
1574 { |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1575 NSMutableArray *array = [item pointerAtIndex:3]; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1576 return array ? [array objectAtIndex:index] : nil; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1577 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1578 else |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1579 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1580 return [data objectAtIndex:index]; |
680
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1581 } |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1582 } |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1583 -(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
|
1584 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1585 return [self outlineView:outlineView numberOfChildrenOfItem:item] != 0; |
680
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1586 } |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1587 -(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
|
1588 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1589 if(item) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1590 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1591 if([item isKindOfClass:[NSPointerArray class]]) |
680
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1592 { |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1593 NSMutableArray *array = [item pointerAtIndex:3]; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1594 return array ? (int)[array count] : 0; |
680
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1595 } |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1596 else |
680
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1597 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1598 return 0; |
680
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1599 } |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1600 } |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1601 else |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1602 { |
680
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1603 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
|
1604 } |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1605 } |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1606 -(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
|
1607 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1608 if(item) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1609 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1610 if([item isKindOfClass:[NSPointerArray class]]) |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1611 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1612 NSPointerArray *this = (NSPointerArray *)item; |
680
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1613 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
|
1614 } |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1615 else |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1616 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1617 return nil; |
680
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1618 } |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1619 } |
680
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1620 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
|
1621 } |
882
1e7b7f870d88
Experimental change to use a single column for holding the filename and icon on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
881
diff
changeset
|
1622 -(void)outlineView:(NSOutlineView *)outlineView willDisplayCell:(id)cell forTableColumn:(NSTableColumn *)tableColumn item:(id)item |
1e7b7f870d88
Experimental change to use a single column for holding the filename and icon on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
881
diff
changeset
|
1623 { |
1e7b7f870d88
Experimental change to use a single column for holding the filename and icon on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
881
diff
changeset
|
1624 if([cell isMemberOfClass:[NSBrowserCell class]]) |
1e7b7f870d88
Experimental change to use a single column for holding the filename and icon on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
881
diff
changeset
|
1625 { |
1e7b7f870d88
Experimental change to use a single column for holding the filename and icon on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
881
diff
changeset
|
1626 NSPointerArray *this = (NSPointerArray *)item; |
1e7b7f870d88
Experimental change to use a single column for holding the filename and icon on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
881
diff
changeset
|
1627 NSImage *img = [this pointerAtIndex:0]; |
1e7b7f870d88
Experimental change to use a single column for holding the filename and icon on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
881
diff
changeset
|
1628 [(NSBrowserCell*)cell setImage:img]; |
1e7b7f870d88
Experimental change to use a single column for holding the filename and icon on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
881
diff
changeset
|
1629 } |
1e7b7f870d88
Experimental change to use a single column for holding the filename and icon on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
881
diff
changeset
|
1630 } |
710
78460ff977c1
Finishing up tree event/signal handlers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
709
diff
changeset
|
1631 -(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
|
1632 -(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
|
1633 { |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1634 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
|
1635 if(parent) |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1636 { |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1637 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
|
1638 if(!children) |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1639 { |
692
bd909322f40d
Added "retain"s to the DWTree/DWContainer/DWListBox classes memory allocation
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
691
diff
changeset
|
1640 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
|
1641 [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
|
1642 } |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1643 } |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1644 else |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1645 { |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1646 if(!data) |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1647 { |
692
bd909322f40d
Added "retain"s to the DWTree/DWContainer/DWListBox classes memory allocation
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
691
diff
changeset
|
1648 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
|
1649 } |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1650 } |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1651 [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
|
1652 } |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1653 -(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
|
1654 -(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
|
1655 -(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
|
1656 { |
710
78460ff977c1
Finishing up tree event/signal handlers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
709
diff
changeset
|
1657 /* 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
|
1658 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
|
1659 |
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
|
1660 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
|
1661 { |
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
|
1662 _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
|
1663 } |
710
78460ff977c1
Finishing up tree event/signal handlers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
709
diff
changeset
|
1664 } |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1665 -(void)treeItemExpanded:(NSNotification *)notification |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1666 { |
722
5a8d5161651d
Implemented tree expand event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
721
diff
changeset
|
1667 id item = [[notification userInfo ] objectForKey: @"NSObject"]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1668 |
722
5a8d5161651d
Implemented tree expand event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
721
diff
changeset
|
1669 if(item) |
5a8d5161651d
Implemented tree expand event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
721
diff
changeset
|
1670 { |
5a8d5161651d
Implemented tree expand event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
721
diff
changeset
|
1671 _event_handler(self, (void *)item, 16); |
5a8d5161651d
Implemented tree expand event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
721
diff
changeset
|
1672 } |
5a8d5161651d
Implemented tree expand event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
721
diff
changeset
|
1673 } |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1674 -(NSMenu *)menuForEvent:(NSEvent *)event |
710
78460ff977c1
Finishing up tree event/signal handlers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
709
diff
changeset
|
1675 { |
78460ff977c1
Finishing up tree event/signal handlers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
709
diff
changeset
|
1676 int row; |
78460ff977c1
Finishing up tree event/signal handlers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
709
diff
changeset
|
1677 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
|
1678 row = (int)[self rowAtPoint:where]; |
78460ff977c1
Finishing up tree event/signal handlers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
709
diff
changeset
|
1679 id item = [self itemAtRow:row]; |
78460ff977c1
Finishing up tree event/signal handlers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
709
diff
changeset
|
1680 NSString *nstr = [item pointerAtIndex:1]; |
78460ff977c1
Finishing up tree event/signal handlers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
709
diff
changeset
|
1681 _event_handler(self, (NSEvent *)[nstr UTF8String], 10); |
78460ff977c1
Finishing up tree event/signal handlers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
709
diff
changeset
|
1682 return nil; |
709
5a268d5f1cfa
Fixes for tree event handling. Still more to come shortly...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
708
diff
changeset
|
1683 } |
680
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1684 -(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
|
1685 -(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
|
1686 -(void)deleteNode:(NSPointerArray *)item { _free_tree_recurse(data, item); } |
810
746cdd753e7a
Added coloring support for the Container/Tree/Listbox controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
809
diff
changeset
|
1687 -(void)setForegroundColor:(NSColor *)input |
746cdd753e7a
Added coloring support for the Container/Tree/Listbox controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
809
diff
changeset
|
1688 { |
882
1e7b7f870d88
Experimental change to use a single column for holding the filename and icon on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
881
diff
changeset
|
1689 NSTextFieldCell *cell = [treecol dataCell]; |
810
746cdd753e7a
Added coloring support for the Container/Tree/Listbox controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
809
diff
changeset
|
1690 fgcolor = input; |
746cdd753e7a
Added coloring support for the Container/Tree/Listbox controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
809
diff
changeset
|
1691 [fgcolor retain]; |
746cdd753e7a
Added coloring support for the Container/Tree/Listbox controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
809
diff
changeset
|
1692 [cell setTextColor:fgcolor]; |
746cdd753e7a
Added coloring support for the Container/Tree/Listbox controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
809
diff
changeset
|
1693 } |
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
|
1694 -(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
|
1695 -(void)dealloc |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1696 { |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1697 UserData *root = userdata; |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1698 _remove_userdata(&root, NULL, TRUE); |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1699 _free_tree_recurse(data, NULL); |
882
1e7b7f870d88
Experimental change to use a single column for holding the filename and icon on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
881
diff
changeset
|
1700 [treecol release]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1701 [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
|
1702 } |
680
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1703 @end |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
1704 |
656
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
1705 /* Subclass for a Calendar type */ |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1706 @interface DWCalendar : NSDatePicker |
655
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
1707 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1708 void *userdata; |
655
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
1709 } |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
1710 -(void *)userdata; |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
1711 -(void)setUserdata:(void *)input; |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
1712 @end |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
1713 |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
1714 @implementation DWCalendar |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
1715 -(void *)userdata { return userdata; } |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
1716 -(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
|
1717 -(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
|
1718 @end |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
1719 |
656
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
1720 /* Subclass for a Combobox type */ |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1721 @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
|
1722 #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
|
1723 <NSComboBoxDelegate> |
17923b931393
Fixes for building for MacOS 10.5 and PPC
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
715
diff
changeset
|
1724 #endif |
656
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
1725 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1726 void *userdata; |
768
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
1727 id clickDefault; |
656
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
1728 } |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
1729 -(void *)userdata; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
1730 -(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
|
1731 -(void)comboBoxSelectionDidChange:(NSNotification *)not; |
768
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
1732 -(void)setClickDefault:(id)input; |
656
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
1733 @end |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
1734 |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
1735 @implementation DWComboBox |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
1736 -(void *)userdata { return userdata; } |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
1737 -(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
|
1738 -(void)comboBoxSelectionDidChange:(NSNotification *)not { _event_handler(self, (void *)[self indexOfSelectedItem], 11); } |
768
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
1739 -(void)setClickDefault:(id)input { clickDefault = input; } |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
1740 -(void)keyUp:(NSEvent *)theEvent |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
1741 { |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
1742 if(clickDefault && [[theEvent charactersIgnoringModifiers] characterAtIndex:0] == VK_RETURN) |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
1743 { |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
1744 [[self window] makeFirstResponder:clickDefault]; |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
1745 } else |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
1746 { |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
1747 [super keyUp:theEvent]; |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
1748 } |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
1749 } |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1750 -(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
|
1751 @end |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1752 |
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
|
1753 /* 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
|
1754 /* 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
|
1755 @interface DWStepper : NSStepper |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1756 { |
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
|
1757 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
|
1758 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
|
1759 } |
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
|
1760 -(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
|
1761 -(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
|
1762 -(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
|
1763 -(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
|
1764 -(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
|
1765 -(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
|
1766 @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
|
1767 |
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
|
1768 @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
|
1769 -(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
|
1770 -(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
|
1771 -(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
|
1772 -(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
|
1773 -(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
|
1774 { |
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
|
1775 [super mouseDown:event]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1776 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
|
1777 { |
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
|
1778 [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
|
1779 _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
|
1780 } |
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
|
1781 } |
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
|
1782 -(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
|
1783 { |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1784 [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
|
1785 _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
|
1786 } |
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
|
1787 @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
|
1788 |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1789 /* Subclass for a Spinbutton type */ |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1790 @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
|
1791 #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
|
1792 <NSTextFieldDelegate> |
17923b931393
Fixes for building for MacOS 10.5 and PPC
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
715
diff
changeset
|
1793 #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
|
1794 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1795 void *userdata; |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1796 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
|
1797 DWStepper *stepper; |
768
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
1798 id clickDefault; |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1799 } |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1800 -(id)init; |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1801 -(void *)userdata; |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1802 -(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
|
1803 -(NSTextField *)textfield; |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1804 -(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
|
1805 -(void)controlTextDidChange:(NSNotification *)aNotification; |
768
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
1806 -(void)setClickDefault:(id)input; |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1807 @end |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1808 |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1809 @implementation DWSpinButton |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1810 -(id)init |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1811 { |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1812 self = [super init]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1813 |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1814 if(self) |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1815 { |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1816 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
|
1817 [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
|
1818 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
|
1819 [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
|
1820 [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
|
1821 [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
|
1822 [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
|
1823 [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
|
1824 } |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1825 return self; |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1826 } |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1827 -(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
|
1828 -(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
|
1829 -(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
|
1830 -(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
|
1831 -(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
|
1832 { |
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
|
1833 [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
|
1834 [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
|
1835 _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
|
1836 } |
768
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
1837 -(void)setClickDefault:(id)input { clickDefault = input; } |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
1838 -(void)keyUp:(NSEvent *)theEvent |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
1839 { |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
1840 if(clickDefault && [[theEvent charactersIgnoringModifiers] characterAtIndex:0] == VK_RETURN) |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
1841 { |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
1842 [[self window] makeFirstResponder:clickDefault]; |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
1843 } |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
1844 else |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
1845 { |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
1846 [super keyUp:theEvent]; |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
1847 } |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
1848 } |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
1849 -(void)performClick:(id)sender { [textfield performClick:sender]; } |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1850 -(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
|
1851 @end |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
1852 |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
1853 /* 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
|
1854 * 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
|
1855 * 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
|
1856 */ |
014b02436c1f
Added MDI simulation code... the MDI "window" will just be a box for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
683
diff
changeset
|
1857 @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
|
1858 @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
|
1859 |
014b02436c1f
Added MDI simulation code... the MDI "window" will just be a box for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
683
diff
changeset
|
1860 @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
|
1861 @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
|
1862 |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1863 /* 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
|
1864 */ |
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
|
1865 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
|
1866 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1867 SignalHandler *new = malloc(sizeof(SignalHandler)); |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
1868 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1869 new->message = message; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1870 new->window = window; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1871 new->id = msgid; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1872 new->signalfunction = signalfunction; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1873 new->data = data; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1874 new->next = NULL; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
1875 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1876 if (!Root) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1877 Root = new; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1878 else |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1879 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1880 SignalHandler *prev = NULL, *tmp = Root; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1881 while(tmp) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1882 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1883 if(tmp->message == message && |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1884 tmp->window == window && |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1885 tmp->id == msgid && |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1886 tmp->signalfunction == signalfunction) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1887 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1888 tmp->data = data; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1889 free(new); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1890 return; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1891 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1892 prev = tmp; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1893 tmp = tmp->next; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1894 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1895 if(prev) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1896 prev->next = new; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1897 else |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1898 Root = new; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1899 } |
650
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 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1902 /* 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
|
1903 ULONG _findsigmessage(char *signame) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1904 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1905 int z; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
1906 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1907 for(z=0;z<SIGNALMAX;z++) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1908 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1909 if(strcasecmp(signame, SignalTranslate[z].name) == 0) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1910 return SignalTranslate[z].message; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1911 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
1912 return 0L; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1913 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1914 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1915 unsigned long _foreground = 0xAAAAAA, _background = 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1916 |
916
44a0f9a2e8f9
Experimental change, pulling the resize event handling out of the resizer code on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
915
diff
changeset
|
1917 void _handle_resize_events(Box *thisbox) |
44a0f9a2e8f9
Experimental change, pulling the resize event handling out of the resizer code on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
915
diff
changeset
|
1918 { |
44a0f9a2e8f9
Experimental change, pulling the resize event handling out of the resizer code on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
915
diff
changeset
|
1919 int z; |
44a0f9a2e8f9
Experimental change, pulling the resize event handling out of the resizer code on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
915
diff
changeset
|
1920 |
44a0f9a2e8f9
Experimental change, pulling the resize event handling out of the resizer code on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
915
diff
changeset
|
1921 for(z=0;z<thisbox->count;z++) |
44a0f9a2e8f9
Experimental change, pulling the resize event handling out of the resizer code on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
915
diff
changeset
|
1922 { |
44a0f9a2e8f9
Experimental change, pulling the resize event handling out of the resizer code on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
915
diff
changeset
|
1923 id handle = thisbox->items[z].hwnd; |
44a0f9a2e8f9
Experimental change, pulling the resize event handling out of the resizer code on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
915
diff
changeset
|
1924 |
44a0f9a2e8f9
Experimental change, pulling the resize event handling out of the resizer code on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
915
diff
changeset
|
1925 if(thisbox->items[z].type == TYPEBOX) |
44a0f9a2e8f9
Experimental change, pulling the resize event handling out of the resizer code on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
915
diff
changeset
|
1926 { |
44a0f9a2e8f9
Experimental change, pulling the resize event handling out of the resizer code on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
915
diff
changeset
|
1927 Box *tmp = [handle box]; |
44a0f9a2e8f9
Experimental change, pulling the resize event handling out of the resizer code on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
915
diff
changeset
|
1928 |
44a0f9a2e8f9
Experimental change, pulling the resize event handling out of the resizer code on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
915
diff
changeset
|
1929 if(tmp) |
44a0f9a2e8f9
Experimental change, pulling the resize event handling out of the resizer code on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
915
diff
changeset
|
1930 { |
44a0f9a2e8f9
Experimental change, pulling the resize event handling out of the resizer code on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
915
diff
changeset
|
1931 _handle_resize_events(tmp); |
44a0f9a2e8f9
Experimental change, pulling the resize event handling out of the resizer code on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
915
diff
changeset
|
1932 } |
44a0f9a2e8f9
Experimental change, pulling the resize event handling out of the resizer code on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
915
diff
changeset
|
1933 } |
44a0f9a2e8f9
Experimental change, pulling the resize event handling out of the resizer code on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
915
diff
changeset
|
1934 else |
44a0f9a2e8f9
Experimental change, pulling the resize event handling out of the resizer code on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
915
diff
changeset
|
1935 { |
44a0f9a2e8f9
Experimental change, pulling the resize event handling out of the resizer code on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
915
diff
changeset
|
1936 if([handle isMemberOfClass:[DWRender class]]) |
44a0f9a2e8f9
Experimental change, pulling the resize event handling out of the resizer code on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
915
diff
changeset
|
1937 { |
44a0f9a2e8f9
Experimental change, pulling the resize event handling out of the resizer code on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
915
diff
changeset
|
1938 DWRender *render = (DWRender *)handle; |
44a0f9a2e8f9
Experimental change, pulling the resize event handling out of the resizer code on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
915
diff
changeset
|
1939 NSSize oldsize = [render size]; |
44a0f9a2e8f9
Experimental change, pulling the resize event handling out of the resizer code on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
915
diff
changeset
|
1940 NSSize newsize = [render frame].size; |
44a0f9a2e8f9
Experimental change, pulling the resize event handling out of the resizer code on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
915
diff
changeset
|
1941 NSWindow *window = [render window]; |
44a0f9a2e8f9
Experimental change, pulling the resize event handling out of the resizer code on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
915
diff
changeset
|
1942 |
44a0f9a2e8f9
Experimental change, pulling the resize event handling out of the resizer code on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
915
diff
changeset
|
1943 if([window preferredBackingLocation] != NSWindowBackingLocationVideoMemory) |
44a0f9a2e8f9
Experimental change, pulling the resize event handling out of the resizer code on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
915
diff
changeset
|
1944 { |
44a0f9a2e8f9
Experimental change, pulling the resize event handling out of the resizer code on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
915
diff
changeset
|
1945 [window setPreferredBackingLocation:NSWindowBackingLocationVideoMemory]; |
44a0f9a2e8f9
Experimental change, pulling the resize event handling out of the resizer code on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
915
diff
changeset
|
1946 } |
44a0f9a2e8f9
Experimental change, pulling the resize event handling out of the resizer code on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
915
diff
changeset
|
1947 |
44a0f9a2e8f9
Experimental change, pulling the resize event handling out of the resizer code on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
915
diff
changeset
|
1948 /* Eliminate duplicate configure requests */ |
44a0f9a2e8f9
Experimental change, pulling the resize event handling out of the resizer code on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
915
diff
changeset
|
1949 if(oldsize.width != newsize.width || oldsize.height != newsize.height) |
44a0f9a2e8f9
Experimental change, pulling the resize event handling out of the resizer code on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
915
diff
changeset
|
1950 { |
44a0f9a2e8f9
Experimental change, pulling the resize event handling out of the resizer code on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
915
diff
changeset
|
1951 if(newsize.width > 0 && newsize.height > 0) |
44a0f9a2e8f9
Experimental change, pulling the resize event handling out of the resizer code on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
915
diff
changeset
|
1952 { |
44a0f9a2e8f9
Experimental change, pulling the resize event handling out of the resizer code on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
915
diff
changeset
|
1953 [render setSize:newsize]; |
44a0f9a2e8f9
Experimental change, pulling the resize event handling out of the resizer code on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
915
diff
changeset
|
1954 _event_handler(handle, nil, 1); |
44a0f9a2e8f9
Experimental change, pulling the resize event handling out of the resizer code on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
915
diff
changeset
|
1955 } |
44a0f9a2e8f9
Experimental change, pulling the resize event handling out of the resizer code on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
915
diff
changeset
|
1956 } |
44a0f9a2e8f9
Experimental change, pulling the resize event handling out of the resizer code on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
915
diff
changeset
|
1957 } |
44a0f9a2e8f9
Experimental change, pulling the resize event handling out of the resizer code on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
915
diff
changeset
|
1958 /* Special handling for notebook controls */ |
44a0f9a2e8f9
Experimental change, pulling the resize event handling out of the resizer code on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
915
diff
changeset
|
1959 else if([handle isMemberOfClass:[DWNotebook class]]) |
44a0f9a2e8f9
Experimental change, pulling the resize event handling out of the resizer code on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
915
diff
changeset
|
1960 { |
44a0f9a2e8f9
Experimental change, pulling the resize event handling out of the resizer code on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
915
diff
changeset
|
1961 DWNotebook *notebook = (DWNotebook *)handle; |
44a0f9a2e8f9
Experimental change, pulling the resize event handling out of the resizer code on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
915
diff
changeset
|
1962 DWNotebookPage *notepage = (DWNotebookPage *)[notebook selectedTabViewItem]; |
44a0f9a2e8f9
Experimental change, pulling the resize event handling out of the resizer code on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
915
diff
changeset
|
1963 id view = [notepage view]; |
44a0f9a2e8f9
Experimental change, pulling the resize event handling out of the resizer code on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
915
diff
changeset
|
1964 |
44a0f9a2e8f9
Experimental change, pulling the resize event handling out of the resizer code on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
915
diff
changeset
|
1965 if(view != nil) |
44a0f9a2e8f9
Experimental change, pulling the resize event handling out of the resizer code on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
915
diff
changeset
|
1966 { |
44a0f9a2e8f9
Experimental change, pulling the resize event handling out of the resizer code on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
915
diff
changeset
|
1967 Box *box = [view box]; |
44a0f9a2e8f9
Experimental change, pulling the resize event handling out of the resizer code on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
915
diff
changeset
|
1968 _handle_resize_events(box); |
44a0f9a2e8f9
Experimental change, pulling the resize event handling out of the resizer code on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
915
diff
changeset
|
1969 } |
44a0f9a2e8f9
Experimental change, pulling the resize event handling out of the resizer code on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
915
diff
changeset
|
1970 } |
44a0f9a2e8f9
Experimental change, pulling the resize event handling out of the resizer code on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
915
diff
changeset
|
1971 /* Handle laying out scrollviews... if required space is less |
44a0f9a2e8f9
Experimental change, pulling the resize event handling out of the resizer code on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
915
diff
changeset
|
1972 * than available space, then expand. Otherwise use required space. |
44a0f9a2e8f9
Experimental change, pulling the resize event handling out of the resizer code on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
915
diff
changeset
|
1973 */ |
44a0f9a2e8f9
Experimental change, pulling the resize event handling out of the resizer code on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
915
diff
changeset
|
1974 else if([handle isMemberOfClass:[DWScrollBox class]]) |
44a0f9a2e8f9
Experimental change, pulling the resize event handling out of the resizer code on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
915
diff
changeset
|
1975 { |
44a0f9a2e8f9
Experimental change, pulling the resize event handling out of the resizer code on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
915
diff
changeset
|
1976 DWScrollBox *scrollbox = (DWScrollBox *)handle; |
44a0f9a2e8f9
Experimental change, pulling the resize event handling out of the resizer code on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
915
diff
changeset
|
1977 DWBox *contentbox = [scrollbox documentView]; |
44a0f9a2e8f9
Experimental change, pulling the resize event handling out of the resizer code on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
915
diff
changeset
|
1978 Box *thisbox = [contentbox box]; |
44a0f9a2e8f9
Experimental change, pulling the resize event handling out of the resizer code on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
915
diff
changeset
|
1979 |
44a0f9a2e8f9
Experimental change, pulling the resize event handling out of the resizer code on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
915
diff
changeset
|
1980 /* Get the required space for the box */ |
44a0f9a2e8f9
Experimental change, pulling the resize event handling out of the resizer code on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
915
diff
changeset
|
1981 _handle_resize_events(thisbox); |
44a0f9a2e8f9
Experimental change, pulling the resize event handling out of the resizer code on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
915
diff
changeset
|
1982 } |
44a0f9a2e8f9
Experimental change, pulling the resize event handling out of the resizer code on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
915
diff
changeset
|
1983 } |
44a0f9a2e8f9
Experimental change, pulling the resize event handling out of the resizer code on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
915
diff
changeset
|
1984 } |
44a0f9a2e8f9
Experimental change, pulling the resize event handling out of the resizer code on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
915
diff
changeset
|
1985 } |
44a0f9a2e8f9
Experimental change, pulling the resize event handling out of the resizer code on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
915
diff
changeset
|
1986 |
806
16964b141964
More accurate groupbox paddig calculations. Title rectangle is now calculated on the fly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
805
diff
changeset
|
1987 /* Default border is 5.0 according to the documentation */ |
16964b141964
More accurate groupbox paddig calculations. Title rectangle is now calculated on the fly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
805
diff
changeset
|
1988 #define _DW_GROUPBOX_BORDER 5 |
796
3a3fae1f31bd
Initial groupbox padding calculation fix. This may still need more work... very simple version.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
795
diff
changeset
|
1989 |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1990 /* 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
|
1991 * and does expansion as necessary. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1992 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1993 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
|
1994 int pass, int *usedpadx, int *usedpady) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1995 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1996 int z, currentx = 0, currenty = 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1997 int uymax = 0, uxmax = 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1998 int upymax = 0, upxmax = 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1999 /* Used for the SIZEEXPAND */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2000 int nux = *usedx, nuy = *usedy; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2001 int nupx = *usedpadx, nupy = *usedpady; |
798
1b0a0775ec19
Ok... groupbox calculation fix try #2!
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
797
diff
changeset
|
2002 int thispadx = thisbox->pad * 2; |
1b0a0775ec19
Ok... groupbox calculation fix try #2!
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
797
diff
changeset
|
2003 int thispady = thisbox->pad * 2; |
1b0a0775ec19
Ok... groupbox calculation fix try #2!
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
797
diff
changeset
|
2004 |
1b0a0775ec19
Ok... groupbox calculation fix try #2!
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
797
diff
changeset
|
2005 /* Handle special groupbox case */ |
1b0a0775ec19
Ok... groupbox calculation fix try #2!
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
797
diff
changeset
|
2006 if(thisbox->grouphwnd) |
1b0a0775ec19
Ok... groupbox calculation fix try #2!
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
797
diff
changeset
|
2007 { |
806
16964b141964
More accurate groupbox paddig calculations. Title rectangle is now calculated on the fly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
805
diff
changeset
|
2008 DWGroupBox *groupbox = thisbox->grouphwnd; |
16964b141964
More accurate groupbox paddig calculations. Title rectangle is now calculated on the fly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
805
diff
changeset
|
2009 NSRect titleRect; |
16964b141964
More accurate groupbox paddig calculations. Title rectangle is now calculated on the fly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
805
diff
changeset
|
2010 |
16964b141964
More accurate groupbox paddig calculations. Title rectangle is now calculated on the fly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
805
diff
changeset
|
2011 /* Get the title size for a more accurate groupbox padding size */ |
16964b141964
More accurate groupbox paddig calculations. Title rectangle is now calculated on the fly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
805
diff
changeset
|
2012 titleRect = [groupbox titleRect]; |
16964b141964
More accurate groupbox paddig calculations. Title rectangle is now calculated on the fly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
805
diff
changeset
|
2013 thisbox->grouppadx = _DW_GROUPBOX_BORDER * 2; |
16964b141964
More accurate groupbox paddig calculations. Title rectangle is now calculated on the fly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
805
diff
changeset
|
2014 thisbox->grouppady = (_DW_GROUPBOX_BORDER * 2) + titleRect.size.height; |
799
3aa5d0777af2
So after looking at the Windows code... I realized it worked differently than I was thinking...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
798
diff
changeset
|
2015 |
3aa5d0777af2
So after looking at the Windows code... I realized it worked differently than I was thinking...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
798
diff
changeset
|
2016 (*usedx) += thisbox->grouppadx; |
3aa5d0777af2
So after looking at the Windows code... I realized it worked differently than I was thinking...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
798
diff
changeset
|
2017 (*usedpadx) += thisbox->grouppadx; |
3aa5d0777af2
So after looking at the Windows code... I realized it worked differently than I was thinking...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
798
diff
changeset
|
2018 (*usedy) += thisbox->grouppady; |
3aa5d0777af2
So after looking at the Windows code... I realized it worked differently than I was thinking...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
798
diff
changeset
|
2019 (*usedpady) += thisbox->grouppady; |
798
1b0a0775ec19
Ok... groupbox calculation fix try #2!
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
797
diff
changeset
|
2020 } |
1b0a0775ec19
Ok... groupbox calculation fix try #2!
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
797
diff
changeset
|
2021 |
1b0a0775ec19
Ok... groupbox calculation fix try #2!
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
797
diff
changeset
|
2022 (*usedx) += thispadx; |
1b0a0775ec19
Ok... groupbox calculation fix try #2!
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
797
diff
changeset
|
2023 (*usedy) += thispady; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2024 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2025 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
|
2026 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2027 if(thisbox->items[z].type == TYPEBOX) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2028 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2029 int initialx, initialy; |
792
fc6a626a96cc
Initial groupbox support. Sizing of the content frame is not quite right yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
768
diff
changeset
|
2030 id box = thisbox->items[z].hwnd; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2031 Box *tmp = [box box]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2032 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2033 initialx = x - (*usedx); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2034 initialy = y - (*usedy); |
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 if(tmp) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2037 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2038 int newx, newy; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2039 int nux = *usedx, nuy = *usedy; |
798
1b0a0775ec19
Ok... groupbox calculation fix try #2!
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
797
diff
changeset
|
2040 int tmppadx = tmp->pad*2; |
1b0a0775ec19
Ok... groupbox calculation fix try #2!
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
797
diff
changeset
|
2041 int tmppady = tmp->pad*2; |
796
3a3fae1f31bd
Initial groupbox padding calculation fix. This may still need more work... very simple version.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
795
diff
changeset
|
2042 int upx, upy; |
3a3fae1f31bd
Initial groupbox padding calculation fix. This may still need more work... very simple version.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
795
diff
changeset
|
2043 |
798
1b0a0775ec19
Ok... groupbox calculation fix try #2!
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
797
diff
changeset
|
2044 upx = *usedpadx + tmppadx; |
1b0a0775ec19
Ok... groupbox calculation fix try #2!
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
797
diff
changeset
|
2045 upy = *usedpady + tmppady; |
650
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 /* 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
|
2048 * 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
|
2049 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2050 if(pass == 2) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2051 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2052 int deep = *depth + 1; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2053 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2054 _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
|
2055 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2056 tmp->upx = upx - *usedpadx; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2057 tmp->upy = upy - *usedpady; |
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 newx = x - nux; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2060 newy = y - nuy; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2061 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2062 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
|
2063 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
|
2064 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2065 tmp->parentxratio = thisbox->xratio; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2066 tmp->parentyratio = thisbox->yratio; |
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 tmp->parentpad = tmp->pad; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2069 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2070 /* Just in case */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2071 tmp->xratio = thisbox->xratio; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2072 tmp->yratio = thisbox->yratio; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2073 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2074 if(thisbox->type == DW_VERT) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2075 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2076 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
|
2077 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
|
2078 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2079 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2080 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2081 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
|
2082 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
|
2083 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2084 if(thisbox->type == DW_HORZ) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2085 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2086 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
|
2087 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
|
2088 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2089 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2090 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2091 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
|
2092 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
|
2093 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2094 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2095 nux = *usedx; nuy = *usedy; |
798
1b0a0775ec19
Ok... groupbox calculation fix try #2!
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
797
diff
changeset
|
2096 upx = *usedpadx + tmppadx; upy = *usedpady + tmppady; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2097 } |
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 (*depth)++; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2100 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2101 _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
|
2102 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2103 (*depth)--; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2104 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2105 newx = x - nux; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2106 newy = y - nuy; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2107 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2108 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
|
2109 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
|
2110 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2111 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2112 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2113 if(pass > 1 && *depth > 0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2114 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2115 if(thisbox->type == DW_VERT) |
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 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
|
2118 thisbox->items[z].xratio = 1.0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2119 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2120 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
|
2121 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2122 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2123 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2124 if(thisbox->minwidth-thisbox->upx == 0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2125 thisbox->items[z].xratio = 1.0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2126 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2127 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
|
2128 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2129 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2130 if(thisbox->type == DW_HORZ) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2131 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2132 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
|
2133 thisbox->items[z].yratio = 1.0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2134 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2135 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
|
2136 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2137 else |
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 if(thisbox->minheight-thisbox->upy == 0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2140 thisbox->items[z].yratio = 1.0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2141 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2142 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
|
2143 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2144 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2145 if(thisbox->items[z].type == TYPEBOX) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2146 { |
792
fc6a626a96cc
Initial groupbox support. Sizing of the content frame is not quite right yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
768
diff
changeset
|
2147 id box = thisbox->items[z].hwnd; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2148 Box *tmp = [box box]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2149 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2150 if(tmp) |
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 tmp->parentxratio = thisbox->items[z].xratio; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2153 tmp->parentyratio = thisbox->items[z].yratio; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2154 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2155 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2156 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2157 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2158 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2159 thisbox->items[z].xratio = thisbox->xratio; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2160 thisbox->items[z].yratio = thisbox->yratio; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2161 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2162 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2163 if(thisbox->type == DW_VERT) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2164 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2165 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
|
2166 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
|
2167 if(thisbox->items[z].hsize != SIZEEXPAND) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2168 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2169 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
|
2170 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
|
2171 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2172 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2173 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2174 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
|
2175 upxmax = thisbox->items[z].pad*2; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2176 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2177 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2178 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2179 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2180 if(thisbox->items[z].width == -1) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2181 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2182 /* 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
|
2183 /* thisbox->items[z].width = */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2184 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2185 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2186 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2187 (*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
|
2188 if(thisbox->items[z].hsize != SIZEEXPAND) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2189 (*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
|
2190 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2191 (*usedpadx) += thisbox->items[z].pad*2; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2192 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2193 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2194 if(thisbox->type == DW_HORZ) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2195 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2196 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
|
2197 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
|
2198 if(thisbox->items[z].vsize != SIZEEXPAND) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2199 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2200 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
|
2201 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
|
2202 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2203 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2204 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2205 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
|
2206 upymax = thisbox->items[z].pad*2; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2207 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2208 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2209 else |
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 if(thisbox->items[z].height == -1) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2212 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2213 /* 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
|
2214 /* thisbox->items[z].height = */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2215 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2216 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2217 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2218 (*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
|
2219 if(thisbox->items[z].vsize != SIZEEXPAND) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2220 (*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
|
2221 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2222 (*usedpady) += thisbox->items[z].pad*2; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2223 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2224 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2225 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2226 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2227 (*usedx) += uxmax; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2228 (*usedy) += uymax; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2229 (*usedpadx) += upxmax; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2230 (*usedpady) += upymax; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2231 |
799
3aa5d0777af2
So after looking at the Windows code... I realized it worked differently than I was thinking...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
798
diff
changeset
|
2232 currentx += thisbox->pad; |
3aa5d0777af2
So after looking at the Windows code... I realized it worked differently than I was thinking...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
798
diff
changeset
|
2233 currenty += thisbox->pad; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2234 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2235 /* 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
|
2236 if(pass > 1) |
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 /* 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
|
2239 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
|
2240 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2241 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
|
2242 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
|
2243 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
|
2244 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
|
2245 /* 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
|
2246 if(thisbox->items[z].type == TYPEBOX) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2247 { |
792
fc6a626a96cc
Initial groupbox support. Sizing of the content frame is not quite right yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
768
diff
changeset
|
2248 id box = thisbox->items[z].hwnd; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2249 Box *tmp = [box box]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2250 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2251 if(tmp) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2252 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2253 if(*depth > 0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2254 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2255 float calcval; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2256 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2257 if(thisbox->type == DW_VERT) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2258 { |
798
1b0a0775ec19
Ok... groupbox calculation fix try #2!
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
797
diff
changeset
|
2259 calcval = (float)(tmp->minwidth-((thisbox->items[z].pad*2)+thispadx)); |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2260 if(calcval == 0.0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2261 tmp->xratio = thisbox->xratio; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2262 else |
798
1b0a0775ec19
Ok... groupbox calculation fix try #2!
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
797
diff
changeset
|
2263 tmp->xratio = ((float)((thisbox->items[z].width * thisbox->xratio)-((thisbox->items[z].pad*2)+thispadx)))/calcval; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2264 tmp->width = thisbox->items[z].width; |
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 if(thisbox->type == DW_HORZ) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2267 { |
798
1b0a0775ec19
Ok... groupbox calculation fix try #2!
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
797
diff
changeset
|
2268 calcval = (float)(tmp->minheight-((thisbox->items[z].pad*2)+thispady)); |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2269 if(calcval == 0.0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2270 tmp->yratio = thisbox->yratio; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2271 else |
798
1b0a0775ec19
Ok... groupbox calculation fix try #2!
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
797
diff
changeset
|
2272 tmp->yratio = ((float)((thisbox->items[z].height * thisbox->yratio)-((thisbox->items[z].pad*2)+thispady)))/calcval; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2273 tmp->height = thisbox->items[z].height; |
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 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2276 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2277 (*depth)++; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2278 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2279 _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
|
2280 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2281 (*depth)--; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2282 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2283 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2284 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2285 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2286 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2287 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
|
2288 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2289 int height = thisbox->items[z].height; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2290 int width = thisbox->items[z].width; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2291 int pad = thisbox->items[z].pad; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2292 NSView *handle = thisbox->items[z].hwnd; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2293 NSPoint point; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2294 NSSize size; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2295 int vectorx, vectory; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2296 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2297 /* 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
|
2298 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
|
2299 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
|
2300 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2301 if(width > 0 && height > 0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2302 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2303 /* 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
|
2304 if(*depth == 0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2305 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2306 vectorx++; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2307 vectory++; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2308 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2309 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2310 /* 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
|
2311 if(thisbox->items[z].vsize != SIZEEXPAND) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2312 vectory = 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2313 if(thisbox->items[z].hsize != SIZEEXPAND) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2314 vectorx = 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2315 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2316 point.x = currentx + pad; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2317 point.y = currenty + pad; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2318 size.width = width + vectorx; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2319 size.height = height + vectory; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2320 [handle setFrameOrigin:point]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2321 [handle setFrameSize:size]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2322 |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2323 /* Special handling for notebook controls */ |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2324 if([handle isMemberOfClass:[DWNotebook class]]) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2325 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2326 DWNotebook *notebook = (DWNotebook *)handle; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2327 DWNotebookPage *notepage = (DWNotebookPage *)[notebook selectedTabViewItem]; |
792
fc6a626a96cc
Initial groupbox support. Sizing of the content frame is not quite right yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
768
diff
changeset
|
2328 id view = [notepage view]; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
2329 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2330 if(view != nil) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2331 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2332 Box *box = [view box]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2333 NSSize size = [view frame].size; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2334 _do_resize(box, size.width, size.height); |
916
44a0f9a2e8f9
Experimental change, pulling the resize event handling out of the resizer code on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
915
diff
changeset
|
2335 _handle_resize_events(box); |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2336 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2337 } |
837
89d4bad9c96e
Initial attempt at implementing the scrollbox on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
831
diff
changeset
|
2338 /* Handle laying out scrollviews... if required space is less |
89d4bad9c96e
Initial attempt at implementing the scrollbox on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
831
diff
changeset
|
2339 * than available space, then expand. Otherwise use required space. |
89d4bad9c96e
Initial attempt at implementing the scrollbox on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
831
diff
changeset
|
2340 */ |
89d4bad9c96e
Initial attempt at implementing the scrollbox on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
831
diff
changeset
|
2341 else if([handle isMemberOfClass:[DWScrollBox class]]) |
89d4bad9c96e
Initial attempt at implementing the scrollbox on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
831
diff
changeset
|
2342 { |
89d4bad9c96e
Initial attempt at implementing the scrollbox on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
831
diff
changeset
|
2343 int usedx = 0, usedy = 0, usedpadx = 0, usedpady = 0, depth = 0; |
89d4bad9c96e
Initial attempt at implementing the scrollbox on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
831
diff
changeset
|
2344 DWScrollBox *scrollbox = (DWScrollBox *)handle; |
89d4bad9c96e
Initial attempt at implementing the scrollbox on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
831
diff
changeset
|
2345 DWBox *contentbox = [scrollbox documentView]; |
89d4bad9c96e
Initial attempt at implementing the scrollbox on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
831
diff
changeset
|
2346 Box *thisbox = [contentbox box]; |
89d4bad9c96e
Initial attempt at implementing the scrollbox on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
831
diff
changeset
|
2347 NSSize contentsize = [scrollbox contentSize]; |
89d4bad9c96e
Initial attempt at implementing the scrollbox on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
831
diff
changeset
|
2348 |
89d4bad9c96e
Initial attempt at implementing the scrollbox on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
831
diff
changeset
|
2349 /* Get the required space for the box */ |
89d4bad9c96e
Initial attempt at implementing the scrollbox on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
831
diff
changeset
|
2350 _resize_box(thisbox, &depth, x, y, &usedx, &usedy, 1, &usedpadx, &usedpady); |
89d4bad9c96e
Initial attempt at implementing the scrollbox on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
831
diff
changeset
|
2351 |
89d4bad9c96e
Initial attempt at implementing the scrollbox on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
831
diff
changeset
|
2352 if(contentsize.width < usedx) |
89d4bad9c96e
Initial attempt at implementing the scrollbox on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
831
diff
changeset
|
2353 { |
89d4bad9c96e
Initial attempt at implementing the scrollbox on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
831
diff
changeset
|
2354 contentsize.width = usedx; |
89d4bad9c96e
Initial attempt at implementing the scrollbox on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
831
diff
changeset
|
2355 } |
89d4bad9c96e
Initial attempt at implementing the scrollbox on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
831
diff
changeset
|
2356 if(contentsize.height < usedy) |
89d4bad9c96e
Initial attempt at implementing the scrollbox on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
831
diff
changeset
|
2357 { |
89d4bad9c96e
Initial attempt at implementing the scrollbox on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
831
diff
changeset
|
2358 contentsize.height = usedy; |
89d4bad9c96e
Initial attempt at implementing the scrollbox on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
831
diff
changeset
|
2359 } |
89d4bad9c96e
Initial attempt at implementing the scrollbox on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
831
diff
changeset
|
2360 [contentbox setFrameSize:contentsize]; |
89d4bad9c96e
Initial attempt at implementing the scrollbox on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
831
diff
changeset
|
2361 |
89d4bad9c96e
Initial attempt at implementing the scrollbox on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
831
diff
changeset
|
2362 /* Layout the content of the scrollbox */ |
89d4bad9c96e
Initial attempt at implementing the scrollbox on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
831
diff
changeset
|
2363 _do_resize(thisbox, contentsize.width, contentsize.height); |
89d4bad9c96e
Initial attempt at implementing the scrollbox on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
831
diff
changeset
|
2364 } |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
2365 /* 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
|
2366 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
|
2367 { |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
2368 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
|
2369 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
|
2370 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
|
2371 [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
|
2372 [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
|
2373 [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
|
2374 [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
|
2375 } |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2376 else if([handle isMemberOfClass:[DWSplitBar class]] && size.width > 20 && size.height > 20) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2377 { |
677
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
2378 DWSplitBar *split = (DWSplitBar *)handle; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2379 float percent = [split percent]; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
2380 |
677
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
2381 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
|
2382 { |
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
2383 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
|
2384 [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
|
2385 } |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2386 } |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
2387 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2388 if(thisbox->type == DW_HORZ) |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2389 currentx += width + vectorx + (pad * 2); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2390 if(thisbox->type == DW_VERT) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2391 currenty += height + vectory + (pad * 2); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2392 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2393 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2394 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2395 return 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2396 } |
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 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
|
2399 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2400 if(x != 0 && y != 0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2401 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2402 if(thisbox) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2403 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2404 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
|
2405 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2406 _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
|
2407 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2408 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
|
2409 return; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2410 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2411 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
|
2412 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
|
2413 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2414 usedx = usedy = usedpadx = usedpady = depth = 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2415 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2416 _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
|
2417 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2418 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2419 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2420 |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
2421 NSMenu *_generate_main_menu() |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
2422 { |
751
eba6ab48c952
Runtime Snow Leopard checks where possible and visual fix for Leopard status text.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
749
diff
changeset
|
2423 NSString *applicationName = nil; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
2424 |
751
eba6ab48c952
Runtime Snow Leopard checks where possible and visual fix for Leopard status text.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
749
diff
changeset
|
2425 /* 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
|
2426 #ifdef BUILDING_FOR_SNOW_LEOPARD |
751
eba6ab48c952
Runtime Snow Leopard checks where possible and visual fix for Leopard status text.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
749
diff
changeset
|
2427 applicationName = [[NSRunningApplication currentApplication] localizedName]; |
717
17923b931393
Fixes for building for MacOS 10.5 and PPC
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
715
diff
changeset
|
2428 #endif |
751
eba6ab48c952
Runtime Snow Leopard checks where possible and visual fix for Leopard status text.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
749
diff
changeset
|
2429 if(applicationName == nil) |
eba6ab48c952
Runtime Snow Leopard checks where possible and visual fix for Leopard status text.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
749
diff
changeset
|
2430 { |
eba6ab48c952
Runtime Snow Leopard checks where possible and visual fix for Leopard status text.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
749
diff
changeset
|
2431 applicationName = [[NSProcessInfo processInfo] processName]; |
eba6ab48c952
Runtime Snow Leopard checks where possible and visual fix for Leopard status text.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
749
diff
changeset
|
2432 } |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
2433 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2434 /* Create the main menu */ |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2435 NSMenu * mainMenu = [[[NSMenu alloc] initWithTitle:@"MainMenu"] autorelease]; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
2436 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2437 NSMenuItem * mitem = [mainMenu addItemWithTitle:@"Apple" action:NULL keyEquivalent:@""]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2438 NSMenu * menu = [[[NSMenu alloc] initWithTitle:@"Apple"] autorelease]; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
2439 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2440 [DWApp performSelector:@selector(setAppleMenu:) withObject:menu]; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
2441 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2442 /* Setup the Application menu */ |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2443 NSMenuItem * item = [menu addItemWithTitle:[NSString stringWithFormat:@"%@ %@", NSLocalizedString(@"About", nil), applicationName] |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2444 action:@selector(orderFrontStandardAboutPanel:) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2445 keyEquivalent:@""]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2446 [item setTarget:DWApp]; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
2447 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2448 [menu addItem:[NSMenuItem separatorItem]]; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
2449 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2450 item = [menu addItemWithTitle:NSLocalizedString(@"Services", nil) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2451 action:NULL |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2452 keyEquivalent:@""]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2453 NSMenu * servicesMenu = [[[NSMenu alloc] initWithTitle:@"Services"] autorelease]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2454 [menu setSubmenu:servicesMenu forItem:item]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2455 [DWApp setServicesMenu:servicesMenu]; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
2456 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2457 [menu addItem:[NSMenuItem separatorItem]]; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
2458 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2459 item = [menu addItemWithTitle:[NSString stringWithFormat:@"%@ %@", NSLocalizedString(@"Hide", nil), applicationName] |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2460 action:@selector(hide:) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2461 keyEquivalent:@"h"]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2462 [item setTarget:DWApp]; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
2463 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2464 item = [menu addItemWithTitle:NSLocalizedString(@"Hide Others", nil) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2465 action:@selector(hideOtherApplications:) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2466 keyEquivalent:@"h"]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2467 [item setKeyEquivalentModifierMask:NSCommandKeyMask | NSAlternateKeyMask]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2468 [item setTarget:DWApp]; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
2469 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2470 item = [menu addItemWithTitle:NSLocalizedString(@"Show All", nil) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2471 action:@selector(unhideAllApplications:) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2472 keyEquivalent:@""]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2473 [item setTarget:DWApp]; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
2474 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2475 [menu addItem:[NSMenuItem separatorItem]]; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
2476 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2477 item = [menu addItemWithTitle:[NSString stringWithFormat:@"%@ %@", NSLocalizedString(@"Quit", nil), applicationName] |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2478 action:@selector(terminate:) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2479 keyEquivalent:@"q"]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2480 [item setTarget:DWApp]; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
2481 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2482 [mainMenu setSubmenu:menu forItem:mitem]; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
2483 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2484 return mainMenu; |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
2485 } |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
2486 |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
2487 /* |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2488 * 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
|
2489 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2490 void API dw_main(void) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2491 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
2492 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
|
2493 DWThread = dw_thread_id(); |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2494 [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
|
2495 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
|
2496 dw_mutex_unlock(DWRunMutex); |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2497 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2498 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2499 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2500 * 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
|
2501 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2502 * 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
|
2503 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2504 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
|
2505 { |
694
130ca42c4ae3
Reimplementation of dw_main_iteration and dw_main_sleep that actually work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
693
diff
changeset
|
2506 DWTID curr = pthread_self(); |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2507 |
694
130ca42c4ae3
Reimplementation of dw_main_iteration and dw_main_sleep that actually work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
693
diff
changeset
|
2508 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
|
2509 { |
130ca42c4ae3
Reimplementation of dw_main_iteration and dw_main_sleep that actually work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
693
diff
changeset
|
2510 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
|
2511 NSDate *until = [NSDate dateWithTimeIntervalSinceNow:(milliseconds/1000.0)]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2512 |
695
3b17111499bf
Minor updates to the last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
694
diff
changeset
|
2513 if(orig == (DWTID)-1) |
3b17111499bf
Minor updates to the last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
694
diff
changeset
|
2514 { |
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
|
2515 dw_mutex_lock(DWRunMutex); |
695
3b17111499bf
Minor updates to the last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
694
diff
changeset
|
2516 DWThread = curr; |
3b17111499bf
Minor updates to the last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
694
diff
changeset
|
2517 } |
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
|
2518 /* 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
|
2519 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
|
2520 { |
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
|
2521 /* Just loop */ |
695
3b17111499bf
Minor updates to the last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
694
diff
changeset
|
2522 } |
3b17111499bf
Minor updates to the last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
694
diff
changeset
|
2523 if(orig == (DWTID)-1) |
3b17111499bf
Minor updates to the last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
694
diff
changeset
|
2524 { |
3b17111499bf
Minor updates to the last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
694
diff
changeset
|
2525 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
|
2526 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
|
2527 } |
130ca42c4ae3
Reimplementation of dw_main_iteration and dw_main_sleep that actually work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
693
diff
changeset
|
2528 } |
130ca42c4ae3
Reimplementation of dw_main_iteration and dw_main_sleep that actually work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
693
diff
changeset
|
2529 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
|
2530 { |
694
130ca42c4ae3
Reimplementation of dw_main_iteration and dw_main_sleep that actually work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
693
diff
changeset
|
2531 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
|
2532 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2533 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2534 |
700
7953f0471e4d
Some cleanups for the run loop iteration and thread system.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
699
diff
changeset
|
2535 /* 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
|
2536 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
|
2537 { |
694
130ca42c4ae3
Reimplementation of dw_main_iteration and dw_main_sleep that actually work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
693
diff
changeset
|
2538 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
|
2539 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
|
2540 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
|
2541 dequeue:YES]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2542 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
|
2543 { |
130ca42c4ae3
Reimplementation of dw_main_iteration and dw_main_sleep that actually work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
693
diff
changeset
|
2544 [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
|
2545 [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
|
2546 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
|
2547 } |
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
|
2548 return 0; |
650
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 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2551 /* |
700
7953f0471e4d
Some cleanups for the run loop iteration and thread system.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
699
diff
changeset
|
2552 * 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
|
2553 */ |
7953f0471e4d
Some cleanups for the run loop iteration and thread system.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
699
diff
changeset
|
2554 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
|
2555 { |
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
|
2556 DWTID curr = pthread_self(); |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2557 |
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
|
2558 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
|
2559 { |
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
|
2560 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
|
2561 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
|
2562 _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
|
2563 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
|
2564 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
|
2565 } |
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
|
2566 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
|
2567 { |
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
|
2568 _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
|
2569 } |
700
7953f0471e4d
Some cleanups for the run loop iteration and thread system.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
699
diff
changeset
|
2570 } |
7953f0471e4d
Some cleanups for the run loop iteration and thread system.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
699
diff
changeset
|
2571 |
7953f0471e4d
Some cleanups for the run loop iteration and thread system.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
699
diff
changeset
|
2572 /* |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2573 * 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
|
2574 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2575 * 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
|
2576 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2577 void API dw_exit(int exitcode) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2578 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2579 exit(exitcode); |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2580 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2581 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2582 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2583 * 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
|
2584 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2585 * ptr: Pointer to dynamic windows allocated |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2586 * memory to be free()'d. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2587 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2588 void API dw_free(void *ptr) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2589 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2590 free(ptr); |
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 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2594 * 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
|
2595 * 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
|
2596 * OS/2 and Windows). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2597 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2598 char *dw_user_dir(void) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2599 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2600 static char _user_dir[1024] = ""; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
2601 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2602 if(!_user_dir[0]) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2603 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2604 char *home = getenv("HOME"); |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
2605 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2606 if(home) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2607 strcpy(_user_dir, home); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2608 else |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2609 strcpy(_user_dir, "/"); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2610 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2611 return _user_dir; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2612 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2613 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2614 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2615 * 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
|
2616 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2617 * 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
|
2618 * 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
|
2619 * format: printf style format string. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2620 * ...: 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
|
2621 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2622 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
|
2623 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2624 int iResponse; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2625 NSString *button1 = @"OK"; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2626 NSString *button2 = nil; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2627 NSString *button3 = nil; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2628 va_list args; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2629 char outbuf[1000]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2630 |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2631 va_start(args, format); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2632 vsprintf(outbuf, format, args); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2633 va_end(args); |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
2634 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2635 if(flags & DW_MB_OKCANCEL) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2636 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2637 button2 = @"Cancel"; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2638 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2639 else if(flags & DW_MB_YESNO) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2640 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2641 button1 = @"Yes"; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2642 button2 = @"No"; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2643 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2644 else if(flags & DW_MB_YESNOCANCEL) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2645 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2646 button1 = @"Yes"; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2647 button2 = @"No"; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2648 button3 = @"Cancel"; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2649 } |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
2650 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2651 if(flags & DW_MB_ERROR) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2652 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2653 iResponse = (int) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2654 NSRunCriticalAlertPanel([ NSString stringWithUTF8String:title ], |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2655 [ NSString stringWithUTF8String:outbuf ], |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2656 button1, button2, button3); } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2657 else |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2658 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2659 iResponse = (int) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2660 NSRunAlertPanel([ NSString stringWithUTF8String:title ], |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2661 [ NSString stringWithUTF8String:outbuf ], |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2662 button1, button2, button3); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2663 } |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
2664 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2665 switch(iResponse) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2666 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2667 case NSAlertDefaultReturn: /* user pressed OK */ |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2668 if(flags & DW_MB_YESNO || flags & DW_MB_YESNOCANCEL) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2669 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2670 return DW_MB_RETURN_YES; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2671 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2672 return DW_MB_RETURN_OK; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2673 case NSAlertAlternateReturn: /* user pressed Cancel */ |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2674 if(flags & DW_MB_OKCANCEL) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2675 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2676 return DW_MB_RETURN_CANCEL; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2677 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2678 return DW_MB_RETURN_NO; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2679 case NSAlertOtherReturn: /* user pressed the third button */ |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2680 return DW_MB_RETURN_CANCEL; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2681 case NSAlertErrorReturn: /* an error occurred */ |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2682 break; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2683 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2684 return 0; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2685 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2686 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2687 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2688 * 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
|
2689 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2690 * title: Title bar text for dialog. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2691 * 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
|
2692 * ext: Default file extention. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2693 * 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
|
2694 * Returns: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2695 * 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
|
2696 * the file path on success. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2697 * |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2698 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2699 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
|
2700 { |
825
8a2e3138e1e4
Implemented DW_DIRECTORY_OPEN on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
821
diff
changeset
|
2701 if(flags == DW_FILE_OPEN || flags == DW_DIRECTORY_OPEN) |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2702 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2703 /* Create the File Open Dialog class. */ |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2704 NSOpenPanel* openDlg = [NSOpenPanel openPanel]; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
2705 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2706 /* Enable the selection of files in the dialog. */ |
825
8a2e3138e1e4
Implemented DW_DIRECTORY_OPEN on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
821
diff
changeset
|
2707 if(flags == DW_FILE_OPEN) |
8a2e3138e1e4
Implemented DW_DIRECTORY_OPEN on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
821
diff
changeset
|
2708 { |
8a2e3138e1e4
Implemented DW_DIRECTORY_OPEN on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
821
diff
changeset
|
2709 [openDlg setCanChooseFiles:YES]; |
8a2e3138e1e4
Implemented DW_DIRECTORY_OPEN on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
821
diff
changeset
|
2710 [openDlg setCanChooseDirectories:NO]; |
8a2e3138e1e4
Implemented DW_DIRECTORY_OPEN on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
821
diff
changeset
|
2711 } |
8a2e3138e1e4
Implemented DW_DIRECTORY_OPEN on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
821
diff
changeset
|
2712 else |
8a2e3138e1e4
Implemented DW_DIRECTORY_OPEN on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
821
diff
changeset
|
2713 { |
8a2e3138e1e4
Implemented DW_DIRECTORY_OPEN on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
821
diff
changeset
|
2714 [openDlg setCanChooseFiles:NO]; |
8a2e3138e1e4
Implemented DW_DIRECTORY_OPEN on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
821
diff
changeset
|
2715 [openDlg setCanChooseDirectories:YES]; |
8a2e3138e1e4
Implemented DW_DIRECTORY_OPEN on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
821
diff
changeset
|
2716 } |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
2717 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2718 /* Disable multiple selection */ |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2719 [openDlg setAllowsMultipleSelection:NO]; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
2720 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2721 /* Display the dialog. If the OK button was pressed, |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2722 * process the files. |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2723 */ |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2724 if([openDlg runModal] == NSOKButton) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2725 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2726 /* Get an array containing the full filenames of all |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2727 * files and directories selected. |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2728 */ |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2729 NSArray* files = [openDlg filenames]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2730 NSString* fileName = [files objectAtIndex:0]; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
2731 return strdup([ fileName UTF8String ]); |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2732 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2733 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2734 else |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2735 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2736 /* Create the File Save Dialog class. */ |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2737 NSSavePanel* saveDlg = [NSSavePanel savePanel]; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
2738 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2739 /* Enable the creation of directories in the dialog. */ |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2740 [saveDlg setCanCreateDirectories:YES]; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
2741 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2742 /* Display the dialog. If the OK button was pressed, |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2743 * process the files. |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2744 */ |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2745 if([saveDlg runModal] == NSFileHandlingPanelOKButton) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2746 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2747 /* Get an array containing the full filenames of all |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2748 * files and directories selected. |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2749 */ |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2750 NSString* fileName = [saveDlg filename]; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
2751 return strdup([ fileName UTF8String ]); |
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
2752 } |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2753 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2754 |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2755 return NULL; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2756 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2757 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2758 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2759 * 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
|
2760 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2761 * None. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2762 * Returns: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2763 * 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
|
2764 * be converted to text. |
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 char *dw_clipboard_get_text() |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2767 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2768 NSPasteboard *pasteboard = [NSPasteboard generalPasteboard]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2769 NSString *str = [pasteboard stringForType:NSStringPboardType]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2770 if(str != nil) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2771 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2772 return strdup([ str UTF8String ]); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2773 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2774 return NULL; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2775 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2776 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2777 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2778 * 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
|
2779 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2780 * Text. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2781 */ |
651
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2782 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
|
2783 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2784 NSPasteboard *pasteboard = [NSPasteboard generalPasteboard]; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
2785 |
751
eba6ab48c952
Runtime Snow Leopard checks where possible and visual fix for Leopard status text.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
749
diff
changeset
|
2786 /* Only in Snow Leopard */ |
eba6ab48c952
Runtime Snow Leopard checks where possible and visual fix for Leopard status text.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
749
diff
changeset
|
2787 if(DWOSMinor > 5) |
eba6ab48c952
Runtime Snow Leopard checks where possible and visual fix for Leopard status text.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
749
diff
changeset
|
2788 { |
eba6ab48c952
Runtime Snow Leopard checks where possible and visual fix for Leopard status text.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
749
diff
changeset
|
2789 [pasteboard clearContents]; |
eba6ab48c952
Runtime Snow Leopard checks where possible and visual fix for Leopard status text.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
749
diff
changeset
|
2790 } |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
2791 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2792 [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
|
2793 } |
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 * Allocates and initializes a dialog struct. |
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 * 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
|
2800 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2801 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
|
2802 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2803 DWDialog *tmp = malloc(sizeof(DWDialog)); |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
2804 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2805 if(tmp) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2806 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2807 tmp->eve = dw_event_new(); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2808 dw_event_reset(tmp->eve); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2809 tmp->data = data; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2810 tmp->done = FALSE; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2811 tmp->result = NULL; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2812 } |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
2813 return tmp; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2814 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2815 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2816 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2817 * 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
|
2818 * initial called of dw_dialog_wait(). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2819 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2820 * 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
|
2821 * 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
|
2822 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2823 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
|
2824 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2825 dialog->result = result; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2826 dw_event_post(dialog->eve); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2827 dialog->done = TRUE; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2828 return 0; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2829 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2830 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2831 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2832 * 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
|
2833 * 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
|
2834 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2835 * 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
|
2836 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2837 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
|
2838 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2839 void *tmp; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
2840 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2841 while(!dialog->done) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2842 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2843 _dw_main_iteration([NSDate dateWithTimeIntervalSinceNow:0.01]); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2844 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2845 dw_event_close(&dialog->eve); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2846 tmp = dialog->result; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2847 free(dialog); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2848 return tmp; |
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 * 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
|
2853 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2854 * 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
|
2855 * 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
|
2856 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2857 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
|
2858 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
2859 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
|
2860 DW_MUTEX_LOCK; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2861 DWBox *view = [[DWBox alloc] init]; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2862 Box *newbox = [view box]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2863 memset(newbox, 0, sizeof(Box)); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2864 newbox->pad = pad; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2865 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
|
2866 DW_MUTEX_UNLOCK; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2867 return view; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2868 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2869 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2870 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2871 * 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
|
2872 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2873 * 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
|
2874 * 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
|
2875 * 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
|
2876 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2877 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
|
2878 { |
792
fc6a626a96cc
Initial groupbox support. Sizing of the content frame is not quite right yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
768
diff
changeset
|
2879 NSBox *groupbox = [[DWGroupBox alloc] init]; |
796
3a3fae1f31bd
Initial groupbox padding calculation fix. This may still need more work... very simple version.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
795
diff
changeset
|
2880 DWBox *thisbox = dw_box_new(type, pad); |
3a3fae1f31bd
Initial groupbox padding calculation fix. This may still need more work... very simple version.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
795
diff
changeset
|
2881 Box *box = [thisbox box]; |
806
16964b141964
More accurate groupbox paddig calculations. Title rectangle is now calculated on the fly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
805
diff
changeset
|
2882 |
792
fc6a626a96cc
Initial groupbox support. Sizing of the content frame is not quite right yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
768
diff
changeset
|
2883 [groupbox setBorderType:NSBezelBorder]; |
fc6a626a96cc
Initial groupbox support. Sizing of the content frame is not quite right yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
768
diff
changeset
|
2884 [groupbox setTitle:[NSString stringWithUTF8String:title]]; |
806
16964b141964
More accurate groupbox paddig calculations. Title rectangle is now calculated on the fly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
805
diff
changeset
|
2885 box->grouphwnd = groupbox; |
796
3a3fae1f31bd
Initial groupbox padding calculation fix. This may still need more work... very simple version.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
795
diff
changeset
|
2886 [groupbox setContentView:thisbox]; |
792
fc6a626a96cc
Initial groupbox support. Sizing of the content frame is not quite right yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
768
diff
changeset
|
2887 return groupbox; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2888 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2889 |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2890 /* |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2891 * Create a new scrollable Box to be packed. |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2892 * Parameters: |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2893 * 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
|
2894 * 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
|
2895 */ |
796
3a3fae1f31bd
Initial groupbox padding calculation fix. This may still need more work... very simple version.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
795
diff
changeset
|
2896 HWND API dw_scrollbox_new( int type, int pad ) |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2897 { |
837
89d4bad9c96e
Initial attempt at implementing the scrollbox on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
831
diff
changeset
|
2898 DWScrollBox *scrollbox = [[DWScrollBox alloc] init]; |
89d4bad9c96e
Initial attempt at implementing the scrollbox on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
831
diff
changeset
|
2899 DWBox *box = dw_box_new(type, pad); |
840
2967934fb587
Implemented the fix for the scrollbox problem on the Mac (that was discovered on Windows)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
838
diff
changeset
|
2900 DWBox *tmpbox = dw_box_new(DW_VERT, 0); |
2967934fb587
Implemented the fix for the scrollbox problem on the Mac (that was discovered on Windows)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
838
diff
changeset
|
2901 dw_box_pack_start(tmpbox, box, 1, 1, TRUE, TRUE, 0); |
837
89d4bad9c96e
Initial attempt at implementing the scrollbox on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
831
diff
changeset
|
2902 [scrollbox setHasVerticalScroller:YES]; |
89d4bad9c96e
Initial attempt at implementing the scrollbox on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
831
diff
changeset
|
2903 [scrollbox setHasHorizontalScroller:YES]; |
89d4bad9c96e
Initial attempt at implementing the scrollbox on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
831
diff
changeset
|
2904 [scrollbox setBorderType:NSNoBorder]; |
838
8e0405435d0a
Minor scrollbox fixes...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
837
diff
changeset
|
2905 [scrollbox setDrawsBackground:NO]; |
840
2967934fb587
Implemented the fix for the scrollbox problem on the Mac (that was discovered on Windows)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
838
diff
changeset
|
2906 [scrollbox setBox:box]; |
2967934fb587
Implemented the fix for the scrollbox problem on the Mac (that was discovered on Windows)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
838
diff
changeset
|
2907 [scrollbox setDocumentView:tmpbox]; |
837
89d4bad9c96e
Initial attempt at implementing the scrollbox on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
831
diff
changeset
|
2908 return scrollbox; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2909 } |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2910 |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2911 /* |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2912 * 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
|
2913 * Parameters: |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2914 * handle: Handle to the scrollbox to be queried. |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2915 * orient: The vertical or horizontal scrollbar. |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2916 */ |
796
3a3fae1f31bd
Initial groupbox padding calculation fix. This may still need more work... very simple version.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
795
diff
changeset
|
2917 int API dw_scrollbox_get_pos(HWND handle, int orient) |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2918 { |
844
5103d132c3cd
Implemented dw_scrollbox_get_range() and dw_scrollbox_get_pos() on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
840
diff
changeset
|
2919 DWScrollBox *scrollbox = handle; |
5103d132c3cd
Implemented dw_scrollbox_get_range() and dw_scrollbox_get_pos() on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
840
diff
changeset
|
2920 NSView *view = [scrollbox documentView]; |
5103d132c3cd
Implemented dw_scrollbox_get_range() and dw_scrollbox_get_pos() on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
840
diff
changeset
|
2921 NSSize contentsize = [scrollbox contentSize]; |
5103d132c3cd
Implemented dw_scrollbox_get_range() and dw_scrollbox_get_pos() on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
840
diff
changeset
|
2922 NSScroller *scrollbar; |
5103d132c3cd
Implemented dw_scrollbox_get_range() and dw_scrollbox_get_pos() on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
840
diff
changeset
|
2923 int range = 0; |
5103d132c3cd
Implemented dw_scrollbox_get_range() and dw_scrollbox_get_pos() on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
840
diff
changeset
|
2924 int val = 0; |
5103d132c3cd
Implemented dw_scrollbox_get_range() and dw_scrollbox_get_pos() on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
840
diff
changeset
|
2925 if(orient == DW_VERT) |
5103d132c3cd
Implemented dw_scrollbox_get_range() and dw_scrollbox_get_pos() on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
840
diff
changeset
|
2926 { |
5103d132c3cd
Implemented dw_scrollbox_get_range() and dw_scrollbox_get_pos() on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
840
diff
changeset
|
2927 scrollbar = [scrollbox verticalScroller]; |
5103d132c3cd
Implemented dw_scrollbox_get_range() and dw_scrollbox_get_pos() on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
840
diff
changeset
|
2928 range = [view bounds].size.height - contentsize.height; |
5103d132c3cd
Implemented dw_scrollbox_get_range() and dw_scrollbox_get_pos() on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
840
diff
changeset
|
2929 } |
5103d132c3cd
Implemented dw_scrollbox_get_range() and dw_scrollbox_get_pos() on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
840
diff
changeset
|
2930 else |
5103d132c3cd
Implemented dw_scrollbox_get_range() and dw_scrollbox_get_pos() on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
840
diff
changeset
|
2931 { |
5103d132c3cd
Implemented dw_scrollbox_get_range() and dw_scrollbox_get_pos() on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
840
diff
changeset
|
2932 scrollbar = [scrollbox horizontalScroller]; |
5103d132c3cd
Implemented dw_scrollbox_get_range() and dw_scrollbox_get_pos() on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
840
diff
changeset
|
2933 range = [view bounds].size.width - contentsize.width; |
5103d132c3cd
Implemented dw_scrollbox_get_range() and dw_scrollbox_get_pos() on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
840
diff
changeset
|
2934 } |
5103d132c3cd
Implemented dw_scrollbox_get_range() and dw_scrollbox_get_pos() on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
840
diff
changeset
|
2935 if(range > 0) |
5103d132c3cd
Implemented dw_scrollbox_get_range() and dw_scrollbox_get_pos() on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
840
diff
changeset
|
2936 { |
5103d132c3cd
Implemented dw_scrollbox_get_range() and dw_scrollbox_get_pos() on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
840
diff
changeset
|
2937 val = [scrollbar floatValue] * range; |
5103d132c3cd
Implemented dw_scrollbox_get_range() and dw_scrollbox_get_pos() on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
840
diff
changeset
|
2938 } |
5103d132c3cd
Implemented dw_scrollbox_get_range() and dw_scrollbox_get_pos() on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
840
diff
changeset
|
2939 return val; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2940 } |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2941 |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2942 /* |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2943 * 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
|
2944 * Parameters: |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2945 * handle: Handle to the scrollbox to be queried. |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2946 * orient: The vertical or horizontal scrollbar. |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2947 */ |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2948 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
|
2949 { |
844
5103d132c3cd
Implemented dw_scrollbox_get_range() and dw_scrollbox_get_pos() on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
840
diff
changeset
|
2950 DWScrollBox *scrollbox = handle; |
5103d132c3cd
Implemented dw_scrollbox_get_range() and dw_scrollbox_get_pos() on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
840
diff
changeset
|
2951 NSView *view = [scrollbox documentView]; |
5103d132c3cd
Implemented dw_scrollbox_get_range() and dw_scrollbox_get_pos() on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
840
diff
changeset
|
2952 int range = 0; |
5103d132c3cd
Implemented dw_scrollbox_get_range() and dw_scrollbox_get_pos() on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
840
diff
changeset
|
2953 if(orient == DW_VERT) |
5103d132c3cd
Implemented dw_scrollbox_get_range() and dw_scrollbox_get_pos() on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
840
diff
changeset
|
2954 { |
5103d132c3cd
Implemented dw_scrollbox_get_range() and dw_scrollbox_get_pos() on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
840
diff
changeset
|
2955 range = [view bounds].size.height; |
5103d132c3cd
Implemented dw_scrollbox_get_range() and dw_scrollbox_get_pos() on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
840
diff
changeset
|
2956 } |
5103d132c3cd
Implemented dw_scrollbox_get_range() and dw_scrollbox_get_pos() on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
840
diff
changeset
|
2957 else |
5103d132c3cd
Implemented dw_scrollbox_get_range() and dw_scrollbox_get_pos() on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
840
diff
changeset
|
2958 { |
5103d132c3cd
Implemented dw_scrollbox_get_range() and dw_scrollbox_get_pos() on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
840
diff
changeset
|
2959 range = [view bounds].size.width; |
5103d132c3cd
Implemented dw_scrollbox_get_range() and dw_scrollbox_get_pos() on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
840
diff
changeset
|
2960 } |
5103d132c3cd
Implemented dw_scrollbox_get_range() and dw_scrollbox_get_pos() on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
840
diff
changeset
|
2961 return range; |
5103d132c3cd
Implemented dw_scrollbox_get_range() and dw_scrollbox_get_pos() on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
840
diff
changeset
|
2962 } |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
2963 |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2964 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2965 * 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
|
2966 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2967 * 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
|
2968 * 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
|
2969 * 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
|
2970 * 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
|
2971 * 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
|
2972 * 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
|
2973 * 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
|
2974 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2975 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
|
2976 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
2977 int _locked_by_me = FALSE; |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
2978 DW_MUTEX_LOCK; |
838
8e0405435d0a
Minor scrollbox fixes...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
837
diff
changeset
|
2979 id object = box; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2980 DWBox *view = box; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2981 DWBox *this = item; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2982 Box *thisbox; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2983 int z; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2984 Item *tmpitem, *thisitem; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2985 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2986 /* Query the objects */ |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2987 if([ object isKindOfClass:[ NSWindow class ] ]) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2988 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2989 NSWindow *window = box; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2990 view = [window contentView]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2991 } |
837
89d4bad9c96e
Initial attempt at implementing the scrollbox on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
831
diff
changeset
|
2992 else if([ object isMemberOfClass:[ DWScrollBox class ] ]) |
89d4bad9c96e
Initial attempt at implementing the scrollbox on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
831
diff
changeset
|
2993 { |
89d4bad9c96e
Initial attempt at implementing the scrollbox on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
831
diff
changeset
|
2994 DWScrollBox *scrollbox = box; |
840
2967934fb587
Implemented the fix for the scrollbox problem on the Mac (that was discovered on Windows)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
838
diff
changeset
|
2995 view = [scrollbox box]; |
837
89d4bad9c96e
Initial attempt at implementing the scrollbox on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
831
diff
changeset
|
2996 } |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
2997 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2998 thisbox = [view box]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
2999 thisitem = thisbox->items; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3000 object = item; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3001 |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3002 /* Query the objects */ |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3003 if([ object isKindOfClass:[ DWContainer class ] ]) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3004 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3005 DWContainer *cont = item; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3006 this = item = [cont scrollview]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3007 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3008 else if([ object isKindOfClass:[ DWTree class ] ]) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3009 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3010 DWTree *tree = item; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3011 this = item = [tree scrollview]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3012 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3013 |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3014 /* 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
|
3015 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
|
3016 |
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
3017 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
|
3018 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3019 tmpitem[z+1] = thisitem[z]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3020 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3021 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3022 /* Sanity checks */ |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3023 if(vsize && !height) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3024 height = 1; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3025 if(hsize && !width) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3026 width = 1; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3027 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3028 /* Fill in the item data appropriately */ |
792
fc6a626a96cc
Initial groupbox support. Sizing of the content frame is not quite right yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
768
diff
changeset
|
3029 if([object isKindOfClass:[DWBox class]] || [object isMemberOfClass:[DWGroupBox class]]) |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3030 tmpitem[0].type = TYPEBOX; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3031 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3032 tmpitem[0].type = TYPEITEM; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3033 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3034 tmpitem[0].hwnd = item; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3035 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
|
3036 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
|
3037 tmpitem[0].pad = pad; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3038 if(hsize) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3039 tmpitem[0].hsize = SIZEEXPAND; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3040 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3041 tmpitem[0].hsize = SIZESTATIC; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3042 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3043 if(vsize) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3044 tmpitem[0].vsize = SIZEEXPAND; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3045 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3046 tmpitem[0].vsize = SIZESTATIC; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3047 |
666
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
3048 thisbox->items = tmpitem; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3049 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3050 /* 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
|
3051 thisbox->count++; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3052 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3053 /* Add the item to the box */ |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3054 [view addSubview:this]; |
793
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
3055 /* If we are packing a button... */ |
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
3056 if([this isMemberOfClass:[DWButton class]]) |
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
3057 { |
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
3058 DWButton *button = (DWButton *)this; |
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
3059 |
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
3060 /* Save the parent box so radio |
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
3061 * buttons can use it later. |
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
3062 */ |
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
3063 [button setParent:view]; |
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
3064 } |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
3065 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3066 /* 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
|
3067 if(thisbox->count) |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3068 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
|
3069 DW_MUTEX_UNLOCK; |
650
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 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3073 * 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
|
3074 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3075 * 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
|
3076 * 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
|
3077 * 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
|
3078 * 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
|
3079 * 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
|
3080 * 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
|
3081 * 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
|
3082 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3083 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
|
3084 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3085 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
|
3086 DW_MUTEX_LOCK; |
838
8e0405435d0a
Minor scrollbox fixes...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
837
diff
changeset
|
3087 id object = box; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3088 DWBox *view = box; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3089 DWBox *this = item; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3090 Box *thisbox; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3091 int z; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3092 Item *tmpitem, *thisitem; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3093 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3094 /* Query the objects */ |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3095 if([ object isKindOfClass:[ NSWindow class ] ]) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3096 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3097 NSWindow *window = box; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3098 view = [window contentView]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3099 } |
837
89d4bad9c96e
Initial attempt at implementing the scrollbox on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
831
diff
changeset
|
3100 else if([ object isMemberOfClass:[ DWScrollBox class ] ]) |
89d4bad9c96e
Initial attempt at implementing the scrollbox on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
831
diff
changeset
|
3101 { |
89d4bad9c96e
Initial attempt at implementing the scrollbox on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
831
diff
changeset
|
3102 DWScrollBox *scrollbox = box; |
840
2967934fb587
Implemented the fix for the scrollbox problem on the Mac (that was discovered on Windows)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
838
diff
changeset
|
3103 view = [scrollbox box]; |
837
89d4bad9c96e
Initial attempt at implementing the scrollbox on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
831
diff
changeset
|
3104 } |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
3105 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3106 thisbox = [view box]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3107 thisitem = thisbox->items; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3108 object = item; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3109 |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3110 /* Query the objects */ |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3111 if([ object isKindOfClass:[ DWContainer class ] ]) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3112 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3113 DWContainer *cont = item; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3114 this = item = [cont scrollview]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3115 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3116 else if([ object isKindOfClass:[ DWTree class ] ]) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3117 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3118 DWTree *tree = item; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3119 this = item = [tree scrollview]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3120 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3121 |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3122 /* 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
|
3123 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
|
3124 |
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
3125 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
|
3126 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3127 tmpitem[z] = thisitem[z]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3128 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3129 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3130 /* Sanity checks */ |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3131 if(vsize && !height) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3132 height = 1; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3133 if(hsize && !width) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3134 width = 1; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3135 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3136 /* Fill in the item data appropriately */ |
792
fc6a626a96cc
Initial groupbox support. Sizing of the content frame is not quite right yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
768
diff
changeset
|
3137 if([object isKindOfClass:[DWBox class]] || [object isMemberOfClass:[DWGroupBox class]]) |
666
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
3138 tmpitem[thisbox->count].type = TYPEBOX; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3139 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
|
3140 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
|
3141 |
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
3142 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
|
3143 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
|
3144 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
|
3145 tmpitem[thisbox->count].pad = pad; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3146 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
|
3147 tmpitem[thisbox->count].hsize = SIZEEXPAND; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3148 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
|
3149 tmpitem[thisbox->count].hsize = SIZESTATIC; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3150 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3151 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
|
3152 tmpitem[thisbox->count].vsize = SIZEEXPAND; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3153 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
|
3154 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
|
3155 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3156 thisbox->items = tmpitem; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3157 |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3158 /* 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
|
3159 thisbox->count++; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3160 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3161 /* Add the item to the box */ |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3162 [view addSubview:this]; |
793
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
3163 /* If we are packing a button... */ |
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
3164 if([this isMemberOfClass:[DWButton class]]) |
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
3165 { |
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
3166 DWButton *button = (DWButton *)this; |
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
3167 |
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
3168 /* Save the parent box so radio |
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
3169 * buttons can use it later. |
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
3170 */ |
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
3171 [button setParent:view]; |
e328c7746cda
Basic code to handle unchecking other radio buttons attached to the same box when one is selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
792
diff
changeset
|
3172 } |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
3173 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3174 /* 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
|
3175 if(thisbox->count) |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3176 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
|
3177 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3178 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3179 |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
3180 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
|
3181 { |
744
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
3182 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
|
3183 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
|
3184 { |
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
3185 [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
|
3186 } |
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
3187 [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
|
3188 [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
|
3189 [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
|
3190 [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
|
3191 [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
|
3192 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
|
3193 { |
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
3194 [[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
|
3195 } |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3196 return button; |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3197 } |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3198 |
650
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 * 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
|
3201 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3202 * 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
|
3203 * 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
|
3204 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
3205 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
|
3206 { |
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
3207 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
|
3208 [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
|
3209 [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
|
3210 [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
|
3211 [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
|
3212 [[button cell] setControlTint:NSBlueControlTint]; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3213 return button; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3214 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3215 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3216 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3217 * 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
|
3218 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3219 * 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
|
3220 * 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
|
3221 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
3222 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
|
3223 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3224 DWEntryField *entry = [[DWEntryField alloc] init]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3225 [entry setStringValue:[ NSString stringWithUTF8String:text ]]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3226 [entry setTag:cid]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3227 return entry; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3228 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3229 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3230 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3231 * 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
|
3232 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3233 * 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
|
3234 * 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
|
3235 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
3236 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
|
3237 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3238 DWEntryFieldPassword *entry = [[DWEntryFieldPassword alloc] init]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3239 [entry setStringValue:[ NSString stringWithUTF8String:text ]]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3240 [entry setTag:cid]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3241 return entry; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3242 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3243 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3244 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3245 * Sets the entryfield character limit. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3246 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3247 * 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
|
3248 * 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
|
3249 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3250 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
|
3251 { |
887
29d8ae25a78c
Implemented dw_entryfield_set_limit() on the Mac using a custom formatter class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
886
diff
changeset
|
3252 DWEntryField *entry = handle; |
29d8ae25a78c
Implemented dw_entryfield_set_limit() on the Mac using a custom formatter class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
886
diff
changeset
|
3253 DWEntryFieldFormatter *formatter = [[DWEntryFieldFormatter alloc] init]; |
29d8ae25a78c
Implemented dw_entryfield_set_limit() on the Mac using a custom formatter class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
886
diff
changeset
|
3254 |
29d8ae25a78c
Implemented dw_entryfield_set_limit() on the Mac using a custom formatter class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
886
diff
changeset
|
3255 [formatter setMaximumLength:(int)limit]; |
29d8ae25a78c
Implemented dw_entryfield_set_limit() on the Mac using a custom formatter class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
886
diff
changeset
|
3256 [[entry cell] setFormatter:formatter]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3257 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3258 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3259 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3260 * 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
|
3261 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3262 * 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
|
3263 * 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
|
3264 */ |
670
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
3265 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
|
3266 { |
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
3267 NSBundle *bundle = [NSBundle mainBundle]; |
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
3268 NSString *respath = [bundle resourcePath]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
3269 NSString *filepath = [respath stringByAppendingFormat:@"/%u.png", resid]; |
749 | 3270 NSImage *image = [[NSImage alloc] initWithContentsOfFile:filepath]; |
3271 DWButton *button = _button_new("", resid); | |
748
f39745844175
Added tooltips to bitmap buttons... and made a change to the look when the image is present...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
747
diff
changeset
|
3272 if(image) |
f39745844175
Added tooltips to bitmap buttons... and made a change to the look when the image is present...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
747
diff
changeset
|
3273 { |
f39745844175
Added tooltips to bitmap buttons... and made a change to the look when the image is present...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
747
diff
changeset
|
3274 [button setImage:image]; |
f39745844175
Added tooltips to bitmap buttons... and made a change to the look when the image is present...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
747
diff
changeset
|
3275 } |
f39745844175
Added tooltips to bitmap buttons... and made a change to the look when the image is present...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
747
diff
changeset
|
3276 [button setToolTip:[NSString stringWithUTF8String:text]]; |
670
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
3277 [image release]; |
749 | 3278 return button; |
650
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 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3282 * 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
|
3283 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3284 * 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
|
3285 * 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
|
3286 * 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
|
3287 * DW pick the appropriate file extension. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3288 * (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
|
3289 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
3290 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
|
3291 { |
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
|
3292 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
|
3293 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
|
3294 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
|
3295 { |
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
|
3296 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
|
3297 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
|
3298 } |
749 | 3299 DWButton *button = _button_new("", cid); |
748
f39745844175
Added tooltips to bitmap buttons... and made a change to the look when the image is present...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
747
diff
changeset
|
3300 if(image) |
f39745844175
Added tooltips to bitmap buttons... and made a change to the look when the image is present...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
747
diff
changeset
|
3301 { |
f39745844175
Added tooltips to bitmap buttons... and made a change to the look when the image is present...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
747
diff
changeset
|
3302 [button setImage:image]; |
f39745844175
Added tooltips to bitmap buttons... and made a change to the look when the image is present...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
747
diff
changeset
|
3303 } |
f39745844175
Added tooltips to bitmap buttons... and made a change to the look when the image is present...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
747
diff
changeset
|
3304 [button setToolTip:[NSString stringWithUTF8String:text]]; |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3305 [image release]; |
749 | 3306 return button; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3307 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3308 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3309 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3310 * 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
|
3311 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3312 * 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
|
3313 * 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
|
3314 * data: The contents of the image |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3315 * (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
|
3316 * len: length of str |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3317 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
3318 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
|
3319 { |
760
2fb17622a455
Possible fix for exception in dw_bitmapbutton_new_from_data()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
755
diff
changeset
|
3320 NSData *thisdata = [NSData dataWithBytes:data length:len]; |
749 | 3321 NSImage *image = [[NSImage alloc] initWithData:thisdata]; |
3322 DWButton *button = _button_new("", cid); | |
748
f39745844175
Added tooltips to bitmap buttons... and made a change to the look when the image is present...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
747
diff
changeset
|
3323 if(image) |
f39745844175
Added tooltips to bitmap buttons... and made a change to the look when the image is present...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
747
diff
changeset
|
3324 { |
f39745844175
Added tooltips to bitmap buttons... and made a change to the look when the image is present...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
747
diff
changeset
|
3325 [button setImage:image]; |
f39745844175
Added tooltips to bitmap buttons... and made a change to the look when the image is present...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
747
diff
changeset
|
3326 } |
f39745844175
Added tooltips to bitmap buttons... and made a change to the look when the image is present...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
747
diff
changeset
|
3327 [button setToolTip:[NSString stringWithUTF8String:text]]; |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3328 [image release]; |
749 | 3329 return button; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3330 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3331 |
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 * 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
|
3334 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3335 * 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
|
3336 * 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
|
3337 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
3338 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
|
3339 { |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
3340 DWSpinButton *spinbutton = [[DWSpinButton alloc] init]; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3341 NSStepper *stepper = [spinbutton stepper]; |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
3342 [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
|
3343 [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
|
3344 return spinbutton; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3345 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3346 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3347 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3348 * Sets the spinbutton value. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3349 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3350 * 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
|
3351 * position: Current value of the spinbutton. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3352 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3353 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
|
3354 { |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
3355 DWSpinButton *spinbutton = handle; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3356 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
|
3357 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
|
3358 [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
|
3359 [textfield takeIntValueFrom:stepper]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3360 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3361 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3362 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3363 * Sets the spinbutton limits. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3364 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3365 * 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
|
3366 * upper: Upper limit. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3367 * lower: Lower limit. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3368 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3369 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
|
3370 { |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
3371 DWSpinButton *spinbutton = handle; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3372 NSStepper *stepper = [spinbutton stepper]; |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
3373 [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
|
3374 [stepper setMaxValue:(double)upper]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3375 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3376 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3377 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3378 * 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
|
3379 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3380 * 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
|
3381 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3382 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
|
3383 { |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
3384 DWSpinButton *spinbutton = handle; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3385 NSStepper *stepper = [spinbutton stepper]; |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
3386 return (long)[stepper integerValue]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3387 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3388 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3389 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3390 * 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
|
3391 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3392 * 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
|
3393 * 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
|
3394 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
3395 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
|
3396 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3397 DWButton *button = _button_new(text, cid); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3398 [button setButtonType:NSRadioButton]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3399 return button; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3400 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3401 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3402 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3403 * 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
|
3404 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3405 * 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
|
3406 * increments: Number of increments available. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3407 * 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
|
3408 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
3409 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
|
3410 { |
704
336800e9e648
Fixes to the slider control so events happen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
703
diff
changeset
|
3411 DWSlider *slider = [[DWSlider alloc] init]; |
336800e9e648
Fixes to the slider control so events happen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
703
diff
changeset
|
3412 [slider setMaxValue:(double)increments]; |
336800e9e648
Fixes to the slider control so events happen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
703
diff
changeset
|
3413 [slider setMinValue:0]; |
336800e9e648
Fixes to the slider control so events happen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
703
diff
changeset
|
3414 [slider setContinuous:YES]; |
336800e9e648
Fixes to the slider control so events happen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
703
diff
changeset
|
3415 [slider setTarget:slider]; |
336800e9e648
Fixes to the slider control so events happen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
703
diff
changeset
|
3416 [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
|
3417 [slider setTag:cid]; |
704
336800e9e648
Fixes to the slider control so events happen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
703
diff
changeset
|
3418 return slider; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3419 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3420 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3421 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3422 * Returns the position of the slider. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3423 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3424 * 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
|
3425 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3426 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
|
3427 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3428 DWSlider *slider = handle; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3429 double val = [slider doubleValue]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3430 return (int)val; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3431 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3432 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3433 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3434 * Sets the slider position. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3435 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3436 * 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
|
3437 * 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
|
3438 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3439 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
|
3440 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3441 DWSlider *slider = handle; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3442 [slider setDoubleValue:(double)position]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3443 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3444 |
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 * 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
|
3447 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3448 * 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
|
3449 * increments: Number of increments available. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3450 * 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
|
3451 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
3452 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
|
3453 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3454 DWScrollbar *scrollbar; |
689
4199730e9889
Fixed errors creating scrollbars.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
688
diff
changeset
|
3455 if(vertical) |
4199730e9889
Fixed errors creating scrollbars.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
688
diff
changeset
|
3456 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3457 scrollbar = [[DWScrollbar alloc] init]; |
689
4199730e9889
Fixed errors creating scrollbars.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
688
diff
changeset
|
3458 } |
4199730e9889
Fixed errors creating scrollbars.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
688
diff
changeset
|
3459 else |
4199730e9889
Fixed errors creating scrollbars.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
688
diff
changeset
|
3460 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3461 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
|
3462 } |
4199730e9889
Fixed errors creating scrollbars.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
688
diff
changeset
|
3463 [scrollbar setArrowsPosition:NSScrollerArrowsDefaultSetting]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
3464 [scrollbar setTarget:scrollbar]; |
689
4199730e9889
Fixed errors creating scrollbars.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
688
diff
changeset
|
3465 [scrollbar setAction:@selector(changed:)]; |
4199730e9889
Fixed errors creating scrollbars.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
688
diff
changeset
|
3466 [scrollbar setRange:0.0 andVisible:0.0]; |
4199730e9889
Fixed errors creating scrollbars.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
688
diff
changeset
|
3467 [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
|
3468 [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
|
3469 [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
|
3470 [scrollbar setTag:cid]; |
689
4199730e9889
Fixed errors creating scrollbars.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
688
diff
changeset
|
3471 [scrollbar setEnabled:YES]; |
4199730e9889
Fixed errors creating scrollbars.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
688
diff
changeset
|
3472 return scrollbar; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3473 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3474 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3475 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3476 * Returns the position of the scrollbar. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3477 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3478 * 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
|
3479 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3480 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
|
3481 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3482 DWScrollbar *scrollbar = handle; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3483 float range = [scrollbar range]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3484 float fresult = [scrollbar doubleValue] * range; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3485 return (int)fresult; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3486 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3487 |
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 * Sets the scrollbar position. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3490 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3491 * 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
|
3492 * 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
|
3493 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3494 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
|
3495 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3496 DWScrollbar *scrollbar = handle; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3497 double range = (double)[scrollbar range]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3498 double newpos = (double)position/range; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3499 [scrollbar setDoubleValue:newpos]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3500 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3501 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3502 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3503 * Sets the scrollbar range. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3504 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3505 * 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
|
3506 * range: Maximum range value. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3507 * 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
|
3508 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3509 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
|
3510 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3511 DWScrollbar *scrollbar = handle; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3512 float knob = (float)visible/(float)range; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3513 [scrollbar setRange:(float)range andVisible:(float)visible]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3514 [scrollbar setKnobProportion:knob]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3515 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3516 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3517 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3518 * 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
|
3519 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3520 * 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
|
3521 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
3522 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
|
3523 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3524 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
|
3525 [percent setStyle:NSProgressIndicatorBarStyle]; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3526 [percent setBezeled:YES]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3527 [percent setMaxValue:100]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3528 [percent setMinValue:0]; |
714
cf6246f86c04
Fixed the percent/progress indicators from always being indeterminate.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
713
diff
changeset
|
3529 [percent incrementBy:1]; |
cf6246f86c04
Fixed the percent/progress indicators from always being indeterminate.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
713
diff
changeset
|
3530 [percent setIndeterminate:NO]; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3531 /*[percent setTag:cid]; Why doesn't this work? */ |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3532 return percent; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3533 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3534 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3535 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3536 * Sets the percent bar position. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3537 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3538 * 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
|
3539 * 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
|
3540 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3541 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
|
3542 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3543 DWPercent *percent = handle; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3544 [percent setDoubleValue:(double)position]; |
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 * 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
|
3549 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3550 * 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
|
3551 * 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
|
3552 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
3553 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
|
3554 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3555 DWButton *button = _button_new(text, cid); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3556 [button setButtonType:NSSwitchButton]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3557 [button setBezelStyle:NSRegularSquareBezelStyle]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3558 return button; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3559 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3560 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3561 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3562 * Returns the state of the checkbox. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3563 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3564 * 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
|
3565 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3566 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
|
3567 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3568 DWButton *button = handle; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3569 if([button state]) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3570 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3571 return TRUE; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3572 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3573 return FALSE; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3574 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3575 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3576 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3577 * Sets the state of the checkbox. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3578 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3579 * 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
|
3580 * 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
|
3581 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3582 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
|
3583 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3584 DWButton *button = handle; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3585 if(value) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3586 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3587 [button setState:NSOnState]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3588 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3589 else |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3590 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3591 [button setState:NSOffState]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3592 } |
656
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
3593 |
650
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 |
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
|
3596 /* 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
|
3597 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
|
3598 { |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
3599 NSScrollView *scrollview = [[NSScrollView alloc] init]; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3600 DWContainer *cont = [[DWContainer alloc] init]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
3601 |
668
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
3602 [cont setScrollview:scrollview]; |
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
3603 [scrollview setBorderType:NSBezelBorder]; |
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
3604 [scrollview setHasVerticalScroller:YES]; |
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
3605 [scrollview setAutohidesScrollers:YES]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
3606 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3607 if(multi) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3608 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3609 [cont setAllowsMultipleSelection:YES]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3610 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3611 else |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3612 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3613 [cont setAllowsMultipleSelection:NO]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3614 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3615 [cont setDataSource:cont]; |
813
7fa26d8cc8d0
Fix for column click handler not working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
812
diff
changeset
|
3616 [cont setDelegate:cont]; |
668
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
3617 [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
|
3618 [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
|
3619 [scrollview release]; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3620 return cont; |
658
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
3621 } |
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
3622 |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3623 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3624 * 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
|
3625 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3626 * 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
|
3627 * multi: Multiple select TRUE or FALSE. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3628 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
3629 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
|
3630 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3631 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
|
3632 DW_MUTEX_LOCK; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3633 DWContainer *cont = _cont_new(cid, multi); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3634 [cont setHeaderView:nil]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3635 int type = DW_CFA_STRING; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3636 [cont setup]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3637 NSTableColumn *column = [[NSTableColumn alloc] init]; |
795
f23cad02cfb3
Make listbox, container and tree cells uneditable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
794
diff
changeset
|
3638 [column setEditable:NO]; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3639 [cont addTableColumn:column]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3640 [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
|
3641 [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
|
3642 DW_MUTEX_UNLOCK; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3643 return cont; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3644 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3645 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3646 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3647 * 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
|
3648 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3649 * 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
|
3650 * text: Text to append into listbox. |
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 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
|
3653 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3654 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
|
3655 DW_MUTEX_LOCK; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3656 id object = handle; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
3657 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3658 if([object isMemberOfClass:[DWComboBox class]]) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3659 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3660 DWComboBox *combo = handle; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
3661 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3662 [combo addItemWithObjectValue:[ NSString stringWithUTF8String:text ]]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3663 } |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3664 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
|
3665 { |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3666 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
|
3667 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
|
3668 NSArray *newrow = [NSArray arrayWithObject:nstr]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
3669 |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3670 [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
|
3671 /*[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
|
3672 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
|
3673 waitUntilDone:YES];*/ |
670
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
3674 [cont reloadData]; |
794
e9bc14c5c72d
Test fix for containers (and probably listboxes) not showing their content changes immediately.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
793
diff
changeset
|
3675 [cont setNeedsDisplay:YES]; |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3676 } |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3677 DW_MUTEX_UNLOCK; |
650
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 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3680 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3681 * 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
|
3682 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3683 * 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
|
3684 * text: Text to insert into listbox. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3685 * 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
|
3686 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3687 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
|
3688 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3689 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
|
3690 DW_MUTEX_LOCK; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3691 id object = handle; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
3692 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3693 if([object isMemberOfClass:[DWComboBox class]]) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3694 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3695 DWComboBox *combo = handle; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
3696 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3697 [combo insertItemWithObjectValue:[ NSString stringWithUTF8String:text ] atIndex:pos]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3698 } |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3699 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
|
3700 { |
687
5dde8d34bc69
Implemented dw_listbox_insert for containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
686
diff
changeset
|
3701 DWContainer *cont = handle; |
5dde8d34bc69
Implemented dw_listbox_insert for containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
686
diff
changeset
|
3702 NSString *nstr = [ NSString stringWithUTF8String:text ]; |
5dde8d34bc69
Implemented dw_listbox_insert for containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
686
diff
changeset
|
3703 NSArray *newrow = [NSArray arrayWithObject:nstr]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
3704 |
687
5dde8d34bc69
Implemented dw_listbox_insert for containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
686
diff
changeset
|
3705 [cont insertRow:newrow at:pos]; |
5dde8d34bc69
Implemented dw_listbox_insert for containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
686
diff
changeset
|
3706 [cont reloadData]; |
794
e9bc14c5c72d
Test fix for containers (and probably listboxes) not showing their content changes immediately.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
793
diff
changeset
|
3707 [cont setNeedsDisplay:YES]; |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3708 } |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3709 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3710 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3711 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3712 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3713 * 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
|
3714 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3715 * 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
|
3716 * 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
|
3717 * 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
|
3718 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3719 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
|
3720 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3721 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
|
3722 DW_MUTEX_LOCK; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3723 id object = handle; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
3724 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3725 if([object isMemberOfClass:[DWComboBox class]]) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3726 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3727 DWComboBox *combo = handle; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3728 int z; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
3729 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3730 for(z=0;z<count;z++) |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
3731 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3732 [combo addItemWithObjectValue:[ NSString stringWithUTF8String:text[z] ]]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3733 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3734 } |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3735 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
|
3736 { |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3737 DWContainer *cont = handle; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3738 int z; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
3739 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3740 for(z=0;z<count;z++) |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
3741 { |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3742 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
|
3743 NSArray *newrow = [[NSArray alloc] arrayWithObject:nstr]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
3744 |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3745 [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
|
3746 } |
670
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
3747 [cont reloadData]; |
794
e9bc14c5c72d
Test fix for containers (and probably listboxes) not showing their content changes immediately.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
793
diff
changeset
|
3748 [cont setNeedsDisplay:YES]; |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3749 } |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3750 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3751 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3752 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3753 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3754 * 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
|
3755 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3756 * 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
|
3757 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3758 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
|
3759 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3760 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
|
3761 DW_MUTEX_LOCK; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3762 id object = handle; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
3763 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3764 if([object isMemberOfClass:[DWComboBox class]]) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3765 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3766 DWComboBox *combo = handle; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
3767 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3768 [combo removeAllItems]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3769 } |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3770 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
|
3771 { |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3772 DWContainer *cont = handle; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
3773 |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3774 [cont clear]; |
670
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
3775 [cont reloadData]; |
794
e9bc14c5c72d
Test fix for containers (and probably listboxes) not showing their content changes immediately.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
793
diff
changeset
|
3776 [cont setNeedsDisplay:YES]; |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3777 } |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3778 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3779 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3780 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3781 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3782 * Returns the listbox's item count. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3783 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3784 * 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
|
3785 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3786 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
|
3787 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3788 id object = handle; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
3789 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3790 if([object isMemberOfClass:[DWComboBox class]]) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3791 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3792 DWComboBox *combo = handle; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
3793 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3794 return (int)[combo numberOfItems]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3795 } |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3796 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
|
3797 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3798 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
|
3799 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
|
3800 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
|
3801 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
|
3802 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
|
3803 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
|
3804 } |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3805 return 0; |
650
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 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3808 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3809 * 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
|
3810 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3811 * 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
|
3812 * top: Index to the top item. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3813 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3814 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
|
3815 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3816 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
|
3817 DW_MUTEX_LOCK; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3818 id object = handle; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
3819 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3820 if([object isMemberOfClass:[DWComboBox class]]) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3821 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3822 DWComboBox *combo = handle; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
3823 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3824 [combo scrollItemAtIndexToTop:top]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3825 } |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3826 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
|
3827 { |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3828 DWContainer *cont = handle; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
3829 |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3830 [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
|
3831 } |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3832 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3833 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3834 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3835 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3836 * 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
|
3837 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3838 * 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
|
3839 * 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
|
3840 * 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
|
3841 * 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
|
3842 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3843 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
|
3844 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3845 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
|
3846 DW_MUTEX_LOCK; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3847 id object = handle; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
3848 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3849 if([object isMemberOfClass:[DWComboBox class]]) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3850 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3851 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
|
3852 int count = (int)[combo numberOfItems]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
3853 |
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
|
3854 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
|
3855 { |
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
|
3856 *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
|
3857 } |
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
|
3858 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
|
3859 { |
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
|
3860 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
|
3861 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
|
3862 } |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3863 } |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3864 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
|
3865 { |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3866 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
|
3867 int count = (int)[cont numberOfRowsInTableView:cont]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
3868 |
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
|
3869 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
|
3870 { |
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
|
3871 *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
|
3872 } |
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
|
3873 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
|
3874 { |
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
|
3875 NSString *nstr = [cont getRow:index and:0]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
3876 |
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
|
3877 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
|
3878 } |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3879 } |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3880 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3881 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3882 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3883 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3884 * 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
|
3885 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3886 * 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
|
3887 * 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
|
3888 * 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
|
3889 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3890 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
|
3891 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3892 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
|
3893 DW_MUTEX_LOCK; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3894 id object = handle; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
3895 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3896 if([object isMemberOfClass:[DWComboBox class]]) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3897 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3898 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
|
3899 int count = (int)[combo numberOfItems]; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
3900 |
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
|
3901 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
|
3902 { |
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
|
3903 [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
|
3904 [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
|
3905 } |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3906 } |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3907 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
|
3908 { |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3909 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
|
3910 int count = (int)[cont numberOfRowsInTableView:cont]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
3911 |
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
|
3912 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
|
3913 { |
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
|
3914 NSString *nstr = [ NSString stringWithUTF8String:buffer ]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
3915 |
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
|
3916 [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
|
3917 [cont reloadData]; |
794
e9bc14c5c72d
Test fix for containers (and probably listboxes) not showing their content changes immediately.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
793
diff
changeset
|
3918 [cont setNeedsDisplay:YES]; |
720
357b59e57a31
Some fixes for out of range parameters passed to dw_listbox_g/set_text().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
719
diff
changeset
|
3919 } |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3920 } |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
3921 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3922 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3923 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3924 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3925 * 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
|
3926 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3927 * 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
|
3928 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3929 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
|
3930 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3931 id object = handle; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
3932 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3933 if([object isMemberOfClass:[DWComboBox class]]) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3934 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3935 DWComboBox *combo = handle; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3936 return (int)[combo indexOfSelectedItem]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3937 } |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3938 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
|
3939 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3940 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
|
3941 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
|
3942 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
|
3943 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
|
3944 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
|
3945 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
|
3946 } |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3947 return -1; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3948 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3949 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3950 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3951 * 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
|
3952 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3953 * handle: Handle to the listbox to be queried. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3954 * 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
|
3955 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3956 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
|
3957 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3958 int _locked_by_me = FALSE; |
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3959 DW_MUTEX_LOCK; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3960 id object = handle; |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3961 int retval = -1; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
3962 |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3963 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
|
3964 { |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3965 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
|
3966 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
|
3967 NSUInteger result = [selected indexGreaterThanIndex:where]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
3968 |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3969 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
|
3970 { |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3971 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
|
3972 } |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
3973 } |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3974 DW_MUTEX_UNLOCK; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3975 return retval; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3976 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3977 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3978 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3979 * 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
|
3980 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3981 * handle: Handle to the listbox to be set. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3982 * index: Item index. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3983 * 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
|
3984 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3985 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
|
3986 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
3987 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
|
3988 DW_MUTEX_LOCK; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3989 id object = handle; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
3990 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3991 if([object isMemberOfClass:[DWComboBox class]]) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3992 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3993 DWComboBox *combo = handle; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3994 if(state) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3995 [combo selectItemAtIndex:index]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3996 else |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3997 [combo deselectItemAtIndex:index]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
3998 } |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3999 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
|
4000 { |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
4001 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
|
4002 NSIndexSet *selected = [[NSIndexSet alloc] initWithIndex:(NSUInteger)index]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
4003 |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
4004 [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
|
4005 [selected release]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
4006 } |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4007 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4008 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4009 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4010 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4011 * 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
|
4012 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4013 * 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
|
4014 * index: Item index. |
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 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
|
4017 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4018 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
|
4019 DW_MUTEX_LOCK; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4020 id object = handle; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
4021 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4022 if([object isMemberOfClass:[DWComboBox class]]) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4023 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4024 DWComboBox *combo = handle; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
4025 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4026 [combo removeItemAtIndex:index]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4027 } |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
4028 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
|
4029 { |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
4030 DWContainer *cont = handle; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
4031 |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
4032 [cont removeRow:index]; |
670
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
4033 [cont reloadData]; |
794
e9bc14c5c72d
Test fix for containers (and probably listboxes) not showing their content changes immediately.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
793
diff
changeset
|
4034 [cont setNeedsDisplay:YES]; |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
4035 } |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4036 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4037 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4038 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4039 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4040 * 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
|
4041 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4042 * 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
|
4043 * 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
|
4044 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
4045 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
|
4046 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4047 DWComboBox *combo = [[DWComboBox alloc] init]; |
804
5b4a831af8fa
Fix for dw_combobox_new() not setting the default text in the entryfield.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
803
diff
changeset
|
4048 [combo setStringValue:[NSString stringWithUTF8String:text]]; |
703
329736825f9b
Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
702
diff
changeset
|
4049 [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
|
4050 [combo setTag:cid]; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4051 return combo; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4052 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4053 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4054 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4055 * 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
|
4056 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4057 * 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
|
4058 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
4059 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
|
4060 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4061 DWMLE *mle = [[DWMLE alloc] init]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
4062 NSScrollView *scrollview = [[NSScrollView alloc] init]; |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
4063 |
676
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
4064 [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
|
4065 [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
|
4066 [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
|
4067 [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
|
4068 [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
|
4069 [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
|
4070 /* [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
|
4071 [mle release]; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4072 return scrollview; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
4073 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4074 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4075 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4076 * 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
|
4077 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4078 * handle: Handle to the MLE to be queried. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4079 * buffer: Text buffer to be imported. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4080 * startpoint: Point to start entering text. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4081 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4082 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
|
4083 { |
676
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
4084 NSScrollView *sv = handle; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4085 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
|
4086 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
|
4087 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
|
4088 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
|
4089 [ms insertString:nstr atIndex:(startpoint+1)]; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4090 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
|
4091 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4092 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4093 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4094 * Grabs text from an MLE box. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4095 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4096 * 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
|
4097 * buffer: Text buffer to be exported. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4098 * startpoint: Point to start grabbing text. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4099 * 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
|
4100 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4101 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
|
4102 { |
676
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
4103 NSScrollView *sv = handle; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4104 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
|
4105 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
|
4106 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
|
4107 strncpy(buffer, [ms UTF8String], length); |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4108 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4109 |
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 * Obtains information about an MLE box. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4112 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4113 * 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
|
4114 * 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
|
4115 * 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
|
4116 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4117 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
|
4118 { |
676
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
4119 NSScrollView *sv = handle; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4120 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
|
4121 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
|
4122 NSMutableString *ms = [ts mutableString]; |
807
f7016a38bedd
Fix for dw_window_set_text() on buttons not working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
806
diff
changeset
|
4123 NSUInteger numberOfLines, index, stringLength = [ms length]; |
f7016a38bedd
Fix for dw_window_set_text() on buttons not working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
806
diff
changeset
|
4124 |
f7016a38bedd
Fix for dw_window_set_text() on buttons not working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
806
diff
changeset
|
4125 for(index=0, numberOfLines=0; index < stringLength; numberOfLines++) |
f7016a38bedd
Fix for dw_window_set_text() on buttons not working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
806
diff
changeset
|
4126 index = NSMaxRange([ms lineRangeForRange:NSMakeRange(index, 0)]); |
f7016a38bedd
Fix for dw_window_set_text() on buttons not working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
806
diff
changeset
|
4127 |
f7016a38bedd
Fix for dw_window_set_text() on buttons not working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
806
diff
changeset
|
4128 *bytes = stringLength; |
f7016a38bedd
Fix for dw_window_set_text() on buttons not working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
806
diff
changeset
|
4129 *lines = numberOfLines; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4130 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4131 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4132 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4133 * Deletes text from an MLE box. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4134 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4135 * 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
|
4136 * startpoint: Point to start deleting text. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4137 * 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
|
4138 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4139 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
|
4140 { |
676
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
4141 NSScrollView *sv = handle; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4142 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
|
4143 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
|
4144 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
|
4145 [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
|
4146 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4147 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4148 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4149 * 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
|
4150 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4151 * 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
|
4152 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4153 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
|
4154 { |
676
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
4155 NSScrollView *sv = handle; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4156 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
|
4157 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
|
4158 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
|
4159 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
|
4160 [ms deleteCharactersInRange:NSMakeRange(0, length)]; |
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 * 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
|
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 MLE to be positioned. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4167 * line: Line to be visible. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4168 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4169 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
|
4170 { |
802
676d46b31a11
Initial implementation of dw_mle_set_visible().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
801
diff
changeset
|
4171 NSScrollView *sv = handle; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4172 DWMLE *mle = [sv documentView]; |
802
676d46b31a11
Initial implementation of dw_mle_set_visible().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
801
diff
changeset
|
4173 NSTextStorage *ts = [mle textStorage]; |
676d46b31a11
Initial implementation of dw_mle_set_visible().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
801
diff
changeset
|
4174 NSMutableString *ms = [ts mutableString]; |
676d46b31a11
Initial implementation of dw_mle_set_visible().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
801
diff
changeset
|
4175 NSUInteger numberOfLines, index, stringLength = [ms length]; |
676d46b31a11
Initial implementation of dw_mle_set_visible().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
801
diff
changeset
|
4176 |
676d46b31a11
Initial implementation of dw_mle_set_visible().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
801
diff
changeset
|
4177 for(index=0, numberOfLines=0; index < stringLength && numberOfLines < line; numberOfLines++) |
676d46b31a11
Initial implementation of dw_mle_set_visible().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
801
diff
changeset
|
4178 index = NSMaxRange([ms lineRangeForRange:NSMakeRange(index, 0)]); |
676d46b31a11
Initial implementation of dw_mle_set_visible().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
801
diff
changeset
|
4179 |
676d46b31a11
Initial implementation of dw_mle_set_visible().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
801
diff
changeset
|
4180 if(line == numberOfLines) |
676d46b31a11
Initial implementation of dw_mle_set_visible().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
801
diff
changeset
|
4181 { |
676d46b31a11
Initial implementation of dw_mle_set_visible().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
801
diff
changeset
|
4182 [mle scrollRangeToVisible:[ms lineRangeForRange:NSMakeRange(index, 0)]]; |
676d46b31a11
Initial implementation of dw_mle_set_visible().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
801
diff
changeset
|
4183 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4184 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4185 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4186 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4187 * 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
|
4188 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4189 * handle: Handle to the MLE. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4190 * 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
|
4191 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4192 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
|
4193 { |
676
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
4194 NSScrollView *sv = handle; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4195 DWMLE *mle = [sv documentView]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4196 if(state) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4197 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4198 [mle setEditable:YES]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4199 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4200 else |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4201 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4202 [mle setEditable:NO]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4203 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4204 } |
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 * 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
|
4208 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4209 * handle: Handle to the MLE. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4210 * 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
|
4211 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4212 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
|
4213 { |
676
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
4214 NSScrollView *sv = handle; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4215 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
|
4216 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
|
4217 { |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4218 [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
|
4219 } |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4220 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
|
4221 { |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4222 [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
|
4223 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4224 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4225 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4226 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4227 * 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
|
4228 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4229 * 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
|
4230 * point: Point to position cursor. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4231 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4232 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
|
4233 { |
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
|
4234 NSScrollView *sv = handle; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4235 DWMLE *mle = [sv documentView]; |
712
01107d8e033e
Fixed the scrollbar maximum range to be correct. Also added some MLE code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
711
diff
changeset
|
4236 [mle setSelectedRange: NSMakeRange(point,point)]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4237 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4238 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4239 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4240 * Finds text in an MLE box. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4241 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4242 * 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
|
4243 * text: Text to search for. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4244 * point: Start point of search. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4245 * flags: Search specific flags. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4246 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4247 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
|
4248 { |
888
cd6ff038e38b
Implemented dw_mle_search on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
887
diff
changeset
|
4249 NSScrollView *sv = handle; |
cd6ff038e38b
Implemented dw_mle_search on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
887
diff
changeset
|
4250 DWMLE *mle = [sv documentView]; |
cd6ff038e38b
Implemented dw_mle_search on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
887
diff
changeset
|
4251 NSTextStorage *ts = [mle textStorage]; |
cd6ff038e38b
Implemented dw_mle_search on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
887
diff
changeset
|
4252 NSMutableString *ms = [ts mutableString]; |
cd6ff038e38b
Implemented dw_mle_search on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
887
diff
changeset
|
4253 NSString *searchForMe = [NSString stringWithUTF8String:text]; |
cd6ff038e38b
Implemented dw_mle_search on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
887
diff
changeset
|
4254 NSRange searchRange = NSMakeRange(point, [ms length] - point); |
cd6ff038e38b
Implemented dw_mle_search on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
887
diff
changeset
|
4255 NSRange range = NSMakeRange(NSNotFound, 0); |
cd6ff038e38b
Implemented dw_mle_search on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
887
diff
changeset
|
4256 NSUInteger options = flags ? flags : NSCaseInsensitiveSearch; |
cd6ff038e38b
Implemented dw_mle_search on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
887
diff
changeset
|
4257 |
cd6ff038e38b
Implemented dw_mle_search on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
887
diff
changeset
|
4258 if(ms) |
cd6ff038e38b
Implemented dw_mle_search on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
887
diff
changeset
|
4259 { |
cd6ff038e38b
Implemented dw_mle_search on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
887
diff
changeset
|
4260 range = [ms rangeOfString:searchForMe options:options range:searchRange]; |
cd6ff038e38b
Implemented dw_mle_search on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
887
diff
changeset
|
4261 } |
cd6ff038e38b
Implemented dw_mle_search on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
887
diff
changeset
|
4262 |
cd6ff038e38b
Implemented dw_mle_search on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
887
diff
changeset
|
4263 if(range.location != NSNotFound) |
cd6ff038e38b
Implemented dw_mle_search on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
887
diff
changeset
|
4264 { |
cd6ff038e38b
Implemented dw_mle_search on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
887
diff
changeset
|
4265 return -1; |
cd6ff038e38b
Implemented dw_mle_search on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
887
diff
changeset
|
4266 } |
cd6ff038e38b
Implemented dw_mle_search on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
887
diff
changeset
|
4267 return (int)range.location; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4268 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4269 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4270 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4271 * Stops redrawing of an MLE box. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4272 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4273 * 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
|
4274 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4275 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
|
4276 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4277 /* 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
|
4278 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4279 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4280 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4281 * Resumes redrawing of an MLE box. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4282 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4283 * 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
|
4284 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4285 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
|
4286 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4287 /* 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
|
4288 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4289 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4290 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4291 * 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
|
4292 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4293 * 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
|
4294 * 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
|
4295 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
4296 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
|
4297 { |
751
eba6ab48c952
Runtime Snow Leopard checks where possible and visual fix for Leopard status text.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
749
diff
changeset
|
4298 NSTextField *textfield = dw_text_new(text, cid); |
eba6ab48c952
Runtime Snow Leopard checks where possible and visual fix for Leopard status text.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
749
diff
changeset
|
4299 [textfield setBordered:YES]; |
eba6ab48c952
Runtime Snow Leopard checks where possible and visual fix for Leopard status text.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
749
diff
changeset
|
4300 if(DWOSMinor > 5) |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4301 { |
751
eba6ab48c952
Runtime Snow Leopard checks where possible and visual fix for Leopard status text.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
749
diff
changeset
|
4302 [textfield setBezeled:YES]; |
eba6ab48c952
Runtime Snow Leopard checks where possible and visual fix for Leopard status text.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
749
diff
changeset
|
4303 [textfield setBezelStyle:NSTextFieldSquareBezel]; |
eba6ab48c952
Runtime Snow Leopard checks where possible and visual fix for Leopard status text.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
749
diff
changeset
|
4304 } |
eba6ab48c952
Runtime Snow Leopard checks where possible and visual fix for Leopard status text.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
749
diff
changeset
|
4305 [textfield setBackgroundColor:[NSColor clearColor]]; |
673
6d0f0dc7ff7c
Some minor font fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
672
diff
changeset
|
4306 [textfield setDrawsBackground:NO]; |
751
eba6ab48c952
Runtime Snow Leopard checks where possible and visual fix for Leopard status text.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
749
diff
changeset
|
4307 return textfield; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4308 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4309 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4310 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4311 * 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
|
4312 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4313 * 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
|
4314 * 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
|
4315 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
4316 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
|
4317 { |
744
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
4318 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
|
4319 [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
|
4320 [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
|
4321 [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
|
4322 [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
|
4323 [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
|
4324 [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
|
4325 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
|
4326 { |
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
4327 [[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
|
4328 } |
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
4329 return textfield; |
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 * 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
|
4334 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4335 * 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
|
4336 * Returns: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4337 * 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
|
4338 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
4339 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
|
4340 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4341 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
|
4342 /* [render setTag:cid]; Why doesn't this work? */ |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4343 return render; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4344 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4345 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4346 /* Sets the current foreground drawing color. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4347 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4348 * red: red value. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4349 * green: green value. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4350 * blue: blue value. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4351 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4352 void API dw_color_foreground_set(unsigned long value) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4353 { |
826
6bb8bff36548
Implemented thread specific colors. Allows threads to have their own colors... also reducing color object recreation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
825
diff
changeset
|
4354 NSColor *oldcolor = pthread_getspecific(_dw_fg_color_key); |
6bb8bff36548
Implemented thread specific colors. Allows threads to have their own colors... also reducing color object recreation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
825
diff
changeset
|
4355 NSColor *newcolor; |
6bb8bff36548
Implemented thread specific colors. Allows threads to have their own colors... also reducing color object recreation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
825
diff
changeset
|
4356 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4357 _foreground = _get_color(value); |
826
6bb8bff36548
Implemented thread specific colors. Allows threads to have their own colors... also reducing color object recreation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
825
diff
changeset
|
4358 |
6bb8bff36548
Implemented thread specific colors. Allows threads to have their own colors... also reducing color object recreation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
825
diff
changeset
|
4359 newcolor = [[NSColor colorWithDeviceRed: DW_RED_VALUE(_foreground)/255.0 green: |
6bb8bff36548
Implemented thread specific colors. Allows threads to have their own colors... also reducing color object recreation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
825
diff
changeset
|
4360 DW_GREEN_VALUE(_foreground)/255.0 blue: |
6bb8bff36548
Implemented thread specific colors. Allows threads to have their own colors... also reducing color object recreation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
825
diff
changeset
|
4361 DW_BLUE_VALUE(_foreground)/255.0 alpha: 1] retain]; |
6bb8bff36548
Implemented thread specific colors. Allows threads to have their own colors... also reducing color object recreation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
825
diff
changeset
|
4362 pthread_setspecific(_dw_fg_color_key, newcolor); |
6bb8bff36548
Implemented thread specific colors. Allows threads to have their own colors... also reducing color object recreation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
825
diff
changeset
|
4363 [oldcolor release]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4364 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4365 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4366 /* Sets the current background drawing color. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4367 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4368 * red: red value. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4369 * green: green value. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4370 * blue: blue value. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4371 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4372 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
|
4373 { |
826
6bb8bff36548
Implemented thread specific colors. Allows threads to have their own colors... also reducing color object recreation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
825
diff
changeset
|
4374 NSColor *oldcolor = pthread_getspecific(_dw_bg_color_key); |
6bb8bff36548
Implemented thread specific colors. Allows threads to have their own colors... also reducing color object recreation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
825
diff
changeset
|
4375 NSColor *newcolor; |
6bb8bff36548
Implemented thread specific colors. Allows threads to have their own colors... also reducing color object recreation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
825
diff
changeset
|
4376 |
891
3774af45eb0c
Fix for dw_draw_text() not using the background color on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
890
diff
changeset
|
4377 if(value == DW_CLR_DEFAULT) |
3774af45eb0c
Fix for dw_draw_text() not using the background color on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
890
diff
changeset
|
4378 { |
3774af45eb0c
Fix for dw_draw_text() not using the background color on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
890
diff
changeset
|
4379 pthread_setspecific(_dw_bg_color_key, NULL); |
3774af45eb0c
Fix for dw_draw_text() not using the background color on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
890
diff
changeset
|
4380 } |
3774af45eb0c
Fix for dw_draw_text() not using the background color on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
890
diff
changeset
|
4381 else |
3774af45eb0c
Fix for dw_draw_text() not using the background color on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
890
diff
changeset
|
4382 { |
3774af45eb0c
Fix for dw_draw_text() not using the background color on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
890
diff
changeset
|
4383 _background = _get_color(value); |
826
6bb8bff36548
Implemented thread specific colors. Allows threads to have their own colors... also reducing color object recreation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
825
diff
changeset
|
4384 |
891
3774af45eb0c
Fix for dw_draw_text() not using the background color on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
890
diff
changeset
|
4385 newcolor = [[NSColor colorWithDeviceRed: DW_RED_VALUE(_background)/255.0 green: |
3774af45eb0c
Fix for dw_draw_text() not using the background color on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
890
diff
changeset
|
4386 DW_GREEN_VALUE(_background)/255.0 blue: |
3774af45eb0c
Fix for dw_draw_text() not using the background color on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
890
diff
changeset
|
4387 DW_BLUE_VALUE(_background)/255.0 alpha: 1] retain]; |
3774af45eb0c
Fix for dw_draw_text() not using the background color on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
890
diff
changeset
|
4388 pthread_setspecific(_dw_bg_color_key, newcolor); |
3774af45eb0c
Fix for dw_draw_text() not using the background color on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
890
diff
changeset
|
4389 } |
826
6bb8bff36548
Implemented thread specific colors. Allows threads to have their own colors... also reducing color object recreation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
825
diff
changeset
|
4390 [oldcolor release]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4391 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4392 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4393 /* 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
|
4394 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4395 * value: current color |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4396 * Returns: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4397 * 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
|
4398 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4399 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
|
4400 { |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
4401 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
|
4402 /* 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
|
4403 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
|
4404 DWDialog *dialog; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
4405 |
733
8d5e5b89725f
Fixed the crashing issue with dw_color_choose() it now functions properly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
732
diff
changeset
|
4406 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
|
4407 { |
db3a173e487e
Fixes for the color chooser... it now works a single time. However...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
731
diff
changeset
|
4408 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
|
4409 /* 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
|
4410 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
|
4411 { |
8d5e5b89725f
Fixed the crashing issue with dw_color_choose() it now functions properly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
732
diff
changeset
|
4412 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
|
4413 } |
732
db3a173e487e
Fixes for the color chooser... it now works a single time. However...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
731
diff
changeset
|
4414 } |
db3a173e487e
Fixes for the color chooser... it now works a single time. However...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
731
diff
changeset
|
4415 else |
db3a173e487e
Fixes for the color chooser... it now works a single time. However...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
731
diff
changeset
|
4416 { |
733
8d5e5b89725f
Fixed the crashing issue with dw_color_choose() it now functions properly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
732
diff
changeset
|
4417 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
|
4418 /* Set defaults for the dialog. */ |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
4419 [colorDlg setContinuous:NO]; |
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
4420 [colorDlg setTarget:colorDlg]; |
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
4421 [colorDlg setAction:@selector(changeColor:)]; |
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
4422 } |
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
4423 |
733
8d5e5b89725f
Fixed the crashing issue with dw_color_choose() it now functions properly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
732
diff
changeset
|
4424 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
|
4425 [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
|
4426 [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
|
4427 [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
|
4428 |
732
db3a173e487e
Fixes for the color chooser... it now works a single time. However...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
731
diff
changeset
|
4429 /* 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
|
4430 color = (NSColor *)dw_dialog_wait(dialog); |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
4431 |
732
db3a173e487e
Fixes for the color chooser... it now works a single time. However...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
731
diff
changeset
|
4432 /* 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
|
4433 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
|
4434 [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
|
4435 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
|
4436 return value; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4437 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4438 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4439 /* 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
|
4440 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4441 * handle: Handle to the window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4442 * 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
|
4443 * x: X coordinate. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4444 * y: Y coordinate. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4445 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4446 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
|
4447 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4448 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
|
4449 DW_MUTEX_LOCK; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4450 id image = handle; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4451 if(pixmap) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4452 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4453 image = (id)pixmap->image; |
909
c092eab43ae3
Experimental change to pixmap rendering. Switch from using NSImage to NSBitmapImageRef to store the image.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
902
diff
changeset
|
4454 [NSGraphicsContext saveGraphicsState]; |
c092eab43ae3
Experimental change to pixmap rendering. Switch from using NSImage to NSBitmapImageRef to store the image.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
902
diff
changeset
|
4455 [NSGraphicsContext setCurrentContext:[NSGraphicsContext |
915
361d80388dc9
Test fix at the partial bitblt issue on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
911
diff
changeset
|
4456 graphicsContextWithGraphicsPort:[[NSGraphicsContext graphicsContextWithBitmapImageRep:image] graphicsPort] flipped:YES]]; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4457 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4458 else |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4459 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4460 if([image lockFocusIfCanDraw] == NO) |
747
a4f99795ff26
Abort drawing functions if we fail to lock focus on a render control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
745
diff
changeset
|
4461 { |
a4f99795ff26
Abort drawing functions if we fail to lock focus on a render control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
745
diff
changeset
|
4462 DW_MUTEX_UNLOCK; |
a4f99795ff26
Abort drawing functions if we fail to lock focus on a render control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
745
diff
changeset
|
4463 return; |
a4f99795ff26
Abort drawing functions if we fail to lock focus on a render control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
745
diff
changeset
|
4464 } |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4465 _DWLastDrawable = handle; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4466 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4467 NSBezierPath* aPath = [NSBezierPath bezierPath]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4468 [aPath setLineWidth: 0.5]; |
826
6bb8bff36548
Implemented thread specific colors. Allows threads to have their own colors... also reducing color object recreation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
825
diff
changeset
|
4469 NSColor *color = pthread_getspecific(_dw_fg_color_key); |
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
|
4470 [color set]; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
4471 |
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
4472 [aPath moveToPoint:NSMakePoint(x, y)]; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4473 [aPath stroke]; |
909
c092eab43ae3
Experimental change to pixmap rendering. Switch from using NSImage to NSBitmapImageRef to store the image.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
902
diff
changeset
|
4474 if(pixmap) |
c092eab43ae3
Experimental change to pixmap rendering. Switch from using NSImage to NSBitmapImageRef to store the image.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
902
diff
changeset
|
4475 { |
c092eab43ae3
Experimental change to pixmap rendering. Switch from using NSImage to NSBitmapImageRef to store the image.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
902
diff
changeset
|
4476 [NSGraphicsContext restoreGraphicsState]; |
c092eab43ae3
Experimental change to pixmap rendering. Switch from using NSImage to NSBitmapImageRef to store the image.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
902
diff
changeset
|
4477 } |
c092eab43ae3
Experimental change to pixmap rendering. Switch from using NSImage to NSBitmapImageRef to store the image.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
902
diff
changeset
|
4478 else |
c092eab43ae3
Experimental change to pixmap rendering. Switch from using NSImage to NSBitmapImageRef to store the image.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
902
diff
changeset
|
4479 { |
c092eab43ae3
Experimental change to pixmap rendering. Switch from using NSImage to NSBitmapImageRef to store the image.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
902
diff
changeset
|
4480 [image unlockFocus]; |
c092eab43ae3
Experimental change to pixmap rendering. Switch from using NSImage to NSBitmapImageRef to store the image.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
902
diff
changeset
|
4481 } |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4482 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4483 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4484 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4485 /* 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
|
4486 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4487 * handle: Handle to the window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4488 * 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
|
4489 * x1: First X coordinate. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4490 * y1: First Y coordinate. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4491 * x2: Second X coordinate. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4492 * y2: Second Y coordinate. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4493 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4494 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
|
4495 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4496 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
|
4497 DW_MUTEX_LOCK; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4498 id image = handle; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4499 if(pixmap) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4500 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4501 image = (id)pixmap->image; |
909
c092eab43ae3
Experimental change to pixmap rendering. Switch from using NSImage to NSBitmapImageRef to store the image.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
902
diff
changeset
|
4502 [NSGraphicsContext saveGraphicsState]; |
c092eab43ae3
Experimental change to pixmap rendering. Switch from using NSImage to NSBitmapImageRef to store the image.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
902
diff
changeset
|
4503 [NSGraphicsContext setCurrentContext:[NSGraphicsContext |
915
361d80388dc9
Test fix at the partial bitblt issue on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
911
diff
changeset
|
4504 graphicsContextWithGraphicsPort:[[NSGraphicsContext graphicsContextWithBitmapImageRep:image] graphicsPort] flipped:YES]]; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4505 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4506 else |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4507 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4508 if([image lockFocusIfCanDraw] == NO) |
747
a4f99795ff26
Abort drawing functions if we fail to lock focus on a render control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
745
diff
changeset
|
4509 { |
a4f99795ff26
Abort drawing functions if we fail to lock focus on a render control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
745
diff
changeset
|
4510 DW_MUTEX_UNLOCK; |
a4f99795ff26
Abort drawing functions if we fail to lock focus on a render control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
745
diff
changeset
|
4511 return; |
a4f99795ff26
Abort drawing functions if we fail to lock focus on a render control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
745
diff
changeset
|
4512 } |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4513 _DWLastDrawable = handle; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4514 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4515 NSBezierPath* aPath = [NSBezierPath bezierPath]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4516 [aPath setLineWidth: 0.5]; |
826
6bb8bff36548
Implemented thread specific colors. Allows threads to have their own colors... also reducing color object recreation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
825
diff
changeset
|
4517 NSColor *color = pthread_getspecific(_dw_fg_color_key); |
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
|
4518 [color set]; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
4519 |
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
4520 [aPath moveToPoint:NSMakePoint(x1, y1)]; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4521 [aPath lineToPoint:NSMakePoint(x2, y2)]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4522 [aPath stroke]; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
4523 |
909
c092eab43ae3
Experimental change to pixmap rendering. Switch from using NSImage to NSBitmapImageRef to store the image.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
902
diff
changeset
|
4524 if(pixmap) |
c092eab43ae3
Experimental change to pixmap rendering. Switch from using NSImage to NSBitmapImageRef to store the image.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
902
diff
changeset
|
4525 { |
c092eab43ae3
Experimental change to pixmap rendering. Switch from using NSImage to NSBitmapImageRef to store the image.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
902
diff
changeset
|
4526 [NSGraphicsContext restoreGraphicsState]; |
c092eab43ae3
Experimental change to pixmap rendering. Switch from using NSImage to NSBitmapImageRef to store the image.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
902
diff
changeset
|
4527 } |
c092eab43ae3
Experimental change to pixmap rendering. Switch from using NSImage to NSBitmapImageRef to store the image.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
902
diff
changeset
|
4528 else |
c092eab43ae3
Experimental change to pixmap rendering. Switch from using NSImage to NSBitmapImageRef to store the image.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
902
diff
changeset
|
4529 { |
c092eab43ae3
Experimental change to pixmap rendering. Switch from using NSImage to NSBitmapImageRef to store the image.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
902
diff
changeset
|
4530 [image unlockFocus]; |
c092eab43ae3
Experimental change to pixmap rendering. Switch from using NSImage to NSBitmapImageRef to store the image.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
902
diff
changeset
|
4531 } |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4532 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4533 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4534 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4535 /* 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
|
4536 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4537 * handle: Handle to the window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4538 * 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
|
4539 * x: X coordinate. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4540 * y: Y coordinate. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4541 * text: Text to be displayed. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4542 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4543 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
|
4544 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4545 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
|
4546 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
|
4547 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
|
4548 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
|
4549 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
|
4550 { |
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
|
4551 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
|
4552 { |
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
|
4553 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
|
4554 NSFont *font = [render font]; |
747
a4f99795ff26
Abort drawing functions if we fail to lock focus on a render control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
745
diff
changeset
|
4555 if([image lockFocusIfCanDraw] == NO) |
a4f99795ff26
Abort drawing functions if we fail to lock focus on a render control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
745
diff
changeset
|
4556 { |
a4f99795ff26
Abort drawing functions if we fail to lock focus on a render control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
745
diff
changeset
|
4557 DW_MUTEX_UNLOCK; |
a4f99795ff26
Abort drawing functions if we fail to lock focus on a render control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
745
diff
changeset
|
4558 return; |
a4f99795ff26
Abort drawing functions if we fail to lock focus on a render control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
745
diff
changeset
|
4559 } |
891
3774af45eb0c
Fix for dw_draw_text() not using the background color on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
890
diff
changeset
|
4560 NSColor *fgcolor = pthread_getspecific(_dw_fg_color_key); |
3774af45eb0c
Fix for dw_draw_text() not using the background color on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
890
diff
changeset
|
4561 NSColor *bgcolor = pthread_getspecific(_dw_bg_color_key); |
3774af45eb0c
Fix for dw_draw_text() not using the background color on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
890
diff
changeset
|
4562 NSMutableDictionary *dict = [[NSMutableDictionary alloc] initWithObjectsAndKeys:fgcolor, NSForegroundColorAttributeName, nil]; |
3774af45eb0c
Fix for dw_draw_text() not using the background color on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
890
diff
changeset
|
4563 if(bgcolor) |
3774af45eb0c
Fix for dw_draw_text() not using the background color on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
890
diff
changeset
|
4564 { |
3774af45eb0c
Fix for dw_draw_text() not using the background color on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
890
diff
changeset
|
4565 [dict setValue:bgcolor forKey:NSBackgroundColorAttributeName]; |
3774af45eb0c
Fix for dw_draw_text() not using the background color on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
890
diff
changeset
|
4566 } |
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
|
4567 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
|
4568 { |
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
|
4569 [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
|
4570 } |
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
|
4571 [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
|
4572 [image unlockFocus]; |
827
dc094750d284
Fixed leak in dw_draw_text() not releasing the dictionary which was also pulling the NSColor along.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
826
diff
changeset
|
4573 [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
|
4574 } |
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
|
4575 _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
|
4576 } |
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
|
4577 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
|
4578 { |
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
|
4579 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
|
4580 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
|
4581 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
|
4582 { |
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
|
4583 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
|
4584 } |
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
|
4585 image = (id)pixmap->image; |
909
c092eab43ae3
Experimental change to pixmap rendering. Switch from using NSImage to NSBitmapImageRef to store the image.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
902
diff
changeset
|
4586 [NSGraphicsContext saveGraphicsState]; |
c092eab43ae3
Experimental change to pixmap rendering. Switch from using NSImage to NSBitmapImageRef to store the image.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
902
diff
changeset
|
4587 [NSGraphicsContext setCurrentContext:[NSGraphicsContext |
915
361d80388dc9
Test fix at the partial bitblt issue on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
911
diff
changeset
|
4588 graphicsContextWithGraphicsPort:[[NSGraphicsContext graphicsContextWithBitmapImageRep:image] graphicsPort] flipped:YES]]; |
891
3774af45eb0c
Fix for dw_draw_text() not using the background color on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
890
diff
changeset
|
4589 NSColor *fgcolor = pthread_getspecific(_dw_fg_color_key); |
3774af45eb0c
Fix for dw_draw_text() not using the background color on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
890
diff
changeset
|
4590 NSColor *bgcolor = pthread_getspecific(_dw_bg_color_key); |
3774af45eb0c
Fix for dw_draw_text() not using the background color on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
890
diff
changeset
|
4591 NSMutableDictionary *dict = [[NSMutableDictionary alloc] initWithObjectsAndKeys:fgcolor, NSForegroundColorAttributeName, nil]; |
3774af45eb0c
Fix for dw_draw_text() not using the background color on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
890
diff
changeset
|
4592 if(bgcolor) |
3774af45eb0c
Fix for dw_draw_text() not using the background color on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
890
diff
changeset
|
4593 { |
3774af45eb0c
Fix for dw_draw_text() not using the background color on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
890
diff
changeset
|
4594 [dict setValue:bgcolor forKey:NSBackgroundColorAttributeName]; |
3774af45eb0c
Fix for dw_draw_text() not using the background color on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
890
diff
changeset
|
4595 } |
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
|
4596 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
|
4597 { |
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
|
4598 [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
|
4599 } |
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
|
4600 [nstr drawAtPoint:NSMakePoint(x, y) withAttributes:dict]; |
909
c092eab43ae3
Experimental change to pixmap rendering. Switch from using NSImage to NSBitmapImageRef to store the image.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
902
diff
changeset
|
4601 [NSGraphicsContext restoreGraphicsState]; |
827
dc094750d284
Fixed leak in dw_draw_text() not releasing the dictionary which was also pulling the NSColor along.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
826
diff
changeset
|
4602 [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
|
4603 } |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4604 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4605 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4606 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4607 /* 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
|
4608 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4609 * handle: Handle to the window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4610 * 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
|
4611 * text: Text to be queried. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4612 * 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
|
4613 * 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
|
4614 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4615 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
|
4616 { |
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
|
4617 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
|
4618 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
|
4619 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
|
4620 { |
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
|
4621 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
|
4622 } |
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
|
4623 NSMutableDictionary *dict = [[NSMutableDictionary alloc] init]; |
828
14c9f4a8839e
Attempt to get dw_font_text_extents_get() on controls besides the render control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
827
diff
changeset
|
4624 if([object isMemberOfClass:[DWRender class]] || [object isKindOfClass:[NSControl class]]) |
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
|
4625 { |
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
|
4626 NSFont *font = [object font]; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
4627 |
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
|
4628 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
|
4629 { |
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
|
4630 [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
|
4631 } |
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
|
4632 } |
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
|
4633 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
|
4634 [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
|
4635 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
|
4636 { |
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
|
4637 *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
|
4638 } |
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
|
4639 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
|
4640 { |
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
|
4641 *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
|
4642 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4643 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4644 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4645 /* 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
|
4646 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4647 * handle: Handle to the window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4648 * 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
|
4649 * fill: Fill box TRUE or FALSE. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4650 * x: X coordinate. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4651 * y: Y coordinate. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4652 * width: Width of rectangle. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4653 * height: Height of rectangle. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4654 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4655 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
|
4656 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4657 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
|
4658 DW_MUTEX_LOCK; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4659 id image = handle; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4660 int z; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4661 if(pixmap) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4662 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4663 image = (id)pixmap->image; |
909
c092eab43ae3
Experimental change to pixmap rendering. Switch from using NSImage to NSBitmapImageRef to store the image.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
902
diff
changeset
|
4664 [NSGraphicsContext saveGraphicsState]; |
c092eab43ae3
Experimental change to pixmap rendering. Switch from using NSImage to NSBitmapImageRef to store the image.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
902
diff
changeset
|
4665 [NSGraphicsContext setCurrentContext:[NSGraphicsContext |
915
361d80388dc9
Test fix at the partial bitblt issue on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
911
diff
changeset
|
4666 graphicsContextWithGraphicsPort:[[NSGraphicsContext graphicsContextWithBitmapImageRep:image] graphicsPort] flipped:YES]]; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4667 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4668 else |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4669 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4670 if([image lockFocusIfCanDraw] == NO) |
747
a4f99795ff26
Abort drawing functions if we fail to lock focus on a render control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
745
diff
changeset
|
4671 { |
a4f99795ff26
Abort drawing functions if we fail to lock focus on a render control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
745
diff
changeset
|
4672 DW_MUTEX_UNLOCK; |
a4f99795ff26
Abort drawing functions if we fail to lock focus on a render control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
745
diff
changeset
|
4673 return; |
a4f99795ff26
Abort drawing functions if we fail to lock focus on a render control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
745
diff
changeset
|
4674 } |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4675 _DWLastDrawable = handle; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4676 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4677 NSBezierPath* aPath = [NSBezierPath bezierPath]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4678 [aPath setLineWidth: 0.5]; |
826
6bb8bff36548
Implemented thread specific colors. Allows threads to have their own colors... also reducing color object recreation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
825
diff
changeset
|
4679 NSColor *color = pthread_getspecific(_dw_fg_color_key); |
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
|
4680 [color set]; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
4681 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4682 [aPath moveToPoint:NSMakePoint(*x, *y)]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4683 for(z=1;z<npoints;z++) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4684 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4685 [aPath lineToPoint:NSMakePoint(x[z], y[z])]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4686 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4687 [aPath closePath]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4688 if(fill) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4689 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4690 [aPath fill]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4691 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4692 [aPath stroke]; |
909
c092eab43ae3
Experimental change to pixmap rendering. Switch from using NSImage to NSBitmapImageRef to store the image.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
902
diff
changeset
|
4693 if(pixmap) |
c092eab43ae3
Experimental change to pixmap rendering. Switch from using NSImage to NSBitmapImageRef to store the image.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
902
diff
changeset
|
4694 { |
c092eab43ae3
Experimental change to pixmap rendering. Switch from using NSImage to NSBitmapImageRef to store the image.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
902
diff
changeset
|
4695 [NSGraphicsContext restoreGraphicsState]; |
c092eab43ae3
Experimental change to pixmap rendering. Switch from using NSImage to NSBitmapImageRef to store the image.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
902
diff
changeset
|
4696 } |
c092eab43ae3
Experimental change to pixmap rendering. Switch from using NSImage to NSBitmapImageRef to store the image.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
902
diff
changeset
|
4697 else |
c092eab43ae3
Experimental change to pixmap rendering. Switch from using NSImage to NSBitmapImageRef to store the image.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
902
diff
changeset
|
4698 { |
c092eab43ae3
Experimental change to pixmap rendering. Switch from using NSImage to NSBitmapImageRef to store the image.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
902
diff
changeset
|
4699 [image unlockFocus]; |
c092eab43ae3
Experimental change to pixmap rendering. Switch from using NSImage to NSBitmapImageRef to store the image.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
902
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 /* 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
|
4705 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4706 * handle: Handle to the window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4707 * 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
|
4708 * fill: Fill box TRUE or FALSE. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4709 * x: X coordinate. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4710 * y: Y coordinate. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4711 * width: Width of rectangle. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4712 * height: Height of rectangle. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4713 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4714 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
|
4715 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4716 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
|
4717 DW_MUTEX_LOCK; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4718 id image = handle; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4719 if(pixmap) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4720 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4721 image = (id)pixmap->image; |
909
c092eab43ae3
Experimental change to pixmap rendering. Switch from using NSImage to NSBitmapImageRef to store the image.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
902
diff
changeset
|
4722 [NSGraphicsContext saveGraphicsState]; |
c092eab43ae3
Experimental change to pixmap rendering. Switch from using NSImage to NSBitmapImageRef to store the image.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
902
diff
changeset
|
4723 [NSGraphicsContext setCurrentContext:[NSGraphicsContext |
915
361d80388dc9
Test fix at the partial bitblt issue on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
911
diff
changeset
|
4724 graphicsContextWithGraphicsPort:[[NSGraphicsContext graphicsContextWithBitmapImageRep:image] graphicsPort] flipped:YES]]; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4725 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4726 else |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4727 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4728 if([image lockFocusIfCanDraw] == NO) |
747
a4f99795ff26
Abort drawing functions if we fail to lock focus on a render control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
745
diff
changeset
|
4729 { |
a4f99795ff26
Abort drawing functions if we fail to lock focus on a render control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
745
diff
changeset
|
4730 DW_MUTEX_UNLOCK; |
a4f99795ff26
Abort drawing functions if we fail to lock focus on a render control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
745
diff
changeset
|
4731 return; |
a4f99795ff26
Abort drawing functions if we fail to lock focus on a render control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
745
diff
changeset
|
4732 } |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4733 _DWLastDrawable = handle; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4734 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4735 NSBezierPath* aPath = [NSBezierPath bezierPath]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4736 [aPath setLineWidth: 0.5]; |
826
6bb8bff36548
Implemented thread specific colors. Allows threads to have their own colors... also reducing color object recreation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
825
diff
changeset
|
4737 NSColor *color = pthread_getspecific(_dw_fg_color_key); |
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
|
4738 [color set]; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
4739 |
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
4740 [aPath moveToPoint:NSMakePoint(x, y)]; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4741 [aPath lineToPoint:NSMakePoint(x, y + height)]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4742 [aPath lineToPoint:NSMakePoint(x + width, y + height)]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4743 [aPath lineToPoint:NSMakePoint(x + width, y)]; |
664
ba3af8eb56f1
Fixed drawing of rects and points. Fonts now properly draw in color. Updated property list.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
662
diff
changeset
|
4744 [aPath closePath]; |
767
9b0c22b58447
Don't fill a rectangle unless requested to
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
766
diff
changeset
|
4745 if(fill) |
9b0c22b58447
Don't fill a rectangle unless requested to
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
766
diff
changeset
|
4746 [aPath fill]; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4747 [aPath stroke]; |
909
c092eab43ae3
Experimental change to pixmap rendering. Switch from using NSImage to NSBitmapImageRef to store the image.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
902
diff
changeset
|
4748 if(pixmap) |
c092eab43ae3
Experimental change to pixmap rendering. Switch from using NSImage to NSBitmapImageRef to store the image.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
902
diff
changeset
|
4749 { |
c092eab43ae3
Experimental change to pixmap rendering. Switch from using NSImage to NSBitmapImageRef to store the image.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
902
diff
changeset
|
4750 [NSGraphicsContext restoreGraphicsState]; |
c092eab43ae3
Experimental change to pixmap rendering. Switch from using NSImage to NSBitmapImageRef to store the image.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
902
diff
changeset
|
4751 } |
c092eab43ae3
Experimental change to pixmap rendering. Switch from using NSImage to NSBitmapImageRef to store the image.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
902
diff
changeset
|
4752 else |
c092eab43ae3
Experimental change to pixmap rendering. Switch from using NSImage to NSBitmapImageRef to store the image.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
902
diff
changeset
|
4753 { |
c092eab43ae3
Experimental change to pixmap rendering. Switch from using NSImage to NSBitmapImageRef to store the image.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
902
diff
changeset
|
4754 [image unlockFocus]; |
c092eab43ae3
Experimental change to pixmap rendering. Switch from using NSImage to NSBitmapImageRef to store the image.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
902
diff
changeset
|
4755 } |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4756 DW_MUTEX_UNLOCK; |
650
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 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4760 * 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
|
4761 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4762 * 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
|
4763 * resource file. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4764 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
4765 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
|
4766 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4767 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
|
4768 DW_MUTEX_LOCK; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
4769 NSScrollView *scrollview = [[NSScrollView alloc] init]; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4770 DWTree *tree = [[DWTree alloc] init]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
4771 |
680
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
4772 [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
|
4773 [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
|
4774 [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
|
4775 [scrollview setAutohidesScrollers:YES]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
4776 |
680
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
4777 [tree setAllowsMultipleSelection:NO]; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4778 [tree setDataSource:tree]; |
882
1e7b7f870d88
Experimental change to use a single column for holding the filename and icon on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
881
diff
changeset
|
4779 [tree setDelegate:tree]; |
680
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
4780 [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
|
4781 [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
|
4782 [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
|
4783 [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
|
4784 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
|
4785 return tree; |
650
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 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4788 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4789 * 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
|
4790 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4791 * 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
|
4792 * 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
|
4793 * 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
|
4794 * icon: Handle to coresponding icon. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4795 * 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
|
4796 * itemdata: Item specific data. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4797 */ |
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
|
4798 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
|
4799 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4800 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
|
4801 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
|
4802 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
|
4803 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
|
4804 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
|
4805 [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
|
4806 [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
|
4807 [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
|
4808 [treenode addPointer:NULL]; |
881
7b2750744552
Implemented dw_tree_get_parent() for the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
873
diff
changeset
|
4809 [treenode addPointer:parent]; |
680
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
4810 [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
|
4811 [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
|
4812 DW_MUTEX_UNLOCK; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
4813 return treenode; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4814 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4815 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4816 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4817 * 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
|
4818 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4819 * 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
|
4820 * 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
|
4821 * icon: Handle to coresponding icon. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4822 * 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
|
4823 * itemdata: Item specific data. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4824 */ |
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
|
4825 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
|
4826 { |
680
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
4827 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
|
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 * 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
|
4832 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4833 * 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
|
4834 * 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
|
4835 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4836 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
|
4837 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4838 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
|
4839 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
|
4840 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
|
4841 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
|
4842 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
|
4843 return strdup([nstr UTF8String]); |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4844 } |
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 * 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
|
4848 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4849 * 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
|
4850 * 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
|
4851 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4852 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
|
4853 { |
881
7b2750744552
Implemented dw_tree_get_parent() for the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
873
diff
changeset
|
4854 int _locked_by_me = FALSE; |
7b2750744552
Implemented dw_tree_get_parent() for the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
873
diff
changeset
|
4855 HTREEITEM parent; |
7b2750744552
Implemented dw_tree_get_parent() for the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
873
diff
changeset
|
4856 |
7b2750744552
Implemented dw_tree_get_parent() for the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
873
diff
changeset
|
4857 DW_MUTEX_LOCK; |
7b2750744552
Implemented dw_tree_get_parent() for the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
873
diff
changeset
|
4858 NSPointerArray *array = (NSPointerArray *)item; |
7b2750744552
Implemented dw_tree_get_parent() for the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
873
diff
changeset
|
4859 parent = (HTREEITEM)[array pointerAtIndex:4]; |
7b2750744552
Implemented dw_tree_get_parent() for the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
873
diff
changeset
|
4860 DW_MUTEX_UNLOCK; |
7b2750744552
Implemented dw_tree_get_parent() for the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
873
diff
changeset
|
4861 return parent; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4862 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4863 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4864 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4865 * 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
|
4866 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4867 * 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
|
4868 * 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
|
4869 * 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
|
4870 * icon: Handle to coresponding icon. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4871 */ |
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
|
4872 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
|
4873 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4874 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
|
4875 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
|
4876 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
|
4877 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
|
4878 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
|
4879 { |
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
|
4880 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
|
4881 [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
|
4882 } |
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
|
4883 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
|
4884 { |
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
|
4885 [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
|
4886 } |
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
|
4887 [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
|
4888 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4889 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4890 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4891 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4892 * 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
|
4893 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4894 * 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
|
4895 * 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
|
4896 * 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
|
4897 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4898 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
|
4899 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4900 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
|
4901 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
|
4902 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
|
4903 [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
|
4904 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4905 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4906 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4907 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4908 * 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
|
4909 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4910 * 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
|
4911 * 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
|
4912 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4913 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
|
4914 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4915 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
|
4916 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
|
4917 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
|
4918 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
|
4919 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
|
4920 return result; |
650
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 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4923 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4924 * 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
|
4925 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4926 * 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
|
4927 * 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
|
4928 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4929 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
|
4930 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4931 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
|
4932 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
|
4933 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
|
4934 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
|
4935 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
|
4936 { |
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
|
4937 [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
|
4938 } |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4939 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4940 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4941 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4942 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4943 * Removes all nodes from a tree. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4944 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4945 * 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
|
4946 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4947 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
|
4948 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4949 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
|
4950 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
|
4951 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
|
4952 [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
|
4953 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4954 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4955 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4956 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4957 * Expands a node on a tree. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4958 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4959 * 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
|
4960 * 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
|
4961 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4962 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
|
4963 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4964 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
|
4965 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
|
4966 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
|
4967 [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
|
4968 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4969 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4970 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4971 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4972 * Collapses a node on a tree. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4973 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4974 * 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
|
4975 * 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
|
4976 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4977 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
|
4978 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4979 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
|
4980 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
|
4981 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
|
4982 [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
|
4983 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4984 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4985 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4986 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4987 * Removes a node from a tree. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4988 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4989 * 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
|
4990 * 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
|
4991 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4992 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
|
4993 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
4994 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
|
4995 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
|
4996 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
|
4997 [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
|
4998 [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
|
4999 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5000 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5001 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5002 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5003 * 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
|
5004 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5005 * 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
|
5006 * resource file. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5007 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
5008 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
|
5009 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
5010 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
|
5011 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
|
5012 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
|
5013 NSScrollView *scrollview = [cont scrollview]; |
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
5014 [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
|
5015 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
|
5016 [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
|
5017 [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
|
5018 [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
|
5019 [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
|
5020 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
|
5021 return cont; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5022 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5023 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5024 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5025 * Sets up the container columns. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5026 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5027 * 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
|
5028 * 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
|
5029 * 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
|
5030 * 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
|
5031 * 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
|
5032 * (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
|
5033 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5034 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
|
5035 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
5036 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
|
5037 DW_MUTEX_LOCK; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5038 int z; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5039 DWContainer *cont = handle; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
5040 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5041 [cont setup]; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
5042 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5043 for(z=0;z<count;z++) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5044 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5045 NSTableColumn *column = [[NSTableColumn alloc] init]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5046 [[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
|
5047 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
|
5048 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
5049 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
|
5050 [column setDataCell:imagecell]; |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
5051 [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
|
5052 } |
882
1e7b7f870d88
Experimental change to use a single column for holding the filename and icon on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
881
diff
changeset
|
5053 else if(flags[z] & DW_CFA_STRINGANDICON) |
1e7b7f870d88
Experimental change to use a single column for holding the filename and icon on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
881
diff
changeset
|
5054 { |
1e7b7f870d88
Experimental change to use a single column for holding the filename and icon on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
881
diff
changeset
|
5055 NSBrowserCell *browsercell = [[NSBrowserCell alloc] init]; |
1e7b7f870d88
Experimental change to use a single column for holding the filename and icon on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
881
diff
changeset
|
5056 [browsercell setLeaf:YES]; |
1e7b7f870d88
Experimental change to use a single column for holding the filename and icon on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
881
diff
changeset
|
5057 [column setDataCell:browsercell]; |
1e7b7f870d88
Experimental change to use a single column for holding the filename and icon on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
881
diff
changeset
|
5058 [browsercell release]; |
1e7b7f870d88
Experimental change to use a single column for holding the filename and icon on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
881
diff
changeset
|
5059 } |
1e7b7f870d88
Experimental change to use a single column for holding the filename and icon on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
881
diff
changeset
|
5060 /* Defaults to left justified so just handle right and center */ |
1e7b7f870d88
Experimental change to use a single column for holding the filename and icon on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
881
diff
changeset
|
5061 if(flags[z] & DW_CFA_RIGHT) |
855
0103a8751ab4
Removed an unnecessary method in the container (rowCount) and implemented container column alignment.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
854
diff
changeset
|
5062 { |
0103a8751ab4
Removed an unnecessary method in the container (rowCount) and implemented container column alignment.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
854
diff
changeset
|
5063 [(NSCell *)[column dataCell] setAlignment:NSRightTextAlignment]; |
858
80f3e108fa43
Also align the header cells, not just the data ones.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
857
diff
changeset
|
5064 [(NSCell *)[column headerCell] setAlignment:NSRightTextAlignment]; |
855
0103a8751ab4
Removed an unnecessary method in the container (rowCount) and implemented container column alignment.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
854
diff
changeset
|
5065 } |
0103a8751ab4
Removed an unnecessary method in the container (rowCount) and implemented container column alignment.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
854
diff
changeset
|
5066 else if(flags[z] & DW_CFA_CENTER) |
0103a8751ab4
Removed an unnecessary method in the container (rowCount) and implemented container column alignment.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
854
diff
changeset
|
5067 { |
0103a8751ab4
Removed an unnecessary method in the container (rowCount) and implemented container column alignment.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
854
diff
changeset
|
5068 [(NSCell *)[column dataCell] setAlignment:NSCenterTextAlignment]; |
858
80f3e108fa43
Also align the header cells, not just the data ones.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
857
diff
changeset
|
5069 [(NSCell *)[column headerCell] setAlignment:NSCenterTextAlignment]; |
855
0103a8751ab4
Removed an unnecessary method in the container (rowCount) and implemented container column alignment.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
854
diff
changeset
|
5070 } |
795
f23cad02cfb3
Make listbox, container and tree cells uneditable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
794
diff
changeset
|
5071 [column setEditable:NO]; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5072 [cont addTableColumn:column]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5073 [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
|
5074 [column release]; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
5075 } |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
5076 DW_MUTEX_UNLOCK; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5077 return TRUE; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5078 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5079 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5080 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5081 * 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
|
5082 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5083 * 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
|
5084 * 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
|
5085 * 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
|
5086 * 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
|
5087 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5088 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
|
5089 { |
882
1e7b7f870d88
Experimental change to use a single column for holding the filename and icon on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
881
diff
changeset
|
5090 char **newtitles = malloc(sizeof(char *) * (count + 1)); |
1e7b7f870d88
Experimental change to use a single column for holding the filename and icon on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
881
diff
changeset
|
5091 unsigned long *newflags = malloc(sizeof(unsigned long) * (count + 1)); |
813
7fa26d8cc8d0
Fix for column click handler not working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
812
diff
changeset
|
5092 DWContainer *cont = handle; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
5093 |
882
1e7b7f870d88
Experimental change to use a single column for holding the filename and icon on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
881
diff
changeset
|
5094 newtitles[0] = "Filename"; |
1e7b7f870d88
Experimental change to use a single column for holding the filename and icon on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
881
diff
changeset
|
5095 |
1e7b7f870d88
Experimental change to use a single column for holding the filename and icon on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
881
diff
changeset
|
5096 newflags[0] = DW_CFA_STRINGANDICON | DW_CFA_LEFT | DW_CFA_HORZSEPARATOR; |
1e7b7f870d88
Experimental change to use a single column for holding the filename and icon on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
881
diff
changeset
|
5097 |
1e7b7f870d88
Experimental change to use a single column for holding the filename and icon on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
881
diff
changeset
|
5098 memcpy(&newtitles[1], titles, sizeof(char *) * count); |
1e7b7f870d88
Experimental change to use a single column for holding the filename and icon on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
881
diff
changeset
|
5099 memcpy(&newflags[1], flags, sizeof(unsigned long) * count); |
1e7b7f870d88
Experimental change to use a single column for holding the filename and icon on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
881
diff
changeset
|
5100 |
1e7b7f870d88
Experimental change to use a single column for holding the filename and icon on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
881
diff
changeset
|
5101 dw_container_setup(handle, newflags, newtitles, count + 1, 0); |
813
7fa26d8cc8d0
Fix for column click handler not working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
812
diff
changeset
|
5102 [cont setFilesystem:YES]; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
5103 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5104 free(newtitles); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5105 free(newflags); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5106 return TRUE; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5107 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5108 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5109 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5110 * 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
|
5111 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5112 * 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
|
5113 * 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
|
5114 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5115 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
|
5116 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
5117 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
|
5118 DW_MUTEX_LOCK; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5119 DWContainer *cont = handle; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5120 [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
|
5121 DW_MUTEX_UNLOCK; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5122 return cont; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5123 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5124 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5125 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5126 * 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
|
5127 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5128 * 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
|
5129 * 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
|
5130 * 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
|
5131 * 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
|
5132 * 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
|
5133 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5134 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
|
5135 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
5136 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
|
5137 DW_MUTEX_LOCK; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5138 DWContainer *cont = handle; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5139 id object = nil; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5140 int type = [cont cellType:column]; |
801
5d8e4ecb7820
Think we need to ignore the last add point when the pointer argument is NULL.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
800
diff
changeset
|
5141 int lastadd = 0; |
5d8e4ecb7820
Think we need to ignore the last add point when the pointer argument is NULL.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
800
diff
changeset
|
5142 |
5d8e4ecb7820
Think we need to ignore the last add point when the pointer argument is NULL.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
800
diff
changeset
|
5143 /* If pointer is NULL we are getting a change request instead of set */ |
5d8e4ecb7820
Think we need to ignore the last add point when the pointer argument is NULL.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
800
diff
changeset
|
5144 if(pointer) |
5d8e4ecb7820
Think we need to ignore the last add point when the pointer argument is NULL.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
800
diff
changeset
|
5145 { |
5d8e4ecb7820
Think we need to ignore the last add point when the pointer argument is NULL.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
800
diff
changeset
|
5146 lastadd = [cont lastAddPoint]; |
5d8e4ecb7820
Think we need to ignore the last add point when the pointer argument is NULL.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
800
diff
changeset
|
5147 } |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
5148 |
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
|
5149 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
|
5150 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
5151 DW_MUTEX_UNLOCK; |
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
|
5152 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
|
5153 } |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5154 if(type & DW_CFA_BITMAPORICON) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5155 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5156 object = *((NSImage **)data); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5157 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5158 else if(type & DW_CFA_STRING) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5159 { |
726
ecf47778caff
Possible fix for container string columns not showing correctly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
725
diff
changeset
|
5160 char *str = *((char **)data); |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5161 object = [ NSString stringWithUTF8String:str ]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5162 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5163 else |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5164 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5165 char textbuffer[100]; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
5166 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5167 if(type & DW_CFA_ULONG) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5168 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5169 ULONG tmp = *((ULONG *)data); |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
5170 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5171 sprintf(textbuffer, "%lu", tmp); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5172 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5173 else if(type & DW_CFA_DATE) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5174 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5175 struct tm curtm; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5176 CDATE cdate = *((CDATE *)data); |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
5177 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5178 memset( &curtm, 0, sizeof(curtm) ); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5179 curtm.tm_mday = cdate.day; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5180 curtm.tm_mon = cdate.month - 1; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5181 curtm.tm_year = cdate.year - 1900; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
5182 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5183 strftime(textbuffer, 100, "%x", &curtm); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5184 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5185 else if(type & DW_CFA_TIME) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5186 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5187 struct tm curtm; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5188 CTIME ctime = *((CTIME *)data); |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
5189 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5190 memset( &curtm, 0, sizeof(curtm) ); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5191 curtm.tm_hour = ctime.hours; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5192 curtm.tm_min = ctime.minutes; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5193 curtm.tm_sec = ctime.seconds; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
5194 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5195 strftime(textbuffer, 100, "%X", &curtm); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5196 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5197 else |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5198 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
5199 DW_MUTEX_UNLOCK; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5200 return; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5201 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5202 object = [ NSString stringWithUTF8String:textbuffer ]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5203 } |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
5204 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5205 [cont editCell:object at:(row+lastadd) and:column]; |
794
e9bc14c5c72d
Test fix for containers (and probably listboxes) not showing their content changes immediately.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
793
diff
changeset
|
5206 [cont setNeedsDisplay:YES]; |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
5207 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5208 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5209 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5210 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5211 * 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
|
5212 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5213 * 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
|
5214 * 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
|
5215 * 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
|
5216 * 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
|
5217 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5218 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
|
5219 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5220 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
|
5221 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5222 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5223 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5224 * 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
|
5225 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5226 * 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
|
5227 * 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
|
5228 * 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
|
5229 * 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
|
5230 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5231 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
|
5232 { |
882
1e7b7f870d88
Experimental change to use a single column for holding the filename and icon on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
881
diff
changeset
|
5233 dw_container_change_item(handle, column+1, row, data); |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5234 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5235 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5236 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5237 * 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
|
5238 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5239 * 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
|
5240 * 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
|
5241 * 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
|
5242 * 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
|
5243 * 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
|
5244 */ |
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
|
5245 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
|
5246 { |
882
1e7b7f870d88
Experimental change to use a single column for holding the filename and icon on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
881
diff
changeset
|
5247 dw_filesystem_set_file(handle, NULL, row, filename, icon); |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5248 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5249 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5250 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5251 * 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
|
5252 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5253 * 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
|
5254 * 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
|
5255 * 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
|
5256 * 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
|
5257 * 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
|
5258 */ |
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
|
5259 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
|
5260 { |
882
1e7b7f870d88
Experimental change to use a single column for holding the filename and icon on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
881
diff
changeset
|
5261 int _locked_by_me = FALSE; |
1e7b7f870d88
Experimental change to use a single column for holding the filename and icon on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
881
diff
changeset
|
5262 DW_MUTEX_LOCK; |
1e7b7f870d88
Experimental change to use a single column for holding the filename and icon on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
881
diff
changeset
|
5263 DWContainer *cont = handle; |
1e7b7f870d88
Experimental change to use a single column for holding the filename and icon on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
881
diff
changeset
|
5264 NSBrowserCell *browsercell; |
1e7b7f870d88
Experimental change to use a single column for holding the filename and icon on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
881
diff
changeset
|
5265 int lastadd = 0; |
1e7b7f870d88
Experimental change to use a single column for holding the filename and icon on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
881
diff
changeset
|
5266 |
1e7b7f870d88
Experimental change to use a single column for holding the filename and icon on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
881
diff
changeset
|
5267 /* If pointer is NULL we are getting a change request instead of set */ |
1e7b7f870d88
Experimental change to use a single column for holding the filename and icon on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
881
diff
changeset
|
5268 if(pointer) |
1e7b7f870d88
Experimental change to use a single column for holding the filename and icon on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
881
diff
changeset
|
5269 { |
1e7b7f870d88
Experimental change to use a single column for holding the filename and icon on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
881
diff
changeset
|
5270 lastadd = [cont lastAddPoint]; |
1e7b7f870d88
Experimental change to use a single column for holding the filename and icon on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
881
diff
changeset
|
5271 } |
1e7b7f870d88
Experimental change to use a single column for holding the filename and icon on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
881
diff
changeset
|
5272 |
1e7b7f870d88
Experimental change to use a single column for holding the filename and icon on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
881
diff
changeset
|
5273 browsercell = [[NSBrowserCell alloc] init]; |
1e7b7f870d88
Experimental change to use a single column for holding the filename and icon on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
881
diff
changeset
|
5274 [browsercell setLeaf:YES]; |
1e7b7f870d88
Experimental change to use a single column for holding the filename and icon on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
881
diff
changeset
|
5275 [browsercell setImage:icon]; |
1e7b7f870d88
Experimental change to use a single column for holding the filename and icon on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
881
diff
changeset
|
5276 [browsercell setStringValue:[ NSString stringWithUTF8String:filename ]]; |
1e7b7f870d88
Experimental change to use a single column for holding the filename and icon on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
881
diff
changeset
|
5277 [cont editCell:browsercell at:(row+lastadd) and:0]; |
1e7b7f870d88
Experimental change to use a single column for holding the filename and icon on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
881
diff
changeset
|
5278 [cont setNeedsDisplay:YES]; |
1e7b7f870d88
Experimental change to use a single column for holding the filename and icon on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
881
diff
changeset
|
5279 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5280 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5281 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5282 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5283 * 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
|
5284 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5285 * 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
|
5286 * 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
|
5287 * 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
|
5288 * 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
|
5289 * 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
|
5290 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5291 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
|
5292 { |
882
1e7b7f870d88
Experimental change to use a single column for holding the filename and icon on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
881
diff
changeset
|
5293 dw_container_set_item(handle, pointer, column+1, row, data); |
650
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 |
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 * 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
|
5298 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5299 * 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
|
5300 * column: Zero based column. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5301 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5302 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
|
5303 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
5304 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
|
5305 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
|
5306 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
|
5307 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
|
5308 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
|
5309 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
|
5310 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
|
5311 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
|
5312 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
|
5313 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
|
5314 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
|
5315 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
|
5316 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
|
5317 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
|
5318 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
|
5319 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
|
5320 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
|
5321 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
|
5322 return rc; |
650
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 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5326 * 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
|
5327 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5328 * 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
|
5329 * column: Zero based column. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5330 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5331 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
|
5332 { |
882
1e7b7f870d88
Experimental change to use a single column for holding the filename and icon on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
881
diff
changeset
|
5333 return dw_container_get_column_type(handle, column+1); |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5334 } |
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 * 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
|
5338 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5339 * 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
|
5340 * 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
|
5341 * width: Width of column in pixels. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5342 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5343 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
|
5344 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
5345 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
|
5346 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
|
5347 DWContainer *cont = handle; |
831
168b9db65825
Minor fix for dw_container_column_set_width() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
829
diff
changeset
|
5348 if([cont filesystem]) |
168b9db65825
Minor fix for dw_container_column_set_width() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
829
diff
changeset
|
5349 { |
168b9db65825
Minor fix for dw_container_column_set_width() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
829
diff
changeset
|
5350 column++; |
168b9db65825
Minor fix for dw_container_column_set_width() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
829
diff
changeset
|
5351 } |
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
|
5352 NSTableColumn *col = [cont getColumn:column]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
5353 |
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
|
5354 [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
|
5355 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5356 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5357 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5358 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5359 * 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
|
5360 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5361 * 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
|
5362 * 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
|
5363 * title: String title of the item. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5364 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5365 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
|
5366 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
5367 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
|
5368 DW_MUTEX_LOCK; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5369 DWContainer *cont = pointer; |
821
00fa951abeb5
Fix for dw_container_set_row_title() misbehavior on Mac and implemented dw_container_change_row_title().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
813
diff
changeset
|
5370 int lastadd = [cont lastAddPoint]; |
00fa951abeb5
Fix for dw_container_set_row_title() misbehavior on Mac and implemented dw_container_change_row_title().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
813
diff
changeset
|
5371 [cont setRow:(row+lastadd) title:title]; |
00fa951abeb5
Fix for dw_container_set_row_title() misbehavior on Mac and implemented dw_container_change_row_title().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
813
diff
changeset
|
5372 DW_MUTEX_UNLOCK; |
00fa951abeb5
Fix for dw_container_set_row_title() misbehavior on Mac and implemented dw_container_change_row_title().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
813
diff
changeset
|
5373 } |
00fa951abeb5
Fix for dw_container_set_row_title() misbehavior on Mac and implemented dw_container_change_row_title().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
813
diff
changeset
|
5374 |
00fa951abeb5
Fix for dw_container_set_row_title() misbehavior on Mac and implemented dw_container_change_row_title().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
813
diff
changeset
|
5375 |
00fa951abeb5
Fix for dw_container_set_row_title() misbehavior on Mac and implemented dw_container_change_row_title().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
813
diff
changeset
|
5376 /* |
00fa951abeb5
Fix for dw_container_set_row_title() misbehavior on Mac and implemented dw_container_change_row_title().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
813
diff
changeset
|
5377 * Sets the title of a row in the container. |
00fa951abeb5
Fix for dw_container_set_row_title() misbehavior on Mac and implemented dw_container_change_row_title().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
813
diff
changeset
|
5378 * Parameters: |
00fa951abeb5
Fix for dw_container_set_row_title() misbehavior on Mac and implemented dw_container_change_row_title().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
813
diff
changeset
|
5379 * handle: Handle to window (widget) of container. |
00fa951abeb5
Fix for dw_container_set_row_title() misbehavior on Mac and implemented dw_container_change_row_title().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
813
diff
changeset
|
5380 * row: Zero based row of data being set. |
00fa951abeb5
Fix for dw_container_set_row_title() misbehavior on Mac and implemented dw_container_change_row_title().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
813
diff
changeset
|
5381 * title: String title of the item. |
00fa951abeb5
Fix for dw_container_set_row_title() misbehavior on Mac and implemented dw_container_change_row_title().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
813
diff
changeset
|
5382 */ |
00fa951abeb5
Fix for dw_container_set_row_title() misbehavior on Mac and implemented dw_container_change_row_title().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
813
diff
changeset
|
5383 void API dw_container_change_row_title(HWND handle, int row, char *title) |
00fa951abeb5
Fix for dw_container_set_row_title() misbehavior on Mac and implemented dw_container_change_row_title().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
813
diff
changeset
|
5384 { |
00fa951abeb5
Fix for dw_container_set_row_title() misbehavior on Mac and implemented dw_container_change_row_title().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
813
diff
changeset
|
5385 int _locked_by_me = FALSE; |
00fa951abeb5
Fix for dw_container_set_row_title() misbehavior on Mac and implemented dw_container_change_row_title().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
813
diff
changeset
|
5386 DW_MUTEX_LOCK; |
00fa951abeb5
Fix for dw_container_set_row_title() misbehavior on Mac and implemented dw_container_change_row_title().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
813
diff
changeset
|
5387 DWContainer *cont = handle; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5388 [cont setRow:row title:title]; |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
5389 DW_MUTEX_UNLOCK; |
650
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 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5393 * 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
|
5394 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5395 * 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
|
5396 * 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
|
5397 * 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
|
5398 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5399 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
|
5400 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
5401 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
|
5402 DW_MUTEX_LOCK; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5403 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
|
5404 [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
|
5405 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5406 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5407 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5408 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5409 * Removes all rows from a container. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5410 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5411 * 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
|
5412 * 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
|
5413 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5414 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
|
5415 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
5416 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
|
5417 DW_MUTEX_LOCK; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5418 DWContainer *cont = handle; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5419 [cont clear]; |
670
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
5420 if(redraw) |
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
5421 { |
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
5422 [cont reloadData]; |
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
5423 } |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
5424 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5425 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5426 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5427 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5428 * 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
|
5429 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5430 * 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
|
5431 * 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
|
5432 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5433 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
|
5434 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
5435 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
|
5436 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
|
5437 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
|
5438 int x; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
5439 |
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
|
5440 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
|
5441 { |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
5442 [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
|
5443 } |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
5444 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5445 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5446 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5447 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5448 * Scrolls container up or down. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5449 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5450 * 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
|
5451 * 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
|
5452 * 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
|
5453 * 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
|
5454 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5455 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
|
5456 { |
837
89d4bad9c96e
Initial attempt at implementing the scrollbox on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
831
diff
changeset
|
5457 DWContainer *cont = handle; |
89d4bad9c96e
Initial attempt at implementing the scrollbox on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
831
diff
changeset
|
5458 NSScrollView *sv = [cont scrollview]; |
852
bb582f89007a
Implemented dw_container_scroll() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
851
diff
changeset
|
5459 NSScroller *scrollbar = [sv verticalScroller]; |
855
0103a8751ab4
Removed an unnecessary method in the container (rowCount) and implemented container column alignment.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
854
diff
changeset
|
5460 int rowcount = (int)[cont numberOfRowsInTableView:cont]; |
852
bb582f89007a
Implemented dw_container_scroll() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
851
diff
changeset
|
5461 float currpos = [scrollbar floatValue]; |
853
c27ce204302b
Add safety check to avoid potential divide by zero.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
852
diff
changeset
|
5462 float change; |
c27ce204302b
Add safety check to avoid potential divide by zero.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
852
diff
changeset
|
5463 |
c27ce204302b
Add safety check to avoid potential divide by zero.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
852
diff
changeset
|
5464 /* Safety check */ |
c27ce204302b
Add safety check to avoid potential divide by zero.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
852
diff
changeset
|
5465 if(rowcount < 1) |
c27ce204302b
Add safety check to avoid potential divide by zero.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
852
diff
changeset
|
5466 { |
c27ce204302b
Add safety check to avoid potential divide by zero.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
852
diff
changeset
|
5467 return; |
c27ce204302b
Add safety check to avoid potential divide by zero.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
852
diff
changeset
|
5468 } |
c27ce204302b
Add safety check to avoid potential divide by zero.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
852
diff
changeset
|
5469 |
c27ce204302b
Add safety check to avoid potential divide by zero.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
852
diff
changeset
|
5470 change = (float)rows/(float)rowcount; |
852
bb582f89007a
Implemented dw_container_scroll() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
851
diff
changeset
|
5471 |
bb582f89007a
Implemented dw_container_scroll() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
851
diff
changeset
|
5472 switch(direction) |
bb582f89007a
Implemented dw_container_scroll() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
851
diff
changeset
|
5473 { |
bb582f89007a
Implemented dw_container_scroll() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
851
diff
changeset
|
5474 case DW_SCROLL_TOP: |
bb582f89007a
Implemented dw_container_scroll() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
851
diff
changeset
|
5475 { |
bb582f89007a
Implemented dw_container_scroll() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
851
diff
changeset
|
5476 [scrollbar setFloatValue:0]; |
bb582f89007a
Implemented dw_container_scroll() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
851
diff
changeset
|
5477 break; |
bb582f89007a
Implemented dw_container_scroll() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
851
diff
changeset
|
5478 } |
bb582f89007a
Implemented dw_container_scroll() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
851
diff
changeset
|
5479 case DW_SCROLL_BOTTOM: |
bb582f89007a
Implemented dw_container_scroll() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
851
diff
changeset
|
5480 { |
bb582f89007a
Implemented dw_container_scroll() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
851
diff
changeset
|
5481 [scrollbar setFloatValue:1]; |
bb582f89007a
Implemented dw_container_scroll() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
851
diff
changeset
|
5482 break; |
bb582f89007a
Implemented dw_container_scroll() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
851
diff
changeset
|
5483 } |
bb582f89007a
Implemented dw_container_scroll() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
851
diff
changeset
|
5484 case DW_SCROLL_UP: |
bb582f89007a
Implemented dw_container_scroll() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
851
diff
changeset
|
5485 { |
bb582f89007a
Implemented dw_container_scroll() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
851
diff
changeset
|
5486 float newpos = currpos - change; |
bb582f89007a
Implemented dw_container_scroll() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
851
diff
changeset
|
5487 if(newpos < 0) |
bb582f89007a
Implemented dw_container_scroll() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
851
diff
changeset
|
5488 { |
bb582f89007a
Implemented dw_container_scroll() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
851
diff
changeset
|
5489 newpos = 0; |
bb582f89007a
Implemented dw_container_scroll() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
851
diff
changeset
|
5490 } |
bb582f89007a
Implemented dw_container_scroll() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
851
diff
changeset
|
5491 [scrollbar setFloatValue:newpos]; |
bb582f89007a
Implemented dw_container_scroll() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
851
diff
changeset
|
5492 break; |
bb582f89007a
Implemented dw_container_scroll() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
851
diff
changeset
|
5493 } |
bb582f89007a
Implemented dw_container_scroll() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
851
diff
changeset
|
5494 case DW_SCROLL_DOWN: |
bb582f89007a
Implemented dw_container_scroll() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
851
diff
changeset
|
5495 { |
bb582f89007a
Implemented dw_container_scroll() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
851
diff
changeset
|
5496 float newpos = currpos + change; |
bb582f89007a
Implemented dw_container_scroll() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
851
diff
changeset
|
5497 if(newpos > 1) |
bb582f89007a
Implemented dw_container_scroll() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
851
diff
changeset
|
5498 { |
bb582f89007a
Implemented dw_container_scroll() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
851
diff
changeset
|
5499 newpos = 1; |
bb582f89007a
Implemented dw_container_scroll() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
851
diff
changeset
|
5500 } |
bb582f89007a
Implemented dw_container_scroll() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
851
diff
changeset
|
5501 [scrollbar setFloatValue:newpos]; |
bb582f89007a
Implemented dw_container_scroll() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
851
diff
changeset
|
5502 break; |
bb582f89007a
Implemented dw_container_scroll() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
851
diff
changeset
|
5503 } |
bb582f89007a
Implemented dw_container_scroll() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
851
diff
changeset
|
5504 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5505 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5506 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5507 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5508 * 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
|
5509 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5510 * 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
|
5511 * 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
|
5512 * 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
|
5513 * 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
|
5514 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5515 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
|
5516 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
5517 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
|
5518 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
|
5519 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
|
5520 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
|
5521 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
|
5522 char *retval = NULL; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
5523 |
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
|
5524 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
|
5525 { |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
5526 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
|
5527 [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
|
5528 } |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
5529 DW_MUTEX_UNLOCK; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5530 return retval; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5531 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5532 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5533 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5534 * 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
|
5535 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5536 * 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
|
5537 * 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
|
5538 * 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
|
5539 * 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
|
5540 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5541 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
|
5542 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
5543 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
|
5544 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
|
5545 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
|
5546 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
|
5547 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
|
5548 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
|
5549 char *retval = NULL; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
5550 |
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
|
5551 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
|
5552 { |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
5553 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
|
5554 [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
|
5555 } |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
5556 DW_MUTEX_UNLOCK; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5557 return retval; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5558 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5559 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5560 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5561 * 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
|
5562 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5563 * 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
|
5564 * 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
|
5565 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5566 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
|
5567 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
5568 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
|
5569 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
|
5570 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
|
5571 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
|
5572 int x, count = (int)[cont numberOfRowsInTableView:cont]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
5573 |
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
|
5574 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
|
5575 { |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
5576 thistext = [cont getRowTitle:x]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
5577 |
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
|
5578 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
|
5579 { |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
5580 NSIndexSet *selected = [[NSIndexSet alloc] initWithIndex:(NSUInteger)x]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
5581 |
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
|
5582 [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
|
5583 [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
|
5584 } |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
5585 } |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
5586 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5587 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5588 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5589 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5590 * 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
|
5591 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5592 * handle: Handle to the window (widget). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5593 * 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
|
5594 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5595 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
|
5596 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
5597 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
|
5598 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
|
5599 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
|
5600 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
|
5601 int x, count = (int)[cont numberOfRowsInTableView:cont]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
5602 |
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
|
5603 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
|
5604 { |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
5605 thistext = [cont getRowTitle:x]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
5606 |
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
|
5607 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
|
5608 { |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
5609 [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
|
5610 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
|
5611 } |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
5612 } |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
5613 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5614 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5615 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5616 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5617 * 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
|
5618 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5619 * 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
|
5620 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5621 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
|
5622 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
5623 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
|
5624 DW_MUTEX_LOCK; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5625 DWContainer *cont = handle; |
856
9dc45928a75f
Added method to do column optimizations like on other platforms. Figure out the maximum width for a column and sizing to that.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
855
diff
changeset
|
5626 [cont optimize]; |
857
718b91ac19d2
Disable auto-sizing... I had enabled this during optimize because it produces some nice results....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
856
diff
changeset
|
5627 #if 0 |
856
9dc45928a75f
Added method to do column optimizations like on other platforms. Figure out the maximum width for a column and sizing to that.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
855
diff
changeset
|
5628 /* All resizable columns should expand */ |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5629 [cont setColumnAutoresizingStyle:NSTableViewUniformColumnAutoresizingStyle]; |
857
718b91ac19d2
Disable auto-sizing... I had enabled this during optimize because it produces some nice results....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
856
diff
changeset
|
5630 #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
|
5631 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5632 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5633 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5634 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5635 * Inserts an icon into the taskbar. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5636 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5637 * 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
|
5638 * 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
|
5639 * 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
|
5640 */ |
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
|
5641 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
|
5642 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5643 NSLog(@"dw_taskbar_insert() unimplemented\n"); |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5644 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5645 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5646 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5647 * Deletes an icon from the taskbar. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5648 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5649 * 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
|
5650 * 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
|
5651 */ |
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
|
5652 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
|
5653 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5654 NSLog(@"dw_taskbar_delete() unimplemented\n"); |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5655 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5656 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5657 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5658 * 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
|
5659 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5660 * 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
|
5661 * 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
|
5662 * 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
|
5663 * to an embedded XPM. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5664 */ |
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
|
5665 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
|
5666 { |
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
|
5667 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
|
5668 NSString *respath = [bundle resourcePath]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
5669 NSString *filepath = [respath stringByAppendingFormat:@"/%u.png", resid]; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5670 NSImage *image = [[NSImage alloc] initWithContentsOfFile:filepath]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5671 return image; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5672 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5673 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5674 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5675 * Obtains an icon from a file. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5676 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5677 * 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
|
5678 * DW pick the appropriate file extension. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5679 * (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
|
5680 */ |
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
|
5681 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
|
5682 { |
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
|
5683 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
|
5684 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
|
5685 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
|
5686 { |
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
|
5687 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
|
5688 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
|
5689 } |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5690 return image; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5691 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5692 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5693 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5694 * Obtains an icon from data |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5695 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5696 * 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
|
5697 * DW pick the appropriate file extension. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5698 * (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
|
5699 */ |
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
|
5700 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
|
5701 { |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
5702 NSData *thisdata = [NSData dataWithBytes:data length:len]; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5703 NSImage *image = [[NSImage alloc] initWithData:thisdata]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5704 return image; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5705 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5706 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5707 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5708 * 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
|
5709 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5710 * 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
|
5711 */ |
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
|
5712 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
|
5713 { |
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
|
5714 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
|
5715 [image release]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5716 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5717 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5718 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5719 * 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
|
5720 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5721 * 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
|
5722 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
5723 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
|
5724 { |
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
|
5725 /* 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
|
5726 * 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
|
5727 * when the application is deactivated to simulate |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
5728 * 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
|
5729 */ |
014b02436c1f
Added MDI simulation code... the MDI "window" will just be a box for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
683
diff
changeset
|
5730 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
|
5731 /* [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
|
5732 return mdi; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5733 } |
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 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5736 * 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
|
5737 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5738 * 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
|
5739 * 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
|
5740 * 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
|
5741 * Returns: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5742 * 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
|
5743 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
5744 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
|
5745 { |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
5746 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
|
5747 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
|
5748 DW_MUTEX_LOCK; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5749 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
|
5750 [split setDelegate:split]; |
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
5751 dw_box_pack_start(tmpbox, topleft, 0, 0, TRUE, TRUE, 0); |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5752 [split addSubview:tmpbox]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
5753 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
|
5754 dw_box_pack_start(tmpbox, bottomright, 0, 0, TRUE, TRUE, 0); |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5755 [split addSubview:tmpbox]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5756 if(type == DW_VERT) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5757 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5758 [split setVertical:NO]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5759 } |
668
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
5760 else |
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
5761 { |
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
5762 [split setVertical:YES]; |
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
5763 } |
753
590eebc9b61f
Preset the splitbar percent to 50% since Leopard doesn't set it automatically.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
752
diff
changeset
|
5764 /* Set the default percent to 50% split */ |
590eebc9b61f
Preset the splitbar percent to 50% since Leopard doesn't set it automatically.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
752
diff
changeset
|
5765 [split setPercent:50.0]; |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
5766 /* [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
|
5767 DW_MUTEX_UNLOCK; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5768 return split; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5769 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5770 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5771 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5772 * 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
|
5773 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5774 * 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
|
5775 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5776 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
|
5777 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5778 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
|
5779 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
|
5780 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
|
5781 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
|
5782 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
|
5783 /* 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
|
5784 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
|
5785 { |
677
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
5786 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
|
5787 } |
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
5788 else |
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
5789 { |
676
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
5790 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
|
5791 } |
677
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
5792 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
|
5793 { |
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
5794 [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
|
5795 } |
676
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
5796 else |
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
5797 { |
677
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
5798 /* 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
|
5799 * 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
|
5800 * 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
|
5801 */ |
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
5802 [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
|
5803 } |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
5804 DW_MUTEX_UNLOCK; |
650
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 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5808 * 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
|
5809 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5810 * 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
|
5811 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5812 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
|
5813 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5814 DWSplitBar *split = handle; |
676
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
5815 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
|
5816 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
|
5817 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
|
5818 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
|
5819 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
|
5820 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
|
5821 { |
677
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
5822 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
|
5823 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
|
5824 } |
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
5825 else |
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
5826 { |
677
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
5827 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
|
5828 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
|
5829 } |
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
5830 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
|
5831 { |
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
5832 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
|
5833 } |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5834 return retval; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5835 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5836 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5837 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5838 * 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
|
5839 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5840 * 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
|
5841 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
5842 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
|
5843 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
5844 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
|
5845 DW_MUTEX_LOCK; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5846 NSImageView *bitmap = [[NSImageView alloc] init]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5847 [bitmap setImageFrameStyle:NSImageFrameNone]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5848 [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
|
5849 [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
|
5850 DW_MUTEX_UNLOCK; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5851 return bitmap; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5852 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5853 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5854 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5855 * Creates a pixmap with given parameters. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5856 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5857 * 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
|
5858 * 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
|
5859 * 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
|
5860 * depth: Color depth of the pixmap. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5861 * Returns: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5862 * 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
|
5863 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5864 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
|
5865 { |
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
|
5866 HPIXMAP pixmap; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
5867 |
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
|
5868 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
|
5869 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
|
5870 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
|
5871 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
|
5872 pixmap->handle = handle; |
909
c092eab43ae3
Experimental change to pixmap rendering. Switch from using NSImage to NSBitmapImageRef to store the image.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
902
diff
changeset
|
5873 id image = pixmap->image = [[NSBitmapImageRep alloc] |
c092eab43ae3
Experimental change to pixmap rendering. Switch from using NSImage to NSBitmapImageRef to store the image.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
902
diff
changeset
|
5874 initWithBitmapDataPlanes:NULL |
c092eab43ae3
Experimental change to pixmap rendering. Switch from using NSImage to NSBitmapImageRef to store the image.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
902
diff
changeset
|
5875 pixelsWide:width |
c092eab43ae3
Experimental change to pixmap rendering. Switch from using NSImage to NSBitmapImageRef to store the image.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
902
diff
changeset
|
5876 pixelsHigh:height |
c092eab43ae3
Experimental change to pixmap rendering. Switch from using NSImage to NSBitmapImageRef to store the image.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
902
diff
changeset
|
5877 bitsPerSample:8 |
c092eab43ae3
Experimental change to pixmap rendering. Switch from using NSImage to NSBitmapImageRef to store the image.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
902
diff
changeset
|
5878 samplesPerPixel:4 |
c092eab43ae3
Experimental change to pixmap rendering. Switch from using NSImage to NSBitmapImageRef to store the image.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
902
diff
changeset
|
5879 hasAlpha:YES |
c092eab43ae3
Experimental change to pixmap rendering. Switch from using NSImage to NSBitmapImageRef to store the image.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
902
diff
changeset
|
5880 isPlanar:NO |
911
1ac9669caf86
Pick a better colorspace for new pixmaps.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
910
diff
changeset
|
5881 colorSpaceName:NSDeviceRGBColorSpace |
909
c092eab43ae3
Experimental change to pixmap rendering. Switch from using NSImage to NSBitmapImageRef to store the image.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
902
diff
changeset
|
5882 bytesPerRow:0 |
c092eab43ae3
Experimental change to pixmap rendering. Switch from using NSImage to NSBitmapImageRef to store the image.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
902
diff
changeset
|
5883 bitsPerPixel: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
|
5884 return pixmap; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5885 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5886 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5887 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5888 * Creates a pixmap from a file. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5889 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5890 * 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
|
5891 * 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
|
5892 * DW pick the appropriate file extension. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5893 * (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
|
5894 * Returns: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5895 * 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
|
5896 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5897 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
|
5898 { |
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
|
5899 HPIXMAP pixmap; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
5900 |
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
|
5901 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
|
5902 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
|
5903 NSString *nstr = [ NSString stringWithUTF8String:filename ]; |
909
c092eab43ae3
Experimental change to pixmap rendering. Switch from using NSImage to NSBitmapImageRef to store the image.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
902
diff
changeset
|
5904 NSBitmapImageRep *image = [[NSBitmapImageRep alloc] initWithContentsOfFile:nstr]; |
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
|
5905 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
|
5906 { |
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
|
5907 nstr = [nstr stringByAppendingString:@".png"]; |
909
c092eab43ae3
Experimental change to pixmap rendering. Switch from using NSImage to NSBitmapImageRef to store the image.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
902
diff
changeset
|
5908 image = [[NSBitmapImageRep alloc] initWithContentsOfFile:nstr]; |
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
|
5909 } |
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
|
5910 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
|
5911 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
|
5912 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
|
5913 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
|
5914 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
|
5915 return pixmap; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5916 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5917 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5918 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5919 * Creates a pixmap from memory. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5920 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5921 * 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
|
5922 * data: Source of the image data |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5923 * (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
|
5924 * le: length of data |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5925 * Returns: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5926 * 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
|
5927 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5928 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
|
5929 { |
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
|
5930 HPIXMAP pixmap; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
5931 |
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
|
5932 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
|
5933 return NULL; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
5934 NSData *thisdata = [NSData dataWithBytes:data length:len]; |
909
c092eab43ae3
Experimental change to pixmap rendering. Switch from using NSImage to NSBitmapImageRef to store the image.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
902
diff
changeset
|
5935 NSBitmapImageRep *image = [[NSBitmapImageRep alloc] initWithData:thisdata]; |
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
|
5936 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
|
5937 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
|
5938 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
|
5939 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
|
5940 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
|
5941 return pixmap; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5942 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5943 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5944 /* |
890
5a96cc2695b9
Removed dw_pixmap_set_transparent_color() from unimplemented on the Mac since it is handled automaticaly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
888
diff
changeset
|
5945 * Sets the transparent color for a pixmap |
5a96cc2695b9
Removed dw_pixmap_set_transparent_color() from unimplemented on the Mac since it is handled automaticaly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
888
diff
changeset
|
5946 * Parameters: |
5a96cc2695b9
Removed dw_pixmap_set_transparent_color() from unimplemented on the Mac since it is handled automaticaly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
888
diff
changeset
|
5947 * pixmap: Handle to a pixmap returned by |
5a96cc2695b9
Removed dw_pixmap_set_transparent_color() from unimplemented on the Mac since it is handled automaticaly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
888
diff
changeset
|
5948 * dw_pixmap_new.. |
5a96cc2695b9
Removed dw_pixmap_set_transparent_color() from unimplemented on the Mac since it is handled automaticaly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
888
diff
changeset
|
5949 * color: transparent color |
5a96cc2695b9
Removed dw_pixmap_set_transparent_color() from unimplemented on the Mac since it is handled automaticaly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
888
diff
changeset
|
5950 * Note: This does nothing on Mac as transparency |
5a96cc2695b9
Removed dw_pixmap_set_transparent_color() from unimplemented on the Mac since it is handled automaticaly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
888
diff
changeset
|
5951 * is handled automatically |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5952 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5953 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
|
5954 { |
890
5a96cc2695b9
Removed dw_pixmap_set_transparent_color() from unimplemented on the Mac since it is handled automaticaly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
888
diff
changeset
|
5955 /* Don't do anything */ |
650
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 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5959 * 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
|
5960 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5961 * 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
|
5962 * 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
|
5963 * Returns: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5964 * 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
|
5965 */ |
670
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
5966 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
|
5967 { |
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
|
5968 HPIXMAP pixmap; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
5969 |
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
|
5970 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
|
5971 return NULL; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
5972 |
670
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
5973 NSBundle *bundle = [NSBundle mainBundle]; |
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
5974 NSString *respath = [bundle resourcePath]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
5975 NSString *filepath = [respath stringByAppendingFormat:@"/%u.png", resid]; |
909
c092eab43ae3
Experimental change to pixmap rendering. Switch from using NSImage to NSBitmapImageRef to store the image.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
902
diff
changeset
|
5976 NSBitmapImageRep *image = [[NSBitmapImageRep alloc] initWithContentsOfFile:filepath]; |
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
|
5977 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
|
5978 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
|
5979 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
|
5980 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
|
5981 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
|
5982 return pixmap; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5983 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5984 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5985 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5986 * Destroys an allocated pixmap. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5987 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5988 * 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
|
5989 * dw_pixmap_new.. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5990 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5991 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
|
5992 { |
909
c092eab43ae3
Experimental change to pixmap rendering. Switch from using NSImage to NSBitmapImageRef to store the image.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
902
diff
changeset
|
5993 NSBitmapImageRep *image = (NSBitmapImageRep *)pixmap->image; |
918
6b400a0f5f70
Revering the dw_pixmap_destroy() dealloc/release change on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
917
diff
changeset
|
5994 [image release]; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
5995 free(pixmap); |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5996 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5997 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5998 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5999 * Copies from one item to another. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6000 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6001 * dest: Destination window handle. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6002 * destp: Destination pixmap. (choose only one). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6003 * xdest: X coordinate of destination. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6004 * ydest: Y coordinate of destination. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6005 * width: Width of area to copy. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6006 * height: Height of area to copy. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6007 * src: Source window handle. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6008 * srcp: Source pixmap. (choose only one). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6009 * xsrc: X coordinate of source. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6010 * ysrc: Y coordinate of source. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6011 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6012 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
|
6013 { |
699
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
6014 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
|
6015 NSValue* bi = [NSValue valueWithPointer:bltinfo]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
6016 |
699
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
6017 /* 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
|
6018 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
|
6019 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
|
6020 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
|
6021 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
|
6022 bltinfo->width = width; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
6023 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
|
6024 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
|
6025 bltinfo->ysrc = ysrc; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
6026 |
699
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
6027 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
|
6028 { |
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
|
6029 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
|
6030 } |
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
6031 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
|
6032 { |
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
|
6033 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
|
6034 [object retain]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
6035 } |
699
b79300831495
Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
698
diff
changeset
|
6036 [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
|
6037 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6038 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6039 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6040 * 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
|
6041 * Not available under OS/2, eCS |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6042 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6043 * 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
|
6044 * 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
|
6045 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
6046 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
|
6047 { |
729
6712e4211522
Switched to graphical calendar control style... and fixed date querying code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
728
diff
changeset
|
6048 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
|
6049 [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
|
6050 [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
|
6051 [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
|
6052 [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
|
6053 return calendar; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6054 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6055 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6056 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6057 * 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
|
6058 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6059 * 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
|
6060 * year... |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6061 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6062 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
|
6063 { |
729
6712e4211522
Switched to graphical calendar control style... and fixed date querying code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
728
diff
changeset
|
6064 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
|
6065 NSDate *date; |
6712e4211522
Switched to graphical calendar control style... and fixed date querying code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
728
diff
changeset
|
6066 char buffer[100]; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
6067 |
729
6712e4211522
Switched to graphical calendar control style... and fixed date querying code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
728
diff
changeset
|
6068 sprintf(buffer, "%04d-%02d-%02d 00:00:00 +0600", year, month, day); |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
6069 |
729
6712e4211522
Switched to graphical calendar control style... and fixed date querying code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
728
diff
changeset
|
6070 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
|
6071 [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
|
6072 [date release]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6073 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6074 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6075 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6076 * 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
|
6077 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6078 * 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
|
6079 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6080 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
|
6081 { |
729
6712e4211522
Switched to graphical calendar control style... and fixed date querying code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
728
diff
changeset
|
6082 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
|
6083 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
|
6084 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
|
6085 [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
|
6086 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
|
6087 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
|
6088 if(*year < 70) |
d3fb3613726a
Calendar control should return years with 4 digits not 2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
729
diff
changeset
|
6089 { |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
6090 *year += 2000; |
730
d3fb3613726a
Calendar control should return years with 4 digits not 2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
729
diff
changeset
|
6091 } |
d3fb3613726a
Calendar control should return years with 4 digits not 2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
729
diff
changeset
|
6092 else if(*year < 100) |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
6093 { |
730
d3fb3613726a
Calendar control should return years with 4 digits not 2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
729
diff
changeset
|
6094 *year += 1900; |
d3fb3613726a
Calendar control should return years with 4 digits not 2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
729
diff
changeset
|
6095 } |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
6096 [df release]; |
650
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 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6099 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6100 * 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
|
6101 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6102 * handle: Handle to the window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6103 * 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
|
6104 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6105 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
|
6106 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6107 WebView *html = handle; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6108 switch(action) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6109 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6110 case DW_HTML_GOBACK: |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6111 [html goBack]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6112 break; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6113 case DW_HTML_GOFORWARD: |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6114 [html goForward]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6115 break; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6116 case DW_HTML_GOHOME: |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6117 break; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6118 case DW_HTML_SEARCH: |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6119 break; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6120 case DW_HTML_RELOAD: |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6121 [html reload:html]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6122 break; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6123 case DW_HTML_STOP: |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6124 [html stopLoading:html]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6125 break; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6126 case DW_HTML_PRINT: |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6127 break; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6128 } |
650
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 |
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 * 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
|
6133 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6134 * handle: Handle to the window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6135 * 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
|
6136 * be rendered. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6137 * Returns: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6138 * 0 on success. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6139 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6140 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
|
6141 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6142 WebView *html = handle; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6143 [[html mainFrame] loadHTMLString:[ NSString stringWithUTF8String:string ] baseURL:nil]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6144 return 0; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6145 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6146 |
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 * 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
|
6149 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6150 * handle: Handle to the window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6151 * 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
|
6152 * file object to be rendered. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6153 * Returns: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6154 * 0 on success. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6155 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6156 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
|
6157 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6158 WebView *html = handle; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6159 [[html mainFrame] loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:[ NSString stringWithUTF8String:url ]]]]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6160 return 0; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6161 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6162 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6163 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6164 * 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
|
6165 * Not available under OS/2, eCS |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6166 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6167 * 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
|
6168 * 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
|
6169 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
6170 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
|
6171 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
6172 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
|
6173 DW_MUTEX_LOCK; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6174 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
|
6175 /* [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
|
6176 DW_MUTEX_UNLOCK; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6177 return web; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6178 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6179 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6180 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6181 * 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
|
6182 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6183 * 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
|
6184 * 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
|
6185 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6186 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
|
6187 { |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
6188 NSPoint mouseLoc; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6189 mouseLoc = [NSEvent mouseLocation]; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6190 if(x) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6191 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6192 *x = mouseLoc.x; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6193 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6194 if(y) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6195 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6196 *y = mouseLoc.y; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6197 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6198 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6199 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6200 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6201 * 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
|
6202 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6203 * x: X coordinate. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6204 * y: Y coordinate. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6205 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6206 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
|
6207 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6208 /* 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
|
6209 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6210 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6211 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6212 * 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
|
6213 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6214 * 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
|
6215 * resource file. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6216 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
6217 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
|
6218 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6219 NSMenu *menu = [[[NSMenu alloc] init] autorelease]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6220 [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
|
6221 /* [menu setTag:cid]; Why doesn't this work? */ |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6222 return menu; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6223 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6224 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6225 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6226 * Create a menubar on a window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6227 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6228 * 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
|
6229 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6230 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
|
6231 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6232 NSWindow *window = location; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6233 NSMenu *windowmenu = _generate_main_menu(); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6234 [[window contentView] setMenu:windowmenu]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6235 return (HMENUI)windowmenu; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6236 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6237 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6238 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6239 * 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
|
6240 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6241 * menu: Handle of a menu. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6242 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6243 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
|
6244 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6245 NSMenu *thismenu = *menu; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6246 [thismenu release]; |
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 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6249 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6250 * 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
|
6251 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6252 * 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
|
6253 * 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
|
6254 * x: X coordinate. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6255 * y: Y coordinate. |
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 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
|
6258 { |
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
|
6259 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
|
6260 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
|
6261 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
|
6262 NSWindow *window = [view window]; |
701
c91a1b345f2e
Fix for button press and context menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
700
diff
changeset
|
6263 NSEvent *event = [DWApp currentEvent]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
6264 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
|
6265 location:[window convertScreenToBase:NSMakePoint(x, y)] |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
6266 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
|
6267 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
|
6268 windowNumber:[window windowNumber] |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
6269 context:[NSGraphicsContext currentContext] |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
6270 eventNumber:1 |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
6271 clickCount:1 |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
6272 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
|
6273 [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
|
6274 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6275 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6276 char _removetilde(char *dest, char *src) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6277 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6278 int z, cur=0; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6279 char accel = '\0'; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
6280 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6281 for(z=0;z<strlen(src);z++) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6282 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6283 if(src[z] != '~') |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6284 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6285 dest[cur] = src[z]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6286 cur++; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6287 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6288 else |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6289 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6290 accel = src[z+1]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6291 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6292 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6293 dest[cur] = 0; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6294 return accel; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6295 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6296 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6297 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6298 * 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
|
6299 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6300 * 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
|
6301 * 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
|
6302 * 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
|
6303 * 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
|
6304 * 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
|
6305 * 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
|
6306 * 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
|
6307 * 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
|
6308 */ |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
6309 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
|
6310 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6311 NSMenu *menu = menux; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6312 NSMenu *submenu = submenux; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6313 NSMenuItem *item = NULL; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6314 if(strlen(title) == 0) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6315 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6316 [menu addItem:[NSMenuItem separatorItem]]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6317 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6318 else |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6319 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6320 char accel[2]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6321 char *newtitle = malloc(strlen(title)+1); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6322 NSString *nstr; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
6323 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6324 accel[0] = _removetilde(newtitle, title); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6325 accel[1] = 0; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
6326 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6327 nstr = [ NSString stringWithUTF8String:newtitle ]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6328 free(newtitle); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6329 |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6330 item = [menu addItemWithTitle: nstr |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6331 action:@selector(menuHandler:) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6332 keyEquivalent:[ NSString stringWithUTF8String:accel ]]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6333 [item setTag:itemid]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6334 if(flags & DW_MIS_CHECKED) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6335 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6336 [item setState:NSOnState]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6337 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6338 if(flags & DW_MIS_DISABLED) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6339 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6340 [item setEnabled:NO]; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
6341 } |
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
6342 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6343 if(submenux) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6344 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6345 [submenu setTitle:nstr]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6346 [menu setSubmenu:submenu forItem:item]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6347 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6348 return item; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6349 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6350 return item; |
650
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 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6354 * 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
|
6355 * 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
|
6356 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6357 * 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
|
6358 * id: Menuitem id. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6359 * 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
|
6360 */ |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
6361 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
|
6362 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6363 id menu = menux; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6364 NSMenuItem *menuitem = (NSMenuItem *)[menu itemWithTag:itemid]; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
6365 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6366 if(menuitem != nil) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6367 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6368 if(check) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6369 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6370 [menuitem setState:NSOnState]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6371 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6372 else |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
6373 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6374 [menuitem setState:NSOffState]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6375 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6376 } |
650
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 |
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 * 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
|
6381 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6382 * 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
|
6383 * id: Menuitem id. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6384 * 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
|
6385 * DW_MIS_CHECKED/DW_MIS_UNCHECKED |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6386 */ |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
6387 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
|
6388 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6389 id menu = menux; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6390 NSMenuItem *menuitem = (NSMenuItem *)[menu itemWithTag:itemid]; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
6391 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6392 if(menuitem != nil) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6393 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6394 if(state & DW_MIS_CHECKED) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6395 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6396 [menuitem setState:NSOnState]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6397 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6398 else if(state & DW_MIS_UNCHECKED) |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
6399 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6400 [menuitem setState:NSOffState]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6401 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6402 if(state & DW_MIS_ENABLED) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6403 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6404 [menuitem setEnabled:YES]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6405 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6406 else if(state & DW_MIS_DISABLED) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6407 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6408 [menuitem setEnabled:NO]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6409 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6410 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6411 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6412 |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
6413 /* 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
|
6414 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
|
6415 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6416 NSArray *pages = [notebook tabViewItems]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6417 for(DWNotebookPage *notepage in pages) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6418 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6419 if([notepage pageid] == pageid) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6420 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6421 return notepage; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6422 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6423 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6424 return nil; |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
6425 } |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
6426 |
650
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 * 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
|
6429 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6430 * 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
|
6431 * resource file. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6432 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
6433 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
|
6434 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6435 DWNotebook *notebook = [[DWNotebook alloc] init]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6436 [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
|
6437 /* [notebook setTag:cid]; Why doesn't this work? */ |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6438 return notebook; |
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 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6441 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6442 * 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
|
6443 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6444 * handle: Window (widget) handle. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6445 * flags: Any additional page creation flags. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6446 * 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
|
6447 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6448 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
|
6449 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6450 DWNotebook *notebook = handle; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6451 NSInteger page = [notebook pageid]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6452 DWNotebookPage *notepage = [[DWNotebookPage alloc] initWithIdentifier:nil]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6453 [notepage setPageid:(NSInteger)page]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6454 if(front) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6455 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6456 [notebook insertTabViewItem:notepage atIndex:(NSInteger)0]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6457 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6458 else |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6459 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6460 [notebook addTabViewItem:notepage]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6461 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6462 [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
|
6463 [notepage release]; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6464 return (unsigned long)page; |
650
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 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6468 * Remove a page from a notebook. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6469 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6470 * handle: Handle to the notebook widget. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6471 * 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
|
6472 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6473 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
|
6474 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6475 DWNotebook *notebook = handle; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6476 DWNotebookPage *notepage = _notepage_from_id(notebook, pageid); |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
6477 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6478 if(notepage != nil) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6479 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6480 [notebook removeTabViewItem:notepage]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6481 [notepage release]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6482 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6483 } |
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 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6486 * Queries the currently visible page ID. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6487 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6488 * handle: Handle to the notebook widget. |
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 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
|
6491 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6492 DWNotebook *notebook = handle; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6493 DWNotebookPage *notepage = (DWNotebookPage *)[notebook selectedTabViewItem]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6494 return [notepage pageid]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6495 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6496 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6497 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6498 * Sets the currently visibale page ID. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6499 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6500 * handle: Handle to the notebook widget. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6501 * 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
|
6502 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6503 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
|
6504 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6505 DWNotebook *notebook = handle; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6506 DWNotebookPage *notepage = _notepage_from_id(notebook, pageid); |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
6507 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6508 if(notepage != nil) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6509 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6510 [notebook selectTabViewItem:notepage]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6511 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6512 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6513 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6514 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6515 * 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
|
6516 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6517 * handle: Notebook handle. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6518 * 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
|
6519 * 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
|
6520 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6521 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
|
6522 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6523 DWNotebook *notebook = handle; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6524 DWNotebookPage *notepage = _notepage_from_id(notebook, pageid); |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
6525 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6526 if(notepage != nil) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6527 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6528 [notepage setLabel:[ NSString stringWithUTF8String:text ]]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6529 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6530 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6531 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6532 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6533 * 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
|
6534 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6535 * handle: Notebook handle. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6536 * 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
|
6537 * 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
|
6538 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6539 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
|
6540 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6541 /* Note supported here... do nothing */ |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6542 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6543 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6544 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6545 * 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
|
6546 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6547 * 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
|
6548 * 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
|
6549 * page: Box handle to be packed. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6550 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6551 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
|
6552 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6553 DWNotebook *notebook = handle; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6554 DWNotebookPage *notepage = _notepage_from_id(notebook, pageid); |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
6555 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6556 if(notepage != nil) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6557 { |
667
28727d9a835c
Fix for a rather serious notebook layout bug.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
666
diff
changeset
|
6558 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
|
6559 DWBox *box = tmpbox; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
6560 |
667
28727d9a835c
Fix for a rather serious notebook layout bug.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
666
diff
changeset
|
6561 dw_box_pack_start(tmpbox, page, 0, 0, TRUE, TRUE, 0); |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6562 [notepage setView:box]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6563 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6564 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6565 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6566 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6567 * Create a new Window Frame. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6568 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6569 * 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
|
6570 * title: The Window title. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6571 * 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
|
6572 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6573 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
|
6574 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
6575 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
|
6576 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
|
6577 NSRect frame = NSMakeRect(1,1,1,1); |
894
d1d7e5c51860
Added a DWWindow subclass to trap key events on the main window for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
891
diff
changeset
|
6578 DWWindow *window = [[DWWindow 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
|
6579 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
|
6580 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
|
6581 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
|
6582 defer:false]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6583 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6584 [window setTitle:[ NSString stringWithUTF8String:title ]]; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
6585 |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6586 DWView *view = [[DWView alloc] init]; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
6587 |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6588 [window setContentView:view]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6589 [window setDelegate:view]; |
766
82cde14ec084
Enable recalculating the key view loop (keyboard focus list) automatically.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
763
diff
changeset
|
6590 [window setAutorecalculatesKeyViewLoop:YES]; |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
6591 [view release]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
6592 |
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
|
6593 /* 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
|
6594 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
|
6595 { |
014b02436c1f
Added MDI simulation code... the MDI "window" will just be a box for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
683
diff
changeset
|
6596 id object = hwndOwner; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
6597 |
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
|
6598 /* 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
|
6599 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
|
6600 { |
014b02436c1f
Added MDI simulation code... the MDI "window" will just be a box for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
683
diff
changeset
|
6601 /* 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
|
6602 [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
|
6603 [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
|
6604 } |
014b02436c1f
Added MDI simulation code... the MDI "window" will just be a box for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
683
diff
changeset
|
6605 } |
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
|
6606 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
|
6607 return (HWND)window; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6608 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6609 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6610 /* |
651
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6611 * 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
|
6612 * Parameters: |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6613 * handle: Window handle of the widget. |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6614 * function: Function pointer to be called. |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6615 * 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
|
6616 */ |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6617 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
|
6618 { |
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
|
6619 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
|
6620 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
|
6621 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
|
6622 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
|
6623 [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
|
6624 free(params); |
651
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6625 } |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6626 |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6627 |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
6628 /* |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6629 * 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
|
6630 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6631 * 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
|
6632 * 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
|
6633 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6634 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
|
6635 { |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
6636 id object = handle; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
6637 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6638 if([ object isKindOfClass:[ NSView class ] ]) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6639 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6640 NSView *view = handle; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
6641 |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
6642 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
|
6643 { |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
6644 [view discardCursorRects]; |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
6645 } |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
6646 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
|
6647 { |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
6648 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
|
6649 NSCursor *cursor = [NSCursor arrowCursor]; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
6650 |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
6651 [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
|
6652 } |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
6653 /* 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
|
6654 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6655 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6656 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6657 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6658 * Makes the window visible. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6659 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6660 * 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
|
6661 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6662 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
|
6663 { |
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
|
6664 NSObject *object = handle; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
6665 |
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
|
6666 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
|
6667 { |
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
|
6668 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
|
6669 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
|
6670 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
|
6671 { |
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
|
6672 [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
|
6673 } |
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
|
6674 /* 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
|
6675 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
|
6676 { |
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
|
6677 /* 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
|
6678 [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
|
6679 } |
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
|
6680 [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
|
6681 [[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
|
6682 [[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
|
6683 } |
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
|
6684 return 0; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6685 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6686 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6687 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6688 * Makes the window invisible. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6689 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6690 * 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
|
6691 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6692 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
|
6693 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6694 NSObject *object = handle; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
6695 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6696 if([ object isKindOfClass:[ NSWindow class ] ]) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6697 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6698 NSWindow *window = handle; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
6699 |
733
8d5e5b89725f
Fixed the crashing issue with dw_color_choose() it now functions properly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
732
diff
changeset
|
6700 [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
|
6701 } |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6702 return 0; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6703 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6704 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6705 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6706 * 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
|
6707 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6708 * handle: The window (widget) handle. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6709 * 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
|
6710 * 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
|
6711 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6712 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
|
6713 { |
739
a0aec9a56914
Font and color improvements... including implementing dw_window_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
738
diff
changeset
|
6714 id object = handle; |
a0aec9a56914
Font and color improvements... including implementing dw_window_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
738
diff
changeset
|
6715 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
|
6716 unsigned long _back = _get_color(back); |
811
50ed3e92215b
Changes for dw_window_set_color() so it works on pretty much any control we support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
810
diff
changeset
|
6717 NSColor *fg = NULL; |
50ed3e92215b
Changes for dw_window_set_color() so it works on pretty much any control we support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
810
diff
changeset
|
6718 NSColor *bg = NULL; |
50ed3e92215b
Changes for dw_window_set_color() so it works on pretty much any control we support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
810
diff
changeset
|
6719 |
50ed3e92215b
Changes for dw_window_set_color() so it works on pretty much any control we support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
810
diff
changeset
|
6720 /* Get the NSColor for non-default colors */ |
50ed3e92215b
Changes for dw_window_set_color() so it works on pretty much any control we support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
810
diff
changeset
|
6721 if(fore != DW_CLR_DEFAULT) |
50ed3e92215b
Changes for dw_window_set_color() so it works on pretty much any control we support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
810
diff
changeset
|
6722 { |
50ed3e92215b
Changes for dw_window_set_color() so it works on pretty much any control we support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
810
diff
changeset
|
6723 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]; |
50ed3e92215b
Changes for dw_window_set_color() so it works on pretty much any control we support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
810
diff
changeset
|
6724 } |
50ed3e92215b
Changes for dw_window_set_color() so it works on pretty much any control we support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
810
diff
changeset
|
6725 if(back != DW_CLR_DEFAULT) |
50ed3e92215b
Changes for dw_window_set_color() so it works on pretty much any control we support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
810
diff
changeset
|
6726 { |
50ed3e92215b
Changes for dw_window_set_color() so it works on pretty much any control we support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
810
diff
changeset
|
6727 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]; |
50ed3e92215b
Changes for dw_window_set_color() so it works on pretty much any control we support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
810
diff
changeset
|
6728 } |
50ed3e92215b
Changes for dw_window_set_color() so it works on pretty much any control we support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
810
diff
changeset
|
6729 |
50ed3e92215b
Changes for dw_window_set_color() so it works on pretty much any control we support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
810
diff
changeset
|
6730 /* Get the textfield from the spinbutton */ |
50ed3e92215b
Changes for dw_window_set_color() so it works on pretty much any control we support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
810
diff
changeset
|
6731 if([object isMemberOfClass:[DWSpinButton class]]) |
50ed3e92215b
Changes for dw_window_set_color() so it works on pretty much any control we support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
810
diff
changeset
|
6732 { |
50ed3e92215b
Changes for dw_window_set_color() so it works on pretty much any control we support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
810
diff
changeset
|
6733 object = [object textfield]; |
50ed3e92215b
Changes for dw_window_set_color() so it works on pretty much any control we support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
810
diff
changeset
|
6734 } |
50ed3e92215b
Changes for dw_window_set_color() so it works on pretty much any control we support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
810
diff
changeset
|
6735 /* Get the cell on classes using NSCell */ |
50ed3e92215b
Changes for dw_window_set_color() so it works on pretty much any control we support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
810
diff
changeset
|
6736 if([object isKindOfClass:[NSTextField class]]) |
50ed3e92215b
Changes for dw_window_set_color() so it works on pretty much any control we support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
810
diff
changeset
|
6737 { |
50ed3e92215b
Changes for dw_window_set_color() so it works on pretty much any control we support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
810
diff
changeset
|
6738 id cell = [object cell]; |
50ed3e92215b
Changes for dw_window_set_color() so it works on pretty much any control we support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
810
diff
changeset
|
6739 |
50ed3e92215b
Changes for dw_window_set_color() so it works on pretty much any control we support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
810
diff
changeset
|
6740 if(fg) |
50ed3e92215b
Changes for dw_window_set_color() so it works on pretty much any control we support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
810
diff
changeset
|
6741 { |
50ed3e92215b
Changes for dw_window_set_color() so it works on pretty much any control we support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
810
diff
changeset
|
6742 [cell setTextColor:fg]; |
50ed3e92215b
Changes for dw_window_set_color() so it works on pretty much any control we support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
810
diff
changeset
|
6743 } |
50ed3e92215b
Changes for dw_window_set_color() so it works on pretty much any control we support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
810
diff
changeset
|
6744 } |
50ed3e92215b
Changes for dw_window_set_color() so it works on pretty much any control we support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
810
diff
changeset
|
6745 if([object isKindOfClass:[NSTextField class]] || [object isKindOfClass:[NSButton class]]) |
50ed3e92215b
Changes for dw_window_set_color() so it works on pretty much any control we support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
810
diff
changeset
|
6746 { |
50ed3e92215b
Changes for dw_window_set_color() so it works on pretty much any control we support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
810
diff
changeset
|
6747 id cell = [object cell]; |
50ed3e92215b
Changes for dw_window_set_color() so it works on pretty much any control we support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
810
diff
changeset
|
6748 |
50ed3e92215b
Changes for dw_window_set_color() so it works on pretty much any control we support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
810
diff
changeset
|
6749 if(bg) |
50ed3e92215b
Changes for dw_window_set_color() so it works on pretty much any control we support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
810
diff
changeset
|
6750 { |
50ed3e92215b
Changes for dw_window_set_color() so it works on pretty much any control we support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
810
diff
changeset
|
6751 [cell setBackgroundColor:bg]; |
50ed3e92215b
Changes for dw_window_set_color() so it works on pretty much any control we support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
810
diff
changeset
|
6752 } |
739
a0aec9a56914
Font and color improvements... including implementing dw_window_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
738
diff
changeset
|
6753 } |
a0aec9a56914
Font and color improvements... including implementing dw_window_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
738
diff
changeset
|
6754 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
|
6755 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6756 DWBox *box = object; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
6757 |
811
50ed3e92215b
Changes for dw_window_set_color() so it works on pretty much any control we support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
810
diff
changeset
|
6758 if(bg) |
50ed3e92215b
Changes for dw_window_set_color() so it works on pretty much any control we support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
810
diff
changeset
|
6759 { |
50ed3e92215b
Changes for dw_window_set_color() so it works on pretty much any control we support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
810
diff
changeset
|
6760 [box setColor:_back]; |
50ed3e92215b
Changes for dw_window_set_color() so it works on pretty much any control we support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
810
diff
changeset
|
6761 } |
739
a0aec9a56914
Font and color improvements... including implementing dw_window_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
738
diff
changeset
|
6762 } |
810
746cdd753e7a
Added coloring support for the Container/Tree/Listbox controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
809
diff
changeset
|
6763 else if([object isKindOfClass:[NSTableView class]]) |
746cdd753e7a
Added coloring support for the Container/Tree/Listbox controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
809
diff
changeset
|
6764 { |
746cdd753e7a
Added coloring support for the Container/Tree/Listbox controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
809
diff
changeset
|
6765 DWContainer *cont = handle; |
746cdd753e7a
Added coloring support for the Container/Tree/Listbox controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
809
diff
changeset
|
6766 |
811
50ed3e92215b
Changes for dw_window_set_color() so it works on pretty much any control we support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
810
diff
changeset
|
6767 if(bg) |
50ed3e92215b
Changes for dw_window_set_color() so it works on pretty much any control we support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
810
diff
changeset
|
6768 { |
50ed3e92215b
Changes for dw_window_set_color() so it works on pretty much any control we support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
810
diff
changeset
|
6769 [cont setBackgroundColor:bg]; |
50ed3e92215b
Changes for dw_window_set_color() so it works on pretty much any control we support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
810
diff
changeset
|
6770 } |
50ed3e92215b
Changes for dw_window_set_color() so it works on pretty much any control we support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
810
diff
changeset
|
6771 if(fg) |
50ed3e92215b
Changes for dw_window_set_color() so it works on pretty much any control we support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
810
diff
changeset
|
6772 { |
50ed3e92215b
Changes for dw_window_set_color() so it works on pretty much any control we support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
810
diff
changeset
|
6773 [cont setForegroundColor:fg]; |
50ed3e92215b
Changes for dw_window_set_color() so it works on pretty much any control we support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
810
diff
changeset
|
6774 } |
810
746cdd753e7a
Added coloring support for the Container/Tree/Listbox controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
809
diff
changeset
|
6775 } |
739
a0aec9a56914
Font and color improvements... including implementing dw_window_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
738
diff
changeset
|
6776 return 0; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6777 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6778 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6779 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6780 * 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
|
6781 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6782 * handle: The window (widget) handle. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6783 * 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
|
6784 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6785 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
|
6786 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6787 return 0; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6788 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6789 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6790 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6791 * 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
|
6792 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6793 * handle: Window (widget) handle. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6794 * width: New width in pixels. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6795 * height: New height in pixels. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6796 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6797 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
|
6798 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
6799 id object = handle; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
6800 |
894
d1d7e5c51860
Added a DWWindow subclass to trap key events on the main window for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
891
diff
changeset
|
6801 if(DWOSMinor > 5 && [object isMemberOfClass:[DWWindow class]]) |
d1d7e5c51860
Added a DWWindow subclass to trap key events on the main window for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
891
diff
changeset
|
6802 { |
d1d7e5c51860
Added a DWWindow subclass to trap key events on the main window for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
891
diff
changeset
|
6803 DWWindow *window = object; |
751
eba6ab48c952
Runtime Snow Leopard checks where possible and visual fix for Leopard status text.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
749
diff
changeset
|
6804 int currentstyle = (int)[window styleMask]; |
eba6ab48c952
Runtime Snow Leopard checks where possible and visual fix for Leopard status text.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
749
diff
changeset
|
6805 int tmp; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
6806 |
751
eba6ab48c952
Runtime Snow Leopard checks where possible and visual fix for Leopard status text.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
749
diff
changeset
|
6807 tmp = currentstyle | (int)mask; |
eba6ab48c952
Runtime Snow Leopard checks where possible and visual fix for Leopard status text.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
749
diff
changeset
|
6808 tmp ^= mask; |
eba6ab48c952
Runtime Snow Leopard checks where possible and visual fix for Leopard status text.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
749
diff
changeset
|
6809 tmp |= style; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
6810 |
751
eba6ab48c952
Runtime Snow Leopard checks where possible and visual fix for Leopard status text.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
749
diff
changeset
|
6811 [window setStyleMask:tmp]; |
eba6ab48c952
Runtime Snow Leopard checks where possible and visual fix for Leopard status text.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
749
diff
changeset
|
6812 } |
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
|
6813 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
|
6814 { |
bb3b2d804f0e
Working on fonts some more.... setting a default label font that is smaller.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
739
diff
changeset
|
6815 NSTextField *tf = object; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
6816 |
859
80a88c91ccf6
Implemented vertical centering on text fields.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
858
diff
changeset
|
6817 [[tf cell] setAlignment:(style & 0xF)]; |
80a88c91ccf6
Implemented vertical centering on text fields.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
858
diff
changeset
|
6818 if(style & DW_DT_VCENTER) |
80a88c91ccf6
Implemented vertical centering on text fields.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
858
diff
changeset
|
6819 { |
80a88c91ccf6
Implemented vertical centering on text fields.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
858
diff
changeset
|
6820 [[tf cell] setVCenter:YES]; |
80a88c91ccf6
Implemented vertical centering on text fields.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
858
diff
changeset
|
6821 } |
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
|
6822 } |
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
|
6823 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
|
6824 { |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
6825 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
|
6826 [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
|
6827 } |
763
2cace4e6e69a
Added DW_BS_NOBORDER style which can be set on buttons with dw_window_set_style() to make them flat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
762
diff
changeset
|
6828 else if([object isMemberOfClass:[DWButton class]]) |
2cace4e6e69a
Added DW_BS_NOBORDER style which can be set on buttons with dw_window_set_style() to make them flat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
762
diff
changeset
|
6829 { |
2cace4e6e69a
Added DW_BS_NOBORDER style which can be set on buttons with dw_window_set_style() to make them flat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
762
diff
changeset
|
6830 DWButton *button = handle; |
2cace4e6e69a
Added DW_BS_NOBORDER style which can be set on buttons with dw_window_set_style() to make them flat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
762
diff
changeset
|
6831 |
2cace4e6e69a
Added DW_BS_NOBORDER style which can be set on buttons with dw_window_set_style() to make them flat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
762
diff
changeset
|
6832 if(mask & DW_BS_NOBORDER) |
2cace4e6e69a
Added DW_BS_NOBORDER style which can be set on buttons with dw_window_set_style() to make them flat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
762
diff
changeset
|
6833 { |
2cace4e6e69a
Added DW_BS_NOBORDER style which can be set on buttons with dw_window_set_style() to make them flat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
762
diff
changeset
|
6834 if(style & DW_BS_NOBORDER) |
2cace4e6e69a
Added DW_BS_NOBORDER style which can be set on buttons with dw_window_set_style() to make them flat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
762
diff
changeset
|
6835 { |
2cace4e6e69a
Added DW_BS_NOBORDER style which can be set on buttons with dw_window_set_style() to make them flat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
762
diff
changeset
|
6836 [button setButtonType:NSMomentaryLight]; |
2cace4e6e69a
Added DW_BS_NOBORDER style which can be set on buttons with dw_window_set_style() to make them flat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
762
diff
changeset
|
6837 [button setBordered:NO]; |
2cace4e6e69a
Added DW_BS_NOBORDER style which can be set on buttons with dw_window_set_style() to make them flat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
762
diff
changeset
|
6838 } |
2cace4e6e69a
Added DW_BS_NOBORDER style which can be set on buttons with dw_window_set_style() to make them flat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
762
diff
changeset
|
6839 else |
2cace4e6e69a
Added DW_BS_NOBORDER style which can be set on buttons with dw_window_set_style() to make them flat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
762
diff
changeset
|
6840 { |
2cace4e6e69a
Added DW_BS_NOBORDER style which can be set on buttons with dw_window_set_style() to make them flat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
762
diff
changeset
|
6841 [button setButtonType:NSMomentaryPushInButton]; |
2cace4e6e69a
Added DW_BS_NOBORDER style which can be set on buttons with dw_window_set_style() to make them flat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
762
diff
changeset
|
6842 [button setBordered:YES]; |
2cace4e6e69a
Added DW_BS_NOBORDER style which can be set on buttons with dw_window_set_style() to make them flat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
762
diff
changeset
|
6843 } |
2cace4e6e69a
Added DW_BS_NOBORDER style which can be set on buttons with dw_window_set_style() to make them flat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
762
diff
changeset
|
6844 } |
2cace4e6e69a
Added DW_BS_NOBORDER style which can be set on buttons with dw_window_set_style() to make them flat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
762
diff
changeset
|
6845 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6846 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6847 |
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 * 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
|
6850 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6851 * window: Toplevel window or dialog. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6852 * 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
|
6853 */ |
766
82cde14ec084
Enable recalculating the key view loop (keyboard focus list) automatically.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
763
diff
changeset
|
6854 void API dw_window_default(HWND handle, HWND defaultitem) |
82cde14ec084
Enable recalculating the key view loop (keyboard focus list) automatically.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
763
diff
changeset
|
6855 { |
894
d1d7e5c51860
Added a DWWindow subclass to trap key events on the main window for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
891
diff
changeset
|
6856 DWWindow *window = handle; |
872
13debcad9757
Another test fix at reported crash in dw_window_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
867
diff
changeset
|
6857 id object = defaultitem; |
766
82cde14ec084
Enable recalculating the key view loop (keyboard focus list) automatically.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
763
diff
changeset
|
6858 |
872
13debcad9757
Another test fix at reported crash in dw_window_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
867
diff
changeset
|
6859 if([window isKindOfClass:[NSWindow class]] && [object isKindOfClass:[NSControl class]]) |
864
ca01c7d95b80
Added some sanity checks for a couple of problem functions and default optimized container column width to 16 for image columns.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
860
diff
changeset
|
6860 { |
ca01c7d95b80
Added some sanity checks for a couple of problem functions and default optimized container column width to 16 for image columns.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
860
diff
changeset
|
6861 [window setInitialFirstResponder:defaultitem]; |
ca01c7d95b80
Added some sanity checks for a couple of problem functions and default optimized container column width to 16 for image columns.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
860
diff
changeset
|
6862 } |
650
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 |
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 * 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
|
6867 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6868 * 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
|
6869 * 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
|
6870 */ |
768
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
6871 void API dw_window_click_default(HWND handle, HWND next) |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
6872 { |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
6873 id object = handle; |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
6874 id control = next; |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
6875 |
894
d1d7e5c51860
Added a DWWindow subclass to trap key events on the main window for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
891
diff
changeset
|
6876 if([object isMemberOfClass:[DWWindow class]]) |
792
fc6a626a96cc
Initial groupbox support. Sizing of the content frame is not quite right yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
768
diff
changeset
|
6877 { |
fc6a626a96cc
Initial groupbox support. Sizing of the content frame is not quite right yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
768
diff
changeset
|
6878 if([control isMemberOfClass:[DWButton class]]) |
fc6a626a96cc
Initial groupbox support. Sizing of the content frame is not quite right yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
768
diff
changeset
|
6879 { |
fc6a626a96cc
Initial groupbox support. Sizing of the content frame is not quite right yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
768
diff
changeset
|
6880 NSWindow *window = object; |
768
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
6881 |
792
fc6a626a96cc
Initial groupbox support. Sizing of the content frame is not quite right yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
768
diff
changeset
|
6882 [window setDefaultButtonCell:control]; |
fc6a626a96cc
Initial groupbox support. Sizing of the content frame is not quite right yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
768
diff
changeset
|
6883 } |
768
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
6884 } |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
6885 else |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
6886 { |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
6887 if([control isMemberOfClass:[DWSpinButton class]]) |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
6888 { |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
6889 control = [control textfield]; |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
6890 } |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
6891 else if([control isMemberOfClass:[DWComboBox class]]) |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
6892 { |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
6893 /* TODO: Figure out why the combobox can't be |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
6894 * focused using makeFirstResponder method. |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
6895 */ |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
6896 control = [control textfield]; |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
6897 } |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
6898 [object setClickDefault:control]; |
7a236fdcf4ba
Fixed a typo in VK_RETURN and initial implementation of dw_window_click_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
767
diff
changeset
|
6899 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6900 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6901 |
686
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
6902 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
|
6903 |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6904 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6905 * 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
|
6906 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6907 * handle: Handle to receive mouse input. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6908 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6909 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
|
6910 { |
686
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
6911 id object = handle; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
6912 |
894
d1d7e5c51860
Added a DWWindow subclass to trap key events on the main window for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
891
diff
changeset
|
6913 if(![object isMemberOfClass:[DWWindow class]]) |
686
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
6914 { |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
6915 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
|
6916 } |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
6917 if(object) |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
6918 { |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
6919 [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
|
6920 _DWCapture = object; |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
6921 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6922 } |
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 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6925 * Releases previous mouse capture. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6926 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6927 void API dw_window_release(void) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6928 { |
686
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
6929 if(_DWCapture) |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
6930 { |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
6931 [_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
|
6932 _DWCapture = nil; |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
6933 } |
650
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 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6937 * 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
|
6938 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6939 * handle: The window handle to destroy. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6940 * 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
|
6941 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6942 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
|
6943 { |
686
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
6944 id object = handle; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
6945 |
894
d1d7e5c51860
Added a DWWindow subclass to trap key events on the main window for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
891
diff
changeset
|
6946 if([object isMemberOfClass:[DWWindow class]]) |
686
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
6947 { |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
6948 /* 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
|
6949 * 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
|
6950 * 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
|
6951 */ |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
6952 NSWindow *window = handle; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
6953 |
686
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
6954 /* 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
|
6955 if(newparent) |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
6956 { |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
6957 object = newparent; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
6958 |
686
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
6959 /* 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
|
6960 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
|
6961 { |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
6962 /* 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
|
6963 [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
|
6964 [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
|
6965 return; |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
6966 } |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
6967 } |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
6968 /* 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
|
6969 [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
|
6970 [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
|
6971 } |
650
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 |
744
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
6974 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
|
6975 { |
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
6976 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
|
6977 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
|
6978 NSFont *font = nil; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
6979 |
744
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
6980 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
|
6981 { |
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
6982 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
|
6983 *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
|
6984 name++; |
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
6985 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
|
6986 } |
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
6987 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
|
6988 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
|
6989 } |
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
6990 |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6991 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6992 * 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
|
6993 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6994 * handle: The window (widget) handle. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6995 * 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
|
6996 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6997 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
|
6998 { |
744
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
6999 NSFont *font = _dw_font_by_name(fontname); |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
7000 |
744
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
7001 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
|
7002 { |
744
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
7003 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
|
7004 if([object window]) |
673
6d0f0dc7ff7c
Some minor font fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
672
diff
changeset
|
7005 { |
744
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
7006 [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
|
7007 [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
|
7008 [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
|
7009 } |
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
7010 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
|
7011 { |
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
7012 [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
|
7013 [[object cell] setFont:font]; |
673
6d0f0dc7ff7c
Some minor font fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
672
diff
changeset
|
7014 } |
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
|
7015 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
|
7016 { |
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
|
7017 DWRender *render = object; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
7018 |
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
|
7019 [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
|
7020 } |
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
|
7021 } |
bb3b2d804f0e
Working on fonts some more.... setting a default label font that is smaller.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
739
diff
changeset
|
7022 return 0; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7023 } |
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 /* |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
7026 * Returns the current font for the specified window |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
7027 * Parameters: |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
7028 * 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
|
7029 */ |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
7030 char * API dw_window_get_font(HWND handle) |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
7031 { |
739
a0aec9a56914
Font and color improvements... including implementing dw_window_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
738
diff
changeset
|
7032 id object = handle; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
7033 |
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
|
7034 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
|
7035 { |
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
|
7036 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
|
7037 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
|
7038 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
|
7039 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
|
7040 } |
a0aec9a56914
Font and color improvements... including implementing dw_window_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
738
diff
changeset
|
7041 return NULL; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
7042 } |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
7043 |
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
7044 /* |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7045 * 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
|
7046 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7047 * handle: The window handle to destroy. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7048 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7049 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
|
7050 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
7051 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
|
7052 DW_MUTEX_LOCK; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7053 NSObject *object = handle; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
7054 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7055 if([ object isKindOfClass:[ NSWindow class ] ]) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7056 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7057 NSWindow *window = handle; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7058 [window close]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7059 } |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
7060 DW_MUTEX_UNLOCK; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7061 return 0; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7062 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7063 |
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 * 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
|
7066 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7067 * handle: Handle to the window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7068 * Returns: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7069 * 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
|
7070 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7071 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
|
7072 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7073 NSObject *object = handle; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
7074 |
808
c0641a6d4258
Similar fix for dw_window_get_text().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
807
diff
changeset
|
7075 if([ object isKindOfClass:[ NSWindow class ] ] || [ object isKindOfClass:[ NSButton class ] ]) |
c0641a6d4258
Similar fix for dw_window_get_text().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
807
diff
changeset
|
7076 { |
c0641a6d4258
Similar fix for dw_window_get_text().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
807
diff
changeset
|
7077 id window = handle; |
c0641a6d4258
Similar fix for dw_window_get_text().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
807
diff
changeset
|
7078 NSString *nsstr = [ window title]; |
c0641a6d4258
Similar fix for dw_window_get_text().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
807
diff
changeset
|
7079 |
c0641a6d4258
Similar fix for dw_window_get_text().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
807
diff
changeset
|
7080 return strdup([ nsstr UTF8String ]); |
c0641a6d4258
Similar fix for dw_window_get_text().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
807
diff
changeset
|
7081 } |
c0641a6d4258
Similar fix for dw_window_get_text().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
807
diff
changeset
|
7082 else if([ object isKindOfClass:[ NSControl class ] ]) |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7083 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7084 NSControl *control = handle; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7085 NSString *nsstr = [ control stringValue]; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
7086 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7087 return strdup([ nsstr UTF8String ]); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7088 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7089 return NULL; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7090 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7091 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7092 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7093 * 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
|
7094 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7095 * handle: Handle to the window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7096 * 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
|
7097 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7098 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
|
7099 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
7100 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
|
7101 DW_MUTEX_LOCK; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7102 NSObject *object = handle; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
7103 |
807
f7016a38bedd
Fix for dw_window_set_text() on buttons not working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
806
diff
changeset
|
7104 if([ object isKindOfClass:[ NSWindow class ] ] || [ object isKindOfClass:[ NSButton class ] ]) |
f7016a38bedd
Fix for dw_window_set_text() on buttons not working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
806
diff
changeset
|
7105 { |
f7016a38bedd
Fix for dw_window_set_text() on buttons not working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
806
diff
changeset
|
7106 id window = handle; |
f7016a38bedd
Fix for dw_window_set_text() on buttons not working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
806
diff
changeset
|
7107 [window setTitle:[ NSString stringWithUTF8String:text ]]; |
f7016a38bedd
Fix for dw_window_set_text() on buttons not working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
806
diff
changeset
|
7108 } |
f7016a38bedd
Fix for dw_window_set_text() on buttons not working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
806
diff
changeset
|
7109 else if([ object isKindOfClass:[ NSControl class ] ]) |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7110 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7111 NSControl *control = handle; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7112 [control setStringValue:[ NSString stringWithUTF8String:text ]]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7113 } |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
7114 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7115 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7116 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7117 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7118 * Disables given window (widget). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7119 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7120 * handle: Handle to the window. |
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 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
|
7123 { |
800
e5a0a1a3ee03
dw_window_enable() and dw_window_disable() now function as expected on MLE controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
799
diff
changeset
|
7124 id object = handle; |
e5a0a1a3ee03
dw_window_enable() and dw_window_disable() now function as expected on MLE controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
799
diff
changeset
|
7125 |
e5a0a1a3ee03
dw_window_enable() and dw_window_disable() now function as expected on MLE controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
799
diff
changeset
|
7126 if([object isMemberOfClass:[NSScrollView class]]) |
e5a0a1a3ee03
dw_window_enable() and dw_window_disable() now function as expected on MLE controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
799
diff
changeset
|
7127 { |
e5a0a1a3ee03
dw_window_enable() and dw_window_disable() now function as expected on MLE controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
799
diff
changeset
|
7128 NSScrollView *sv = handle; |
e5a0a1a3ee03
dw_window_enable() and dw_window_disable() now function as expected on MLE controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
799
diff
changeset
|
7129 object = [sv documentView]; |
e5a0a1a3ee03
dw_window_enable() and dw_window_disable() now function as expected on MLE controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
799
diff
changeset
|
7130 } |
e5a0a1a3ee03
dw_window_enable() and dw_window_disable() now function as expected on MLE controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
799
diff
changeset
|
7131 if([object isKindOfClass:[NSControl class]]) |
e5a0a1a3ee03
dw_window_enable() and dw_window_disable() now function as expected on MLE controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
799
diff
changeset
|
7132 { |
e5a0a1a3ee03
dw_window_enable() and dw_window_disable() now function as expected on MLE controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
799
diff
changeset
|
7133 NSControl *control = object; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7134 [control setEnabled:NO]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7135 } |
800
e5a0a1a3ee03
dw_window_enable() and dw_window_disable() now function as expected on MLE controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
799
diff
changeset
|
7136 if([object isKindOfClass:[NSTextView class]]) |
e5a0a1a3ee03
dw_window_enable() and dw_window_disable() now function as expected on MLE controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
799
diff
changeset
|
7137 { |
e5a0a1a3ee03
dw_window_enable() and dw_window_disable() now function as expected on MLE controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
799
diff
changeset
|
7138 NSTextView *mle = object; |
e5a0a1a3ee03
dw_window_enable() and dw_window_disable() now function as expected on MLE controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
799
diff
changeset
|
7139 |
e5a0a1a3ee03
dw_window_enable() and dw_window_disable() now function as expected on MLE controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
799
diff
changeset
|
7140 [mle setEditable:NO]; |
e5a0a1a3ee03
dw_window_enable() and dw_window_disable() now function as expected on MLE controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
799
diff
changeset
|
7141 } |
650
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 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7144 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7145 * Enables given window (widget). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7146 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7147 * handle: Handle to the window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7148 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7149 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
|
7150 { |
800
e5a0a1a3ee03
dw_window_enable() and dw_window_disable() now function as expected on MLE controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
799
diff
changeset
|
7151 id object = handle; |
e5a0a1a3ee03
dw_window_enable() and dw_window_disable() now function as expected on MLE controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
799
diff
changeset
|
7152 |
e5a0a1a3ee03
dw_window_enable() and dw_window_disable() now function as expected on MLE controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
799
diff
changeset
|
7153 if([object isMemberOfClass:[NSScrollView class]]) |
e5a0a1a3ee03
dw_window_enable() and dw_window_disable() now function as expected on MLE controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
799
diff
changeset
|
7154 { |
e5a0a1a3ee03
dw_window_enable() and dw_window_disable() now function as expected on MLE controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
799
diff
changeset
|
7155 NSScrollView *sv = handle; |
e5a0a1a3ee03
dw_window_enable() and dw_window_disable() now function as expected on MLE controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
799
diff
changeset
|
7156 object = [sv documentView]; |
e5a0a1a3ee03
dw_window_enable() and dw_window_disable() now function as expected on MLE controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
799
diff
changeset
|
7157 } |
e5a0a1a3ee03
dw_window_enable() and dw_window_disable() now function as expected on MLE controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
799
diff
changeset
|
7158 if([object isKindOfClass:[NSControl class]]) |
e5a0a1a3ee03
dw_window_enable() and dw_window_disable() now function as expected on MLE controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
799
diff
changeset
|
7159 { |
e5a0a1a3ee03
dw_window_enable() and dw_window_disable() now function as expected on MLE controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
799
diff
changeset
|
7160 NSControl *control = object; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7161 [control setEnabled:YES]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7162 } |
800
e5a0a1a3ee03
dw_window_enable() and dw_window_disable() now function as expected on MLE controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
799
diff
changeset
|
7163 if([object isKindOfClass:[NSTextView class]]) |
e5a0a1a3ee03
dw_window_enable() and dw_window_disable() now function as expected on MLE controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
799
diff
changeset
|
7164 { |
e5a0a1a3ee03
dw_window_enable() and dw_window_disable() now function as expected on MLE controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
799
diff
changeset
|
7165 NSTextView *mle = object; |
e5a0a1a3ee03
dw_window_enable() and dw_window_disable() now function as expected on MLE controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
799
diff
changeset
|
7166 |
e5a0a1a3ee03
dw_window_enable() and dw_window_disable() now function as expected on MLE controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
799
diff
changeset
|
7167 [mle setEditable:YES]; |
e5a0a1a3ee03
dw_window_enable() and dw_window_disable() now function as expected on MLE controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
799
diff
changeset
|
7168 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7169 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7170 |
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 * 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
|
7173 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7174 * handle: Handle to the window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7175 * 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
|
7176 * (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
|
7177 * 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
|
7178 * 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
|
7179 * 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
|
7180 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
7181 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
|
7182 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7183 NSObject *object = handle; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7184 if([ object isKindOfClass:[ NSImageView class ] ]) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7185 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7186 NSImageView *iv = handle; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
7187 NSData *thisdata = [NSData dataWithBytes:data length:len]; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7188 NSImage *pixmap = [[NSImage alloc] initWithData:thisdata]; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
7189 |
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
|
7190 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
|
7191 { |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
7192 [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
|
7193 } |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
7194 [pixmap release]; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7195 } |
650
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 |
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 * 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
|
7200 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7201 * handle: Handle to the window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7202 * 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
|
7203 * (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
|
7204 * 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
|
7205 * 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
|
7206 * 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
|
7207 */ |
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
|
7208 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
|
7209 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7210 NSObject *object = handle; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7211 if([ object isKindOfClass:[ NSImageView class ] ]) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7212 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7213 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
|
7214 NSImage *bitmap = nil; |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
7215 |
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
|
7216 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
|
7217 { |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
7218 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
|
7219 } |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
7220 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
|
7221 { |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
7222 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
|
7223 } |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
7224 |
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
|
7225 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
|
7226 { |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
7227 [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
|
7228 } |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7229 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7230 } |
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 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7233 * 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
|
7234 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7235 * handle: Handle to the window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7236 * 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
|
7237 */ |
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
|
7238 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
|
7239 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7240 /* 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
|
7241 } |
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 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7244 * 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
|
7245 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7246 * handle: Handle to the parent window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7247 * id: Integer ID of the child. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7248 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
7249 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
|
7250 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7251 NSObject *object = handle; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7252 NSView *view = handle; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7253 if([ object isKindOfClass:[ NSWindow class ] ]) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7254 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7255 NSWindow *window = handle; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7256 view = [window contentView]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7257 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7258 return [view viewWithTag:cid]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7259 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7260 |
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 * 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
|
7263 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7264 * handle: The window handle to minimize. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7265 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7266 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
|
7267 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7268 NSWindow *window = handle; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7269 [window miniaturize:nil]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7270 return 0; |
650
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 /* 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
|
7274 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7275 * 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
|
7276 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7277 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
|
7278 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7279 NSWindow *window = handle; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7280 [window flushWindow]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7281 } |
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 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7284 * Makes the window topmost. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7285 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7286 * 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
|
7287 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7288 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
|
7289 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7290 NSWindow *window = handle; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7291 [window orderFront:nil]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7292 return 0; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7293 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7294 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7295 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7296 * Makes the window bottommost. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7297 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7298 * 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
|
7299 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7300 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
|
7301 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7302 NSWindow *window = handle; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7303 [window orderBack:nil]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7304 return 0; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7305 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7306 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7307 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7308 * 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
|
7309 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7310 * handle: Window (widget) handle. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7311 * width: New width in pixels. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7312 * height: New height in pixels. |
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 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
|
7315 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
7316 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
|
7317 DW_MUTEX_LOCK; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7318 NSObject *object = handle; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7319 NSSize size; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7320 size.width = width; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7321 size.height = height; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
7322 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7323 if([ object isKindOfClass:[ NSWindow class ] ]) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7324 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7325 NSWindow *window = handle; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7326 [window setContentSize:size]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7327 } |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
7328 DW_MUTEX_UNLOCK; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7329 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7330 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7331 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7332 * 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
|
7333 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7334 * handle: Window (widget) handle. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7335 * 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
|
7336 * 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
|
7337 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7338 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
|
7339 { |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
7340 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
|
7341 DW_MUTEX_LOCK; |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7342 NSObject *object = handle; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7343 NSPoint point; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7344 point.x = x; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7345 point.y = y; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
7346 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7347 if([ object isKindOfClass:[ NSWindow class ] ]) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7348 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7349 NSWindow *window = handle; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7350 [window setFrameOrigin:point]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7351 } |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
7352 DW_MUTEX_UNLOCK; |
650
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 |
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 * 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
|
7357 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7358 * handle: Window (widget) handle. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7359 * 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
|
7360 * 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
|
7361 * width: Width of the widget. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7362 * height: Height of the widget. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7363 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7364 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
|
7365 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7366 dw_window_set_pos(handle, x, y); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7367 dw_window_set_size(handle, width, height); |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7368 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7369 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7370 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7371 * 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
|
7372 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7373 * handle: Window (widget) handle. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7374 * 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
|
7375 * 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
|
7376 * width: Width of the widget. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7377 * height: Height of the widget. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7378 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7379 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
|
7380 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7381 NSObject *object = handle; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
7382 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7383 if([ object isKindOfClass:[ NSWindow class ] ]) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7384 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7385 NSWindow *window = handle; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7386 NSRect rect = [window frame]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7387 if(x) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7388 *x = rect.origin.x; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7389 if(y) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7390 *y = rect.origin.y; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7391 if(width) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7392 *width = rect.size.width; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7393 if(height) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7394 *height = rect.size.height; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7395 return; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7396 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7397 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7398 |
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 * Returns the width of the screen. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7401 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7402 int API dw_screen_width(void) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7403 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7404 NSRect screenRect = [[NSScreen mainScreen] frame]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7405 return screenRect.size.width; |
650
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 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7409 * Returns the height of the screen. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7410 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7411 int API dw_screen_height(void) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7412 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7413 NSRect screenRect = [[NSScreen mainScreen] frame]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7414 return screenRect.size.height; |
650
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 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7417 /* 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
|
7418 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
|
7419 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7420 NSWindowDepth screenDepth = [[NSScreen mainScreen] depth]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7421 return NSBitsPerPixelFromDepth(screenDepth); |
650
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 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7424 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7425 * 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
|
7426 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7427 * env: Pointer to a DWEnv struct. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7428 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7429 void dw_environment_query(DWEnv *env) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7430 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7431 struct utsname name; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
7432 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7433 uname(&name); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7434 strcpy(env->osName, "MacOS"); |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
7435 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7436 strcpy(env->buildDate, __DATE__); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7437 strcpy(env->buildTime, __TIME__); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7438 env->DWMajorVersion = DW_MAJOR_VERSION; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7439 env->DWMinorVersion = DW_MINOR_VERSION; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7440 env->DWSubVersion = DW_SUB_VERSION; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
7441 |
751
eba6ab48c952
Runtime Snow Leopard checks where possible and visual fix for Leopard status text.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
749
diff
changeset
|
7442 env->MajorVersion = DWOSMajor; |
eba6ab48c952
Runtime Snow Leopard checks where possible and visual fix for Leopard status text.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
749
diff
changeset
|
7443 env->MinorVersion = DWOSMinor; |
eba6ab48c952
Runtime Snow Leopard checks where possible and visual fix for Leopard status text.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
749
diff
changeset
|
7444 env->MajorBuild = DWOSBuild; |
809
1ef0f4c03c14
MinorBuild was being left uninitialized.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
808
diff
changeset
|
7445 env->MinorBuild = 0; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7446 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7447 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7448 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7449 * Emits a beep. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7450 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7451 * freq: Frequency. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7452 * dur: Duration. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7453 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7454 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
|
7455 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7456 NSBeep(); |
650
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 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7459 /* 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
|
7460 * anything you have drawn is visible. |
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 void API dw_flush(void) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7463 { |
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
|
7464 /* 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
|
7465 [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
|
7466 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7467 |
651
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
7468 /* 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
|
7469 * 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
|
7470 * dw_window_get_data(). |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
7471 */ |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
7472 UserData *_find_userdata(UserData **root, char *varname) |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
7473 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7474 UserData *tmp = *root; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
7475 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7476 while(tmp) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7477 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7478 if(strcasecmp(tmp->varname, varname) == 0) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7479 return tmp; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7480 tmp = tmp->next; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7481 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7482 return NULL; |
651
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
7483 } |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
7484 |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
7485 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
|
7486 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7487 UserData *new = _find_userdata(root, varname); |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
7488 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7489 if(new) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7490 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7491 new->data = data; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7492 return TRUE; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7493 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7494 else |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7495 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7496 new = malloc(sizeof(UserData)); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7497 if(new) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7498 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7499 new->varname = strdup(varname); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7500 new->data = data; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
7501 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7502 new->next = NULL; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
7503 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7504 if (!*root) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7505 *root = new; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7506 else |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7507 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7508 UserData *prev = NULL, *tmp = *root; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7509 while(tmp) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7510 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7511 prev = tmp; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7512 tmp = tmp->next; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7513 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7514 if(prev) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7515 prev->next = new; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7516 else |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7517 *root = new; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7518 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7519 return TRUE; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7520 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7521 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7522 return FALSE; |
651
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
7523 } |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
7524 |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
7525 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
|
7526 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7527 UserData *prev = NULL, *tmp = *root; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
7528 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7529 while(tmp) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7530 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7531 if(all || strcasecmp(tmp->varname, varname) == 0) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7532 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7533 if(!prev) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7534 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7535 *root = tmp->next; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7536 free(tmp->varname); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7537 free(tmp); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7538 if(!all) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7539 return 0; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7540 tmp = *root; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7541 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7542 else |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7543 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7544 /* If all is true we should |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7545 * never get here. |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7546 */ |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7547 prev->next = tmp->next; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7548 free(tmp->varname); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7549 free(tmp); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7550 return 0; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7551 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7552 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7553 else |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7554 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7555 prev = tmp; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7556 tmp = tmp->next; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7557 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7558 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7559 return 0; |
651
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
7560 } |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
7561 |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7562 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7563 * 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
|
7564 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7565 * 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
|
7566 * 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
|
7567 * 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
|
7568 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7569 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
|
7570 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7571 id object = window; |
894
d1d7e5c51860
Added a DWWindow subclass to trap key events on the main window for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
891
diff
changeset
|
7572 if([object isMemberOfClass:[DWWindow class]]) |
681
5fe12469c1fb
Fix for dw_window_set/get_data() on a top-level window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
680
diff
changeset
|
7573 { |
5fe12469c1fb
Fix for dw_window_set/get_data() on a top-level window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
680
diff
changeset
|
7574 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
|
7575 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
|
7576 } |
5fe12469c1fb
Fix for dw_window_set/get_data() on a top-level window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
680
diff
changeset
|
7577 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
|
7578 { |
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
7579 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
|
7580 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
|
7581 } |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7582 WindowData *blah = (WindowData *)[object userdata]; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
7583 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7584 if(!blah) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7585 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7586 if(!dataname) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7587 return; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
7588 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7589 blah = calloc(1, sizeof(WindowData)); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7590 [object setUserdata:blah]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7591 } |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
7592 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7593 if(data) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7594 _new_userdata(&(blah->root), dataname, data); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7595 else |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7596 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7597 if(dataname) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7598 _remove_userdata(&(blah->root), dataname, FALSE); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7599 else |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7600 _remove_userdata(&(blah->root), NULL, TRUE); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7601 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7602 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7603 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7604 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7605 * 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
|
7606 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7607 * 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
|
7608 * 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
|
7609 * 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
|
7610 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7611 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
|
7612 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7613 id object = window; |
894
d1d7e5c51860
Added a DWWindow subclass to trap key events on the main window for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
891
diff
changeset
|
7614 if([object isMemberOfClass:[DWWindow class]]) |
681
5fe12469c1fb
Fix for dw_window_set/get_data() on a top-level window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
680
diff
changeset
|
7615 { |
5fe12469c1fb
Fix for dw_window_set/get_data() on a top-level window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
680
diff
changeset
|
7616 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
|
7617 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
|
7618 } |
5fe12469c1fb
Fix for dw_window_set/get_data() on a top-level window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
680
diff
changeset
|
7619 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
|
7620 { |
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
7621 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
|
7622 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
|
7623 } |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7624 WindowData *blah = (WindowData *)[object userdata]; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
7625 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7626 if(blah && blah->root && dataname) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7627 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7628 UserData *ud = _find_userdata(&(blah->root), dataname); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7629 if(ud) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7630 return ud->data; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7631 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7632 return NULL; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7633 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7634 |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
7635 #define DW_TIMER_MAX 64 |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
7636 NSTimer *DWTimers[DW_TIMER_MAX]; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
7637 |
650
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 * 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
|
7640 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7641 * interval: Milliseconds to delay between calls. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7642 * 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
|
7643 * 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
|
7644 * Returns: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7645 * 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
|
7646 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7647 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
|
7648 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7649 int z; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
7650 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7651 for(z=0;z<DW_TIMER_MAX;z++) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7652 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7653 if(!DWTimers[z]) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7654 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7655 break; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7656 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7657 } |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
7658 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7659 if(sigfunc && !DWTimers[z]) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7660 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7661 NSTimeInterval seconds = (double)interval / 1000.0; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7662 NSTimer *thistimer = DWTimers[z] = [NSTimer scheduledTimerWithTimeInterval:seconds target:DWHandler selector:@selector(runTimer:) userInfo:nil repeats:YES]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7663 _new_signal(0, thistimer, z+1, sigfunc, data); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7664 return z+1; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7665 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7666 return 0; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7667 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7668 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7669 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7670 * Removes timer callback. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7671 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7672 * 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
|
7673 */ |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
7674 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
|
7675 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7676 SignalHandler *prev = NULL, *tmp = Root; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7677 NSTimer *thistimer; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
7678 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7679 /* 0 is an invalid timer ID */ |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7680 if(timerid < 1 || !DWTimers[timerid-1]) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7681 return; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
7682 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7683 thistimer = DWTimers[timerid-1]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7684 DWTimers[timerid-1] = nil; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
7685 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7686 [thistimer invalidate]; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
7687 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7688 while(tmp) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7689 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7690 if(tmp->id == timerid && tmp->window == thistimer) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7691 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7692 if(prev) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7693 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7694 prev->next = tmp->next; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7695 free(tmp); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7696 tmp = prev->next; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7697 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7698 else |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7699 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7700 Root = tmp->next; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7701 free(tmp); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7702 tmp = Root; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7703 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7704 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7705 else |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7706 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7707 prev = tmp; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7708 tmp = tmp->next; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7709 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7710 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7711 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7712 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7713 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7714 * 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
|
7715 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7716 * 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
|
7717 * 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
|
7718 * 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
|
7719 * 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
|
7720 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7721 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
|
7722 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7723 ULONG message = 0, msgid = 0; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7724 |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7725 if(window && signame && sigfunc) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7726 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7727 if((message = _findsigmessage(signame)) != 0) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7728 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7729 _new_signal(message, window, (int)msgid, sigfunc, data); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7730 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7731 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7732 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7733 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7734 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7735 * 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
|
7736 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7737 * 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
|
7738 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7739 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
|
7740 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7741 SignalHandler *prev = NULL, *tmp = Root; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7742 ULONG message; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
7743 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7744 if(!window || !signame || (message = _findsigmessage(signame)) == 0) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7745 return; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
7746 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7747 while(tmp) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7748 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7749 if(tmp->window == window && tmp->message == message) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7750 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7751 if(prev) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7752 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7753 prev->next = tmp->next; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7754 free(tmp); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7755 tmp = prev->next; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7756 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7757 else |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7758 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7759 Root = tmp->next; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7760 free(tmp); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7761 tmp = Root; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7762 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7763 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7764 else |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7765 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7766 prev = tmp; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7767 tmp = tmp->next; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7768 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7769 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7770 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7771 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7772 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7773 * 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
|
7774 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7775 * 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
|
7776 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7777 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
|
7778 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7779 SignalHandler *prev = NULL, *tmp = Root; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
7780 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7781 while(tmp) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7782 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7783 if(tmp->window == window) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7784 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7785 if(prev) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7786 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7787 prev->next = tmp->next; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7788 free(tmp); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7789 tmp = prev->next; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7790 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7791 else |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7792 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7793 Root = tmp->next; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7794 free(tmp); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7795 tmp = Root; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7796 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7797 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7798 else |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7799 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7800 prev = tmp; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7801 tmp = tmp->next; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7802 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7803 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7804 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7805 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7806 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7807 * 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
|
7808 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7809 * 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
|
7810 * 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
|
7811 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7812 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
|
7813 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7814 SignalHandler *prev = NULL, *tmp = Root; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
7815 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7816 while(tmp) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7817 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7818 if(tmp->window == window && tmp->data == data) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7819 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7820 if(prev) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7821 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7822 prev->next = tmp->next; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7823 free(tmp); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7824 tmp = prev->next; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7825 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7826 else |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7827 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7828 Root = tmp->next; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7829 free(tmp); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7830 tmp = Root; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7831 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7832 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7833 else |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7834 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7835 prev = tmp; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7836 tmp = tmp->next; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7837 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
7838 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7839 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7840 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7841 void _my_strlwr(char *buf) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7842 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7843 int z, len = strlen(buf); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7844 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7845 for(z=0;z<len;z++) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7846 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7847 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
|
7848 buf[z] -= 'A' - 'a'; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7849 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7850 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7851 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7852 /* 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
|
7853 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7854 * 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
|
7855 * handle: Pointer to a module handle, |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7856 * 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
|
7857 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7858 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
|
7859 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7860 int len; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7861 char *newname; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7862 char errorbuf[1024]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7863 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7864 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7865 if(!handle) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7866 return -1; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7867 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7868 if((len = strlen(name)) == 0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7869 return -1; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7870 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7871 /* Lenth + "lib" + ".dylib" + NULL */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7872 newname = malloc(len + 10); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7873 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7874 if(!newname) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7875 return -1; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7876 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7877 sprintf(newname, "lib%s.dylib", name); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7878 _my_strlwr(newname); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7879 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7880 *handle = dlopen(newname, RTLD_NOW); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7881 if(*handle == NULL) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7882 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7883 strncpy(errorbuf, dlerror(), 1024); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7884 printf("%s\n", errorbuf); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7885 sprintf(newname, "lib%s.dylib", name); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7886 *handle = dlopen(newname, RTLD_NOW); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7887 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7888 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7889 free(newname); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7890 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7891 return (NULL == *handle) ? -1 : 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7892 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7893 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7894 /* 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
|
7895 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7896 * 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
|
7897 * 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
|
7898 * 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
|
7899 * the address. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7900 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7901 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
|
7902 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7903 if(!func || !name) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7904 return -1; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7905 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7906 if(strlen(name) == 0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7907 return -1; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7908 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7909 *func = (void*)dlsym(handle, name); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7910 return (NULL == *func); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7911 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7912 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7913 /* Frees the shared library previously opened. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7914 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7915 * 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
|
7916 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7917 int dw_module_close(HMOD handle) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7918 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7919 if(handle) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7920 return dlclose(handle); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7921 return 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7922 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7923 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7924 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7925 * 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
|
7926 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7927 HMTX dw_mutex_new(void) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7928 { |
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
|
7929 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
|
7930 |
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
|
7931 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
|
7932 return mutex; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7933 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7934 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7935 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7936 * 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
|
7937 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7938 * 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
|
7939 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7940 void dw_mutex_close(HMTX mutex) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7941 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7942 if(mutex) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7943 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7944 pthread_mutex_destroy(mutex); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7945 free(mutex); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7946 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7947 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7948 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7949 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7950 * 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
|
7951 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7952 * 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
|
7953 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7954 void dw_mutex_lock(HMTX mutex) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7955 { |
693
2f21ee9d7c7b
Experimental change for locking on the main thread... will be committing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
692
diff
changeset
|
7956 /* 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
|
7957 * 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
|
7958 * 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
|
7959 * 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
|
7960 */ |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
7961 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
|
7962 { |
693
2f21ee9d7c7b
Experimental change for locking on the main thread... will be committing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
692
diff
changeset
|
7963 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
|
7964 { |
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
|
7965 /* 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
|
7966 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
|
7967 { |
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
|
7968 /* 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
|
7969 } |
693
2f21ee9d7c7b
Experimental change for locking on the main thread... will be committing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
692
diff
changeset
|
7970 } |
691
578bbfd8c904
Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
690
diff
changeset
|
7971 } |
693
2f21ee9d7c7b
Experimental change for locking on the main thread... will be committing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
692
diff
changeset
|
7972 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
|
7973 { |
693
2f21ee9d7c7b
Experimental change for locking on the main thread... will be committing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
692
diff
changeset
|
7974 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
|
7975 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7976 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7977 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7978 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7979 * Reliquishes the access to the semaphore. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7980 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7981 * 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
|
7982 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7983 void dw_mutex_unlock(HMTX mutex) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7984 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7985 pthread_mutex_unlock(mutex); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7986 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7987 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7988 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7989 * 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
|
7990 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7991 HEV dw_event_new(void) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7992 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7993 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
|
7994 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7995 if(!eve) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7996 return NULL; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7997 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7998 /* 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
|
7999 * 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
|
8000 * 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
|
8001 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8002 pthread_mutex_init (&(eve->mutex), NULL); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8003 pthread_mutex_lock (&(eve->mutex)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8004 pthread_cond_init (&(eve->event), NULL); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8005 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8006 pthread_mutex_unlock (&(eve->mutex)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8007 eve->alive = 1; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8008 eve->posted = 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8009 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8010 return eve; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8011 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8012 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8013 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8014 * 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
|
8015 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8016 * 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
|
8017 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8018 int dw_event_reset (HEV eve) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8019 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8020 if(!eve) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8021 return FALSE; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8022 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8023 pthread_mutex_lock (&(eve->mutex)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8024 pthread_cond_broadcast (&(eve->event)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8025 pthread_cond_init (&(eve->event), NULL); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8026 eve->posted = 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8027 pthread_mutex_unlock (&(eve->mutex)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8028 return 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8029 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8030 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8031 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8032 * 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
|
8033 * 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
|
8034 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8035 * 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
|
8036 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8037 int dw_event_post (HEV eve) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8038 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8039 if(!eve) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8040 return FALSE; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8041 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8042 pthread_mutex_lock (&(eve->mutex)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8043 pthread_cond_broadcast (&(eve->event)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8044 eve->posted = 1; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8045 pthread_mutex_unlock (&(eve->mutex)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8046 return 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8047 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8048 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8049 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8050 * 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
|
8051 * 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
|
8052 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8053 * 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
|
8054 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8055 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
|
8056 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8057 int rc; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8058 struct timeval now; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8059 struct timespec timeo; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8060 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8061 if(!eve) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8062 return FALSE; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8063 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8064 if(eve->posted) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8065 return 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8066 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8067 pthread_mutex_lock (&(eve->mutex)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8068 gettimeofday(&now, 0); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8069 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
|
8070 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
|
8071 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
|
8072 pthread_mutex_unlock (&(eve->mutex)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8073 if(!rc) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8074 return 1; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8075 if(rc == ETIMEDOUT) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8076 return -1; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8077 return 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8078 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8079 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8080 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8081 * 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
|
8082 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8083 * 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
|
8084 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8085 int dw_event_close(HEV *eve) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8086 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8087 if(!eve || !(*eve)) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8088 return FALSE; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8089 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8090 pthread_mutex_lock (&((*eve)->mutex)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8091 pthread_cond_destroy (&((*eve)->event)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8092 pthread_mutex_unlock (&((*eve)->mutex)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8093 pthread_mutex_destroy (&((*eve)->mutex)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8094 free(*eve); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8095 *eve = NULL; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8096 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8097 return TRUE; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8098 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8099 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8100 struct _seminfo { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8101 int fd; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8102 int waiting; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8103 }; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8104 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8105 static void _handle_sem(int *tmpsock) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8106 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8107 fd_set rd; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8108 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
|
8109 int listenfd = tmpsock[0]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8110 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
|
8111 char command; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8112 sigset_t mask; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8113 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8114 sigfillset(&mask); /* Mask all allowed signals */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8115 pthread_sigmask(SIG_BLOCK, &mask, NULL); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8116 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8117 /* problems */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8118 if(tmpsock[1] == -1) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8119 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8120 free(array); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8121 return; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8122 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8123 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8124 array[0].fd = tmpsock[1]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8125 array[0].waiting = 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8126 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8127 /* 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
|
8128 free(tmpsock); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8129 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8130 while(1) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8131 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8132 FD_ZERO(&rd); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8133 FD_SET(listenfd, &rd); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8134 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8135 maxfd = listenfd; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8136 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8137 /* 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
|
8138 for(z=0;z<connectcount;z++) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8139 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8140 if(array[z].fd > maxfd) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8141 maxfd = array[z].fd; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8142 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8143 FD_SET(array[z].fd, &rd); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8144 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8145 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8146 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
|
8147 return; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8148 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8149 if(FD_ISSET(listenfd, &rd)) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8150 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8151 struct _seminfo *newarray; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8152 int newfd = accept(listenfd, 0, 0); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8153 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8154 if(newfd > -1) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8155 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8156 /* Add new connections to the set */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8157 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
|
8158 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
|
8159 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8160 newarray[connectcount].fd = newfd; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8161 newarray[connectcount].waiting = 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8162 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8163 connectcount++; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8164 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8165 /* Replace old array with new one */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8166 free(array); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8167 array = newarray; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8168 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8169 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8170 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8171 /* 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
|
8172 for(z=0;z<connectcount;z++) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8173 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8174 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
|
8175 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8176 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
|
8177 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8178 struct _seminfo *newarray; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8179 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8180 /* Remove this connection from the set */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8181 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
|
8182 if(!z) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8183 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
|
8184 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8185 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8186 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
|
8187 if(z!=(connectcount-1)) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8188 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
|
8189 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8190 connectcount--; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8191 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8192 /* Replace old array with new one */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8193 free(array); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8194 array = newarray; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8195 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8196 else if(bytesread == 1) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8197 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8198 switch(command) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8199 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8200 case 0: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8201 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8202 /* Reset */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8203 posted = 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8204 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8205 break; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8206 case 1: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8207 /* Post */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8208 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8209 int s; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8210 char tmp = (char)0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8211 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8212 posted = 1; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8213 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8214 for(s=0;s<connectcount;s++) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8215 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8216 /* The semaphore has been posted so |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8217 * 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
|
8218 * continue. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8219 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8220 if(array[s].waiting) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8221 write(array[s].fd, &tmp, 1); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8222 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8223 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8224 break; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8225 case 2: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8226 /* Wait */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8227 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8228 char tmp = (char)0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8229 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8230 array[z].waiting = 1; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8231 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8232 /* If we are posted exit immeditately */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8233 if(posted) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8234 write(array[z].fd, &tmp, 1); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8235 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8236 break; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8237 case 3: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8238 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8239 /* Done Waiting */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8240 array[z].waiting = 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8241 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8242 break; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8243 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8244 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8245 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8246 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8247 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8248 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8249 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8250 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8251 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8252 /* 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
|
8253 /* 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
|
8254 * opened from other processes. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8255 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8256 * 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
|
8257 * 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
|
8258 * by other processes. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8259 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8260 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
|
8261 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8262 struct sockaddr_un un; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8263 int ev, *tmpsock = (int *)malloc(sizeof(int)*2); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8264 HEV eve; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8265 DWTID dwthread; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8266 |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8267 if(!tmpsock) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8268 return NULL; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8269 |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8270 eve = (HEV)malloc(sizeof(struct _dw_unix_event)); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8271 |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8272 if(!eve) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8273 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8274 free(tmpsock); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8275 return NULL; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8276 } |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
8277 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8278 tmpsock[0] = socket(AF_UNIX, SOCK_STREAM, 0); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8279 ev = socket(AF_UNIX, SOCK_STREAM, 0); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8280 memset(&un, 0, sizeof(un)); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8281 un.sun_family=AF_UNIX; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8282 mkdir("/tmp/.dw", S_IWGRP|S_IWOTH); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8283 strcpy(un.sun_path, "/tmp/.dw/"); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8284 strcat(un.sun_path, name); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8285 |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8286 /* just to be safe, this should be changed |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8287 * to support multiple instances. |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8288 */ |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8289 remove(un.sun_path); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8290 |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8291 bind(tmpsock[0], (struct sockaddr *)&un, sizeof(un)); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8292 listen(tmpsock[0], 0); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8293 connect(ev, (struct sockaddr *)&un, sizeof(un)); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8294 tmpsock[1] = accept(tmpsock[0], 0, 0); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8295 |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8296 if(tmpsock[0] < 0 || tmpsock[1] < 0 || ev < 0) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8297 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8298 if(tmpsock[0] > -1) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8299 close(tmpsock[0]); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8300 if(tmpsock[1] > -1) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8301 close(tmpsock[1]); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8302 if(ev > -1) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8303 close(ev); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8304 free(tmpsock); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8305 free(eve); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8306 return NULL; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8307 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8308 |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8309 /* Create a thread to handle this event semaphore */ |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8310 pthread_create(&dwthread, NULL, (void *)_handle_sem, (void *)tmpsock); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8311 eve->alive = ev; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8312 return eve; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8313 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8314 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8315 /* 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
|
8316 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8317 * 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
|
8318 * 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
|
8319 * by other processes. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8320 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8321 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
|
8322 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8323 struct sockaddr_un un; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8324 HEV eve; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8325 int ev = socket(AF_UNIX, SOCK_STREAM, 0); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8326 if(ev < 0) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8327 return NULL; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8328 |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8329 eve = (HEV)malloc(sizeof(struct _dw_unix_event)); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8330 |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8331 if(!eve) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8332 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8333 close(ev); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8334 return NULL; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8335 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8336 |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8337 un.sun_family=AF_UNIX; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8338 mkdir("/tmp/.dw", S_IWGRP|S_IWOTH); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8339 strcpy(un.sun_path, "/tmp/.dw/"); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8340 strcat(un.sun_path, name); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8341 connect(ev, (struct sockaddr *)&un, sizeof(un)); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8342 eve->alive = ev; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8343 return eve; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8344 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8345 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8346 /* 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
|
8347 * on this semaphore will block. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8348 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8349 * 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
|
8350 * an open or create call. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8351 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8352 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
|
8353 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8354 /* signal reset */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8355 char tmp = (char)0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8356 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8357 if(!eve || eve->alive < 0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8358 return 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8359 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8360 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
|
8361 return 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8362 return 1; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8363 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8364 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8365 /* 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
|
8366 * 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
|
8367 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8368 * 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
|
8369 * an open or create call. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8370 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8371 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
|
8372 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8373 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8374 /* signal post */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8375 char tmp = (char)1; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8376 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8377 if(!eve || eve->alive < 0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8378 return 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8379 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8380 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
|
8381 return 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8382 return 1; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8383 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8384 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8385 /* 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
|
8386 * 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
|
8387 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8388 * 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
|
8389 * an open or create call. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8390 * 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
|
8391 * or -1 if indefinite. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8392 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8393 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
|
8394 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8395 fd_set rd; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8396 struct timeval tv, *useme; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8397 int retval = 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8398 char tmp; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8399 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8400 if(!eve || eve->alive < 0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8401 return DW_ERROR_NON_INIT; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8402 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8403 /* Set the timout or infinite */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8404 if(timeout == -1) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8405 useme = NULL; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8406 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8407 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8408 tv.tv_sec = timeout / 1000; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8409 tv.tv_usec = timeout % 1000; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8410 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8411 useme = &tv; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8412 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8413 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8414 FD_ZERO(&rd); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8415 FD_SET(eve->alive, &rd); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8416 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8417 /* Signal wait */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8418 tmp = (char)2; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8419 write(eve->alive, &tmp, 1); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8420 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8421 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
|
8422 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8423 /* Signal done waiting. */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8424 tmp = (char)3; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8425 write(eve->alive, &tmp, 1); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8426 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8427 if(retval == 0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8428 return DW_ERROR_TIMEOUT; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8429 else if(retval == -1) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8430 return DW_ERROR_INTERRUPT; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8431 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8432 /* 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
|
8433 * we don't loop endlessly. :) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8434 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8435 read(eve->alive, &tmp, 1); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8436 return 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8437 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8438 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8439 /* 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
|
8440 * 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
|
8441 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8442 * 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
|
8443 * an open or create call. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8444 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8445 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
|
8446 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8447 /* Finally close the domain socket, |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8448 * cleanup will continue in _handle_sem. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8449 */ |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8450 if(eve) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8451 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8452 close(eve->alive); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8453 free(eve); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8454 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8455 return 0; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8456 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8457 |
697
830e1f3672b9
Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
696
diff
changeset
|
8458 /* 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
|
8459 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
|
8460 { |
830e1f3672b9
Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
696
diff
changeset
|
8461 #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
|
8462 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
|
8463 [pool drain]; |
698
e19f69a78f21
Fix for pool being removed and not just drained.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
697
diff
changeset
|
8464 pool = [[NSAutoreleasePool alloc] init]; |
e19f69a78f21
Fix for pool being removed and not just drained.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
697
diff
changeset
|
8465 pthread_setspecific(_dw_pool_key, pool); |
731
6a589a1a42b0
Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
730
diff
changeset
|
8466 #endif |
697
830e1f3672b9
Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
696
diff
changeset
|
8467 } |
830e1f3672b9
Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
696
diff
changeset
|
8468 |
830e1f3672b9
Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
696
diff
changeset
|
8469 /* |
830e1f3672b9
Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
696
diff
changeset
|
8470 * Setup thread independent pools. |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8471 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8472 void _dwthreadstart(void *data) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8473 { |
826
6bb8bff36548
Implemented thread specific colors. Allows threads to have their own colors... also reducing color object recreation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
825
diff
changeset
|
8474 void (*threadfunc)(void *) = NULL; |
6bb8bff36548
Implemented thread specific colors. Allows threads to have their own colors... also reducing color object recreation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
825
diff
changeset
|
8475 void **tmp = (void **)data; |
6bb8bff36548
Implemented thread specific colors. Allows threads to have their own colors... also reducing color object recreation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
825
diff
changeset
|
8476 NSColor *color; |
6bb8bff36548
Implemented thread specific colors. Allows threads to have their own colors... also reducing color object recreation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
825
diff
changeset
|
8477 |
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
|
8478 /* 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
|
8479 #if !defined(GARBAGE_COLLECT) |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8480 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
|
8481 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
|
8482 #endif |
826
6bb8bff36548
Implemented thread specific colors. Allows threads to have their own colors... also reducing color object recreation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
825
diff
changeset
|
8483 _init_colors(); |
6bb8bff36548
Implemented thread specific colors. Allows threads to have their own colors... also reducing color object recreation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
825
diff
changeset
|
8484 |
6bb8bff36548
Implemented thread specific colors. Allows threads to have their own colors... also reducing color object recreation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
825
diff
changeset
|
8485 threadfunc = (void (*)(void *))tmp[0]; |
6bb8bff36548
Implemented thread specific colors. Allows threads to have their own colors... also reducing color object recreation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
825
diff
changeset
|
8486 |
6bb8bff36548
Implemented thread specific colors. Allows threads to have their own colors... also reducing color object recreation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
825
diff
changeset
|
8487 /* Start our thread function */ |
6bb8bff36548
Implemented thread specific colors. Allows threads to have their own colors... also reducing color object recreation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
825
diff
changeset
|
8488 threadfunc(tmp[1]); |
6bb8bff36548
Implemented thread specific colors. Allows threads to have their own colors... also reducing color object recreation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
825
diff
changeset
|
8489 |
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
|
8490 /* Release the pool when we are done so we don't leak */ |
826
6bb8bff36548
Implemented thread specific colors. Allows threads to have their own colors... also reducing color object recreation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
825
diff
changeset
|
8491 color = pthread_getspecific(_dw_fg_color_key); |
6bb8bff36548
Implemented thread specific colors. Allows threads to have their own colors... also reducing color object recreation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
825
diff
changeset
|
8492 [color release]; |
6bb8bff36548
Implemented thread specific colors. Allows threads to have their own colors... also reducing color object recreation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
825
diff
changeset
|
8493 color = pthread_getspecific(_dw_bg_color_key); |
6bb8bff36548
Implemented thread specific colors. Allows threads to have their own colors... also reducing color object recreation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
825
diff
changeset
|
8494 [color release]; |
666
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
8495 #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
|
8496 pool = pthread_getspecific(_dw_pool_key); |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8497 [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
|
8498 #endif |
826
6bb8bff36548
Implemented thread specific colors. Allows threads to have their own colors... also reducing color object recreation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
825
diff
changeset
|
8499 free(tmp); |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8500 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8501 |
744
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
8502 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
|
8503 { |
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
8504 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
|
8505 { |
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
8506 [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
|
8507 } |
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
8508 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
|
8509 [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
|
8510 } |
9882b0dfa304
Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
743
diff
changeset
|
8511 |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8512 /* |
697
830e1f3672b9
Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
696
diff
changeset
|
8513 * 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
|
8514 * Parameters: |
830e1f3672b9
Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
696
diff
changeset
|
8515 * 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
|
8516 * 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
|
8517 */ |
830e1f3672b9
Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
696
diff
changeset
|
8518 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
|
8519 { |
751
eba6ab48c952
Runtime Snow Leopard checks where possible and visual fix for Leopard status text.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
749
diff
changeset
|
8520 /* Get the operating system version */ |
eba6ab48c952
Runtime Snow Leopard checks where possible and visual fix for Leopard status text.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
749
diff
changeset
|
8521 Gestalt(gestaltSystemVersionMajor, &DWOSMajor); |
eba6ab48c952
Runtime Snow Leopard checks where possible and visual fix for Leopard status text.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
749
diff
changeset
|
8522 Gestalt(gestaltSystemVersionMinor, &DWOSMinor); |
eba6ab48c952
Runtime Snow Leopard checks where possible and visual fix for Leopard status text.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
749
diff
changeset
|
8523 Gestalt(gestaltSystemVersionBugFix, &DWOSBuild); |
736
5b48519a7fb2
Added retains to the window menus so they don't get autoreleased when switching between
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
735
diff
changeset
|
8524 /* 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
|
8525 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
|
8526 /* 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
|
8527 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
|
8528 /* 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
|
8529 #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
|
8530 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
|
8531 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
|
8532 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
|
8533 #endif |
826
6bb8bff36548
Implemented thread specific colors. Allows threads to have their own colors... also reducing color object recreation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
825
diff
changeset
|
8534 pthread_key_create(&_dw_fg_color_key, NULL); |
6bb8bff36548
Implemented thread specific colors. Allows threads to have their own colors... also reducing color object recreation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
825
diff
changeset
|
8535 pthread_key_create(&_dw_bg_color_key, NULL); |
6bb8bff36548
Implemented thread specific colors. Allows threads to have their own colors... also reducing color object recreation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
825
diff
changeset
|
8536 _init_colors(); |
697
830e1f3672b9
Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
696
diff
changeset
|
8537 /* 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
|
8538 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
|
8539 [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
|
8540 [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
|
8541 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
|
8542 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
|
8543 /* 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
|
8544 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
|
8545 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
|
8546 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
|
8547 /* 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
|
8548 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
|
8549 [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
|
8550 [thread release]; |
859
80a88c91ccf6
Implemented vertical centering on text fields.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
858
diff
changeset
|
8551 [NSTextField setCellClass:[DWTextFieldCell class]]; |
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
|
8552 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
|
8553 } |
830e1f3672b9
Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
696
diff
changeset
|
8554 |
830e1f3672b9
Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
696
diff
changeset
|
8555 /* |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8556 * 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
|
8557 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8558 * 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
|
8559 * 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
|
8560 * 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
|
8561 * 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
|
8562 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8563 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
|
8564 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8565 char namebuf[1024]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8566 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
|
8567 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8568 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
|
8569 sprintf(namebuf, "/tmp/.dw/%s", name); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8570 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8571 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
|
8572 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8573 free(handle); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8574 return NULL; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8575 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8576 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8577 ftruncate(handle->fd, size); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8578 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8579 /* 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
|
8580 *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
|
8581 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8582 if(*dest == MAP_FAILED) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8583 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8584 close(handle->fd); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8585 *dest = NULL; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8586 free(handle); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8587 return NULL; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8588 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8589 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8590 handle->size = size; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8591 handle->sid = getsid(0); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8592 handle->path = strdup(namebuf); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8593 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8594 return handle; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8595 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8596 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8597 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8598 * 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
|
8599 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8600 * 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
|
8601 * 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
|
8602 * 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
|
8603 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8604 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
|
8605 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8606 char namebuf[1024]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8607 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
|
8608 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8609 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
|
8610 sprintf(namebuf, "/tmp/.dw/%s", name); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8611 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8612 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
|
8613 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8614 free(handle); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8615 return NULL; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8616 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8617 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8618 /* 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
|
8619 *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
|
8620 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8621 if(*dest == MAP_FAILED) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8622 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8623 close(handle->fd); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8624 *dest = NULL; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8625 free(handle); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8626 return NULL; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8627 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8628 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8629 handle->size = size; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8630 handle->sid = -1; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8631 handle->path = NULL; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8632 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8633 return handle; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8634 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8635 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8636 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8637 * 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
|
8638 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8639 * 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
|
8640 * 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
|
8641 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8642 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
|
8643 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8644 struct _dw_unix_shm *h = handle; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8645 int rc = munmap(ptr, h->size); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8646 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8647 close(h->fd); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8648 if(h->path) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8649 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8650 /* 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
|
8651 * creator of the file. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8652 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8653 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
|
8654 remove(h->path); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8655 free(h->path); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8656 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8657 return rc; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8658 } |
697
830e1f3672b9
Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
696
diff
changeset
|
8659 |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8660 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8661 * 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
|
8662 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8663 * 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
|
8664 * 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
|
8665 * 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
|
8666 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8667 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
|
8668 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8669 DWTID thread; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8670 void **tmp = malloc(sizeof(void *) * 2); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8671 int rc; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8672 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8673 tmp[0] = func; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8674 tmp[1] = data; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8675 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8676 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
|
8677 if(rc == 0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8678 return thread; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8679 return (DWTID)-1; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8680 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8681 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8682 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8683 * Ends execution of current thread immediately. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8684 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8685 void dw_thread_end(void) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8686 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8687 pthread_exit(NULL); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8688 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8689 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8690 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8691 * Returns the current thread's ID. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8692 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8693 DWTID dw_thread_id(void) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8694 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8695 return (DWTID)pthread_self(); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8696 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8697 |
661
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
8698 /* |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
8699 * 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
|
8700 * Parameters: |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
8701 * program: Program name with optional path. |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
8702 * 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
|
8703 * 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
|
8704 * Returns: |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
8705 * -1 on error. |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
8706 */ |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
8707 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
|
8708 { |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8709 int ret = -1; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
8710 |
738
52d5ed00f892
Use NSWorkplace to launch GUI applications instead of fork() and exec().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
737
diff
changeset
|
8711 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
|
8712 { |
52d5ed00f892
Use NSWorkplace to launch GUI applications instead of fork() and exec().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
737
diff
changeset
|
8713 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
|
8714 { |
52d5ed00f892
Use NSWorkplace to launch GUI applications instead of fork() and exec().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
737
diff
changeset
|
8715 [[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
|
8716 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
|
8717 } |
52d5ed00f892
Use NSWorkplace to launch GUI applications instead of fork() and exec().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
737
diff
changeset
|
8718 else |
52d5ed00f892
Use NSWorkplace to launch GUI applications instead of fork() and exec().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
737
diff
changeset
|
8719 { |
52d5ed00f892
Use NSWorkplace to launch GUI applications instead of fork() and exec().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
737
diff
changeset
|
8720 [[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
|
8721 } |
52d5ed00f892
Use NSWorkplace to launch GUI applications instead of fork() and exec().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
737
diff
changeset
|
8722 return 0; |
52d5ed00f892
Use NSWorkplace to launch GUI applications instead of fork() and exec().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
737
diff
changeset
|
8723 } |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
8724 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8725 if((ret = fork()) == 0) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8726 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8727 int i; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
8728 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8729 for (i = 3; i < 256; i++) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8730 close(i); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8731 setsid(); |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
8732 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8733 if(type == DW_EXEC_CON) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8734 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8735 char **tmpargs; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
8736 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8737 if(!params) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8738 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8739 tmpargs = malloc(sizeof(char *)); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8740 tmpargs[0] = NULL; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8741 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8742 else |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8743 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8744 int z = 0; |
762
2aaa3f67cfb1
Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
760
diff
changeset
|
8745 |
752
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8746 while(params[z]) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8747 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8748 z++; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8749 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8750 tmpargs = malloc(sizeof(char *)*(z+3)); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8751 z=0; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8752 tmpargs[0] = "xterm"; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8753 tmpargs[1] = "-e"; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8754 while(params[z]) |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8755 { |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8756 tmpargs[z+2] = params[z]; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8757 z++; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8758 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8759 tmpargs[z+2] = NULL; |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8760 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8761 execvp("xterm", tmpargs); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8762 free(tmpargs); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8763 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8764 /* If we got here exec failed */ |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8765 _exit(-1); |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8766 } |
cf447811d322
Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
751
diff
changeset
|
8767 return ret; |
661
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
8768 } |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
8769 |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
8770 /* |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
8771 * 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
|
8772 * Parameters: |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
8773 * url: Uniform resource locator. |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
8774 */ |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
8775 int dw_browse(char *url) |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
8776 { |
715
5f8102bd7646
dw_browse() reimplmented so it actually works as expected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
714
diff
changeset
|
8777 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
|
8778 [[NSWorkspace sharedWorkspace] openURL:myurl]; |
5f8102bd7646
dw_browse() reimplmented so it actually works as expected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
714
diff
changeset
|
8779 return 0; |
5f8102bd7646
dw_browse() reimplmented so it actually works as expected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
714
diff
changeset
|
8780 } |