annotate mac/dw.m @ 1212:5271d5cb27ac

Implemented dw_container_set_row_bg() on Windows. Current immplementation is a bit slow, it does more redrawing than necessary... but it works for now... will look to improve it in the future. Also removed a lot of dead code from a previous attempt at implementation. Also flipped the default colors on Mac since the first index is even (0) not odd (1).
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Sun, 09 Oct 2011 09:50:07 +0000
parents 5a016a5a7412
children dc8ea09605f7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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 *
942
3c9dfb004df6 Minor change to the build comment.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 941
diff changeset
8 * Requires 10.5 or later.
3c9dfb004df6 Minor change to the build comment.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 941
diff changeset
9 * clang -std=c99 -g -o dwtest -D__MAC__ -I. dwtest.c mac/dw.m -framework Cocoa -framework WebKit
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
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
64 /*
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
65 * List those icons that have transparency first
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
66 */
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
67 #define NUM_EXTS 8
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
68 char *image_exts[NUM_EXTS] =
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
69 {
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
70 ".png",
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
71 ".ico",
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
72 ".icns",
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
73 ".gif",
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
74 ".jpg",
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
75 ".jpeg",
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
76 ".tiff",
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
77 ".bmp"
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
78 };
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
79
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
80 char *_dw_get_image_extension( char *filename )
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
81 {
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
82 char *file = alloca(strlen(filename) + 6);
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
83 int found_ext = 0,i;
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
84
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
85 /* Try various extentions */
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
86 for ( i = 0; i < NUM_EXTS; i++ )
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
87 {
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
88 strcpy( file, filename );
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
89 strcat( file, image_exts[i] );
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
90 if ( access( file, R_OK ) == 0 )
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
91 {
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
92 found_ext = 1;
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
93 break;
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
94 }
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
95 }
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
96 if ( found_ext == 1 )
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
97 {
940
b5ae9cf15f68 Fix for returning wrong extension in _dw_get_image_extension; only worked for .ico files
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 939
diff changeset
98 return image_exts[i];
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
99 }
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
100 return NULL;
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
101 }
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
102
657
f31a47b055f8 Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 656
diff changeset
103 unsigned long _get_color(unsigned long thiscolor)
f31a47b055f8 Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 656
diff changeset
104 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
105 if(thiscolor & DW_RGB_COLOR)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
106 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
107 return thiscolor & ~DW_RGB_COLOR;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
108 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
109 else if(thiscolor < 17)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
110 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
111 return _colors[thiscolor];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
112 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
113 return 0;
657
f31a47b055f8 Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 656
diff changeset
114 }
f31a47b055f8 Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 656
diff changeset
115
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
116 /* 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
117 #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
118 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
119 #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
120 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
121 pthread_key_t _dw_bg_color_key;
950
73ff2daed8ca Attempt at fixing mouse button detection on Leopard for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 949
diff changeset
122 SInt32 DWOSMajor, DWOSMinor, DWOSBuild;
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
123
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
124 /* 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
125 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
126 {
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
127 NSColor *fgcolor = [[NSColor grayColor] retain];
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
128
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
129 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
130 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
131 }
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
132
652
ef0f484c6c4b Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 651
diff changeset
133 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
134 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
135 struct _sighandler *next;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
136 ULONG message;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
137 HWND window;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
138 int id;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
139 void *signalfunction;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
140 void *data;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
141
652
ef0f484c6c4b Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 651
diff changeset
142 } SignalHandler;
ef0f484c6c4b Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 651
diff changeset
143
ef0f484c6c4b Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 651
diff changeset
144 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
145
678
0ec8edbb82cf Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 677
diff changeset
146 /* Some internal prototypes */
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
147 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
148 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
149 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
150 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
151
652
ef0f484c6c4b Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 651
diff changeset
152 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
153 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
154 SignalHandler *tmp = Root;
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
155
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
156 /* Find any callbacks for this function */
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
157 while(tmp)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
158 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
159 if(tmp->message == messageid && window == tmp->window)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
160 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
161 return tmp;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
162 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
163 tmp = tmp->next;
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 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
166 }
ef0f484c6c4b Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 651
diff changeset
167
703
329736825f9b Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 702
diff changeset
168 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
169 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
170 ULONG message;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
171 char name[30];
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
172
703
329736825f9b Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 702
diff changeset
173 } SignalList;
329736825f9b Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 702
diff changeset
174
329736825f9b Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 702
diff changeset
175 /* 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
176 #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
177
329736825f9b Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 702
diff changeset
178 SignalList SignalTranslate[SIGNALMAX] = {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
179 { 1, DW_SIGNAL_CONFIGURE },
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
180 { 2, DW_SIGNAL_KEY_PRESS },
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
181 { 3, DW_SIGNAL_BUTTON_PRESS },
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
182 { 4, DW_SIGNAL_BUTTON_RELEASE },
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
183 { 5, DW_SIGNAL_MOTION_NOTIFY },
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
184 { 6, DW_SIGNAL_DELETE },
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
185 { 7, DW_SIGNAL_EXPOSE },
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
186 { 8, DW_SIGNAL_CLICKED },
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
187 { 9, DW_SIGNAL_ITEM_ENTER },
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
188 { 10, DW_SIGNAL_ITEM_CONTEXT },
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
189 { 11, DW_SIGNAL_LIST_SELECT },
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
190 { 12, DW_SIGNAL_ITEM_SELECT },
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
191 { 13, DW_SIGNAL_SET_FOCUS },
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
192 { 14, DW_SIGNAL_VALUE_CHANGED },
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
193 { 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
194 { 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
195 { 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
196 };
329736825f9b Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 702
diff changeset
197
652
ef0f484c6c4b Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 651
diff changeset
198 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
199 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
200 SignalHandler *handler = _get_handler(object, message);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
201 /* 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
202
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
203 if(handler)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
204 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
205 switch(message)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
206 {
703
329736825f9b Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 702
diff changeset
207 /* Timer event */
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
208 case 0:
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
209 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
210 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
211
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
212 if(!timerfunc(handler->data))
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
213 dw_timer_disconnect(handler->id);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
214 return 0;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
215 }
703
329736825f9b Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 702
diff changeset
216 /* Configure/Resize event */
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
217 case 1:
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
218 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
219 int (*sizefunc)(HWND, int, int, void *) = handler->signalfunction;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
220 NSSize size;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
221
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
222 if([object isKindOfClass:[NSWindow class]])
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
223 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
224 NSWindow *window = object;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
225 size = [[window contentView] frame].size;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
226 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
227 else
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 NSView *view = object;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
230 size = [view frame].size;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
231 }
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
232
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
233 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
234 {
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
235 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
236 }
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
237 return 0;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
238 }
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
239 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
240 {
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
241 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
242 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
243 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
244 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
245 char ch = '\0';
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
246
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
247 /* 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
248 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
249 {
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
250 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
251 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
252 {
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
253 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
254 }
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
255 }
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
256
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
257 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
258 }
703
329736825f9b Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 702
diff changeset
259 /* Button press and release event */
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
260 case 3:
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
261 case 4:
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
262 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
263 int (* API buttonfunc)(HWND, int, int, int, void *) = (int (* API)(HWND, int, int, int, void *))handler->signalfunction;
945
254b50be1bc1 Coordinate system changes to button press and motion notify events on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 944
diff changeset
264 id view = [[[event window] contentView] superview];
254b50be1bc1 Coordinate system changes to button press and motion notify events on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 944
diff changeset
265 NSPoint p = [view convertPoint:[event locationInWindow] toView:object];
922
07f9a73c6847 Fix for button press/release events coordinates being relative to the window instead of the screen on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 921
diff changeset
266 NSEventType type = [event type];
07f9a73c6847 Fix for button press/release events coordinates being relative to the window instead of the screen on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 921
diff changeset
267 int button = 1;
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
268
922
07f9a73c6847 Fix for button press/release events coordinates being relative to the window instead of the screen on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 921
diff changeset
269 if(type == NSRightMouseDown || type == NSRightMouseUp)
07f9a73c6847 Fix for button press/release events coordinates being relative to the window instead of the screen on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 921
diff changeset
270 {
07f9a73c6847 Fix for button press/release events coordinates being relative to the window instead of the screen on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 921
diff changeset
271 button = 2;
07f9a73c6847 Fix for button press/release events coordinates being relative to the window instead of the screen on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 921
diff changeset
272 }
07f9a73c6847 Fix for button press/release events coordinates being relative to the window instead of the screen on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 921
diff changeset
273 else if(type == NSOtherMouseDown || type == NSOtherMouseUp)
07f9a73c6847 Fix for button press/release events coordinates being relative to the window instead of the screen on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 921
diff changeset
274 {
07f9a73c6847 Fix for button press/release events coordinates being relative to the window instead of the screen on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 921
diff changeset
275 button = 3;
07f9a73c6847 Fix for button press/release events coordinates being relative to the window instead of the screen on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 921
diff changeset
276 }
07f9a73c6847 Fix for button press/release events coordinates being relative to the window instead of the screen on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 921
diff changeset
277
954
cfb12bf3bb06 Fixes for some more coordinate system issues on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 953
diff changeset
278 return buttonfunc(object, (int)p.x, (int)p.y, button, handler->data);
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
279 }
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
280 /* 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
281 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
282 {
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
283 int (* API motionfunc)(HWND, int, int, int, void *) = (int (* API)(HWND, int, int, int, void *))handler->signalfunction;
950
73ff2daed8ca Attempt at fixing mouse button detection on Leopard for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 949
diff changeset
284 int buttonmask = DWOSMinor > 5 ? (int)[NSEvent pressedMouseButtons] : 0;
945
254b50be1bc1 Coordinate system changes to button press and motion notify events on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 944
diff changeset
285 id view = [[[event window] contentView] superview];
254b50be1bc1 Coordinate system changes to button press and motion notify events on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 944
diff changeset
286 NSPoint p = [view convertPoint:[event locationInWindow] toView:object];
953
2dfc06afc7d3 Support dw_window_set_text() for groupboxes
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 952
diff changeset
287
950
73ff2daed8ca Attempt at fixing mouse button detection on Leopard for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 949
diff changeset
288 if(DWOSMinor < 6)
73ff2daed8ca Attempt at fixing mouse button detection on Leopard for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 949
diff changeset
289 {
73ff2daed8ca Attempt at fixing mouse button detection on Leopard for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 949
diff changeset
290 buttonmask = (1 << [event buttonNumber]);
73ff2daed8ca Attempt at fixing mouse button detection on Leopard for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 949
diff changeset
291 }
945
254b50be1bc1 Coordinate system changes to button press and motion notify events on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 944
diff changeset
292
954
cfb12bf3bb06 Fixes for some more coordinate system issues on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 953
diff changeset
293 return motionfunc(object, (int)p.x, (int)p.y, buttonmask, handler->data);
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
294 }
703
329736825f9b Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 702
diff changeset
295 /* Window close event */
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
296 case 6:
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
297 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
298 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
299 return closefunc(object, handler->data);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
300 }
703
329736825f9b Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 702
diff changeset
301 /* Window expose/draw event */
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
302 case 7:
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
303 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
304 DWExpose exp;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
305 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
306 NSRect rect = [object frame];
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
307
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
308 exp.x = rect.origin.x;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
309 exp.y = rect.origin.y;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
310 exp.width = rect.size.width;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
311 exp.height = rect.size.height;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
312 int result = exposefunc(object, &exp, handler->data);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
313 [[object window] flushWindow];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
314 return result;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
315 }
703
329736825f9b Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 702
diff changeset
316 /* Clicked event for buttons and menu items */
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
317 case 8:
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
318 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
319 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
320
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
321 return clickfunc(object, handler->data);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
322 }
703
329736825f9b Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 702
diff changeset
323 /* 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
324 case 9:
62aae18e7b7d Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 668
diff changeset
325 {
62aae18e7b7d Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 668
diff changeset
326 int (*containerselectfunc)(HWND, char *, void *) = handler->signalfunction;
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
327
669
62aae18e7b7d Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 668
diff changeset
328 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
329 }
703
329736825f9b Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 702
diff changeset
330 /* Container context menu event */
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
331 case 10:
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
332 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
333 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
334 char *text = (char *)event;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
335 void *user = NULL;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
336 LONG x,y;
1068
efaa9ceeb253 Removed test for class member for itemdata in dw_tree_item_get_data()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1067
diff changeset
337
1061
d91e09dc3865 Fix for the item data field of the context event always being NULL even for tree items on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1051
diff changeset
338 /* Fill in both items for the tree */
d91e09dc3865 Fix for the item data field of the context event always being NULL even for tree items on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1051
diff changeset
339 if([object isKindOfClass:[NSOutlineView class]])
d91e09dc3865 Fix for the item data field of the context event always being NULL even for tree items on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1051
diff changeset
340 {
d91e09dc3865 Fix for the item data field of the context event always being NULL even for tree items on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1051
diff changeset
341 id item = event;
1065
25e0317335fc Switched from using NSPointerArray to NSMutableArray on Mac to avoid the duplicate string crashes
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1064
diff changeset
342 NSString *nstr = [item objectAtIndex:1];
1061
d91e09dc3865 Fix for the item data field of the context event always being NULL even for tree items on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1051
diff changeset
343 text = (char *)[nstr UTF8String];
1065
25e0317335fc Switched from using NSPointerArray to NSMutableArray on Mac to avoid the duplicate string crashes
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1064
diff changeset
344 NSValue *value = [item objectAtIndex:2];
25e0317335fc Switched from using NSPointerArray to NSMutableArray on Mac to avoid the duplicate string crashes
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1064
diff changeset
345 if(value && [value isKindOfClass:[NSValue class]])
25e0317335fc Switched from using NSPointerArray to NSMutableArray on Mac to avoid the duplicate string crashes
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1064
diff changeset
346 {
25e0317335fc Switched from using NSPointerArray to NSMutableArray on Mac to avoid the duplicate string crashes
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1064
diff changeset
347 user = [value pointerValue];
25e0317335fc Switched from using NSPointerArray to NSMutableArray on Mac to avoid the duplicate string crashes
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1064
diff changeset
348 }
1061
d91e09dc3865 Fix for the item data field of the context event always being NULL even for tree items on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1051
diff changeset
349 }
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
350
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
351 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
352
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
353 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
354 }
703
329736825f9b Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 702
diff changeset
355 /* 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
356 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
357 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
358 {
329736825f9b Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 702
diff changeset
359 int (* API valuechangedfunc)(HWND, int, void *) = (int (* API)(HWND, int, void *))handler->signalfunction;
1102
cfe7d2b6bc16 Added DW_INT_TO_POINTER/DW_UINT_TO_POINTER/DW_POINTER_TO_INT/DW_POINTER_TO_UINT macros.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1101
diff changeset
360 int selected = DW_POINTER_TO_INT(event);
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
361
703
329736825f9b Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 702
diff changeset
362 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
363 }
329736825f9b Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 702
diff changeset
364 /* Tree class selection event */
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
365 case 12:
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
366 {
709
5a268d5f1cfa Fixes for tree event handling. Still more to come shortly...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 708
diff changeset
367 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
368 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
369 void *user = NULL;
5a268d5f1cfa Fixes for tree event handling. Still more to come shortly...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 708
diff changeset
370 id item = nil;
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
371
710
78460ff977c1 Finishing up tree event/signal handlers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 709
diff changeset
372 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
373 {
5a268d5f1cfa Fixes for tree event handling. Still more to come shortly...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 708
diff changeset
374 item = (id)event;
1065
25e0317335fc Switched from using NSPointerArray to NSMutableArray on Mac to avoid the duplicate string crashes
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1064
diff changeset
375 NSString *nstr = [item objectAtIndex:1];
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
376
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
377 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
378 {
01107d8e033e Fixed the scrollbar maximum range to be correct. Also added some MLE code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 711
diff changeset
379 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
380 }
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
381 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
382 {
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
383 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
384 }
1068
efaa9ceeb253 Removed test for class member for itemdata in dw_tree_item_get_data()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1067
diff changeset
385
1065
25e0317335fc Switched from using NSPointerArray to NSMutableArray on Mac to avoid the duplicate string crashes
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1064
diff changeset
386 NSValue *value = [item objectAtIndex:2];
25e0317335fc Switched from using NSPointerArray to NSMutableArray on Mac to avoid the duplicate string crashes
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1064
diff changeset
387 if(value && [value isKindOfClass:[NSValue class]])
25e0317335fc Switched from using NSPointerArray to NSMutableArray on Mac to avoid the duplicate string crashes
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1064
diff changeset
388 {
25e0317335fc Switched from using NSPointerArray to NSMutableArray on Mac to avoid the duplicate string crashes
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1064
diff changeset
389 user = [value pointerValue];
25e0317335fc Switched from using NSPointerArray to NSMutableArray on Mac to avoid the duplicate string crashes
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1064
diff changeset
390 }
709
5a268d5f1cfa Fixes for tree event handling. Still more to come shortly...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 708
diff changeset
391 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
392 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
393 {
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
394 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
395 }
709
5a268d5f1cfa Fixes for tree event handling. Still more to come shortly...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 708
diff changeset
396 return result;
5a268d5f1cfa Fixes for tree event handling. Still more to come shortly...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 708
diff changeset
397 }
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
398
709
5a268d5f1cfa Fixes for tree event handling. Still more to come shortly...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 708
diff changeset
399 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
400 }
703
329736825f9b Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 702
diff changeset
401 /* 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
402 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
403 {
329736825f9b Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 702
diff changeset
404 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
405
703
329736825f9b Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 702
diff changeset
406 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
407 }
329736825f9b Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 702
diff changeset
408 /* 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
409 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
410 {
329736825f9b Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 702
diff changeset
411 int (* API switchpagefunc)(HWND, unsigned long, void *) = (int (* API)(HWND, unsigned long, void *))handler->signalfunction;
1102
cfe7d2b6bc16 Added DW_INT_TO_POINTER/DW_UINT_TO_POINTER/DW_POINTER_TO_INT/DW_POINTER_TO_UINT macros.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1101
diff changeset
412 int pageid = DW_POINTER_TO_INT(event);
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
413
703
329736825f9b Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 702
diff changeset
414 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
415 }
722
5a8d5161651d Implemented tree expand event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 721
diff changeset
416 case 16:
5a8d5161651d Implemented tree expand event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 721
diff changeset
417 {
5a8d5161651d Implemented tree expand event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 721
diff changeset
418 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
419
722
5a8d5161651d Implemented tree expand event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 721
diff changeset
420 return treeexpandfunc(handler->window, (HTREEITEM)event, handler->data);
5a8d5161651d Implemented tree expand event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 721
diff changeset
421 }
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
422 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
423 {
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
424 int (*clickcolumnfunc)(HWND, int, void *) = handler->signalfunction;
1102
cfe7d2b6bc16 Added DW_INT_TO_POINTER/DW_UINT_TO_POINTER/DW_POINTER_TO_INT/DW_POINTER_TO_UINT macros.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1101
diff changeset
425 int column_num = DW_POINTER_TO_INT(event);
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
426
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
427 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
428 }
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
429 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
430 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
431 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
432 }
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
433
657
f31a47b055f8 Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 656
diff changeset
434 /* Subclass for the Timer type */
f31a47b055f8 Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 656
diff changeset
435 @interface DWTimerHandler : NSObject { }
f31a47b055f8 Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 656
diff changeset
436 -(void)runTimer:(id)sender;
f31a47b055f8 Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 656
diff changeset
437 @end
f31a47b055f8 Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 656
diff changeset
438
f31a47b055f8 Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 656
diff changeset
439 @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
440 -(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
441 @end
f31a47b055f8 Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 656
diff changeset
442
654
80e253df49fd Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 653
diff changeset
443 NSApplication *DWApp;
80e253df49fd Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 653
diff changeset
444 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
445 NSFont *DWDefaultFont;
657
f31a47b055f8 Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 656
diff changeset
446 DWTimerHandler *DWHandler;
654
80e253df49fd Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 653
diff changeset
447 #if !defined(GARBAGE_COLLECT)
80e253df49fd Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 653
diff changeset
448 NSAutoreleasePool *pool;
80e253df49fd Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 653
diff changeset
449 #endif
661
eee90a788876 Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 660
diff changeset
450 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
451 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
452 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
453 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
454 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
455 DWTID _dw_mutex_locked = (DWTID)-1;
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
456
699
b79300831495 Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 698
diff changeset
457 /* 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
458 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
459 {
b79300831495 Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 698
diff changeset
460 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
461 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
462 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
463 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
464 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
465 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
466 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
467 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
468 } DWBitBlt;
b79300831495 Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 698
diff changeset
469
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
470 /* 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
471 @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
472 -(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
473 -(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
474 -(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
475 -(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
476 @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
477
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
478 @implementation DWObject
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
479 -(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
480 -(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
481 {
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
482 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
483 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
484 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
485 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
486 }
699
b79300831495 Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 698
diff changeset
487 -(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
488 {
b79300831495 Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 698
diff changeset
489 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
490 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
491 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
492 id bltsrc = bltinfo->src;
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
493
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
494 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
495 {
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
496 [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
497 [NSGraphicsContext setCurrentContext:[NSGraphicsContext
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
498 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
499 [[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
500 }
b79300831495 Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 698
diff changeset
501 else
b79300831495 Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 698
diff changeset
502 {
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
503 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
504 {
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
505 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
506 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
507 }
699
b79300831495 Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 698
diff changeset
508 _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
509 }
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
510 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
511 {
910
329f2ca62f1b Switched to using a different potentially slower NSImage conversion to support Leopard.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 909
diff changeset
512 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
513 NSImage *image;
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
514
910
329f2ca62f1b Switched to using a different potentially slower NSImage conversion to support Leopard.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 909
diff changeset
515 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
516 {
329f2ca62f1b Switched to using a different potentially slower NSImage conversion to support Leopard.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 909
diff changeset
517 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
518 }
329f2ca62f1b Switched to using a different potentially slower NSImage conversion to support Leopard.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 909
diff changeset
519 else
329f2ca62f1b Switched to using a different potentially slower NSImage conversion to support Leopard.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 909
diff changeset
520 {
329f2ca62f1b Switched to using a different potentially slower NSImage conversion to support Leopard.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 909
diff changeset
521 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
522 [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
523 }
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
524 [image drawAtPoint:NSMakePoint(bltinfo->xdest, bltinfo->ydest) fromRect:NSMakeRect(bltinfo->xsrc, bltinfo->ysrc, bltinfo->width, bltinfo->height)
952
abb9203adc05 Use NSCompositeSourceOver for bitblting that respects transparency of the source
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 951
diff changeset
525 operation:NSCompositeSourceOver fraction:1.0];
699
b79300831495 Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 698
diff changeset
526 [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
527 [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
528 }
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
529 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
530 {
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
531 [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
532 }
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
533 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
534 {
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
535 [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
536 }
699
b79300831495 Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 698
diff changeset
537 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
538 }
b79300831495 Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 698
diff changeset
539 -(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
540 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
541 if(_DWLastDrawable)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
542 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
543 id object = _DWLastDrawable;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
544 NSWindow *window = [object window];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
545 [window flushWindow];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
546 }
699
b79300831495 Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 698
diff changeset
547 }
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
548 -(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
549 {
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
550 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
551 void **params = (void **)[v pointerValue];
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
552 void (* windowfunc)(void *);
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
553
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
554 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
555 {
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
556 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
557 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
558 {
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
559 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
560 }
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
561 }
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
562 }
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
563 @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
564
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
565 DWObject *DWObj;
654
80e253df49fd Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 653
diff changeset
566
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
567 /* 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
568 * 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
569 * basically everything. Was hoping to add methods
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
570 * 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
571 * 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
572 * going to work. -Brian
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
573 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
574
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
575 /* Subclass for a box type */
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
576 @interface DWBox : NSView
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
577 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
578 Box *box;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
579 void *userdata;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
580 NSColor *bgcolor;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
581 }
678
0ec8edbb82cf Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 677
diff changeset
582 -(id)init;
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
583 -(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
584 -(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
585 -(id)contentView;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
586 -(void *)userdata;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
587 -(void)setUserdata:(void *)input;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
588 -(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
589 -(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
590 -(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
591 -(void)mouseUp:(NSEvent *)theEvent;
701
c91a1b345f2e Fix for button press and context menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 700
diff changeset
592 -(NSMenu *)menuForEvent:(NSEvent *)theEvent;
c91a1b345f2e Fix for button press and context menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 700
diff changeset
593 -(void)rightMouseUp:(NSEvent *)theEvent;
c91a1b345f2e Fix for button press and context menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 700
diff changeset
594 -(void)otherMouseDown:(NSEvent *)theEvent;
c91a1b345f2e Fix for button press and context menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 700
diff changeset
595 -(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
596 -(void)keyDown:(NSEvent *)theEvent;
657
f31a47b055f8 Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 656
diff changeset
597 -(void)setColor:(unsigned long)input;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
598 @end
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
599
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
600 @implementation DWBox
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
601 -(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
602 {
e426de6e6c7c Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 665
diff changeset
603 self = [super init];
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
604
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
605 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
606 {
e426de6e6c7c Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 665
diff changeset
607 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
608 }
e426de6e6c7c Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 665
diff changeset
609 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
610 }
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
611 -(void)dealloc
678
0ec8edbb82cf Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 677
diff changeset
612 {
0ec8edbb82cf Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 677
diff changeset
613 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
614 free(box);
678
0ec8edbb82cf Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 677
diff changeset
615 _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
616 [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
617 }
e426de6e6c7c Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 665
diff changeset
618 -(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
619 -(id)contentView { return self; }
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
620 -(void *)userdata { return userdata; }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
621 -(void)setUserdata:(void *)input { userdata = input; }
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
622 -(void)drawRect:(NSRect)rect
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
623 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
624 if(bgcolor)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
625 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
626 [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
627 NSRectFill([self bounds]);
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
628 }
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
629 }
652
ef0f484c6c4b Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 651
diff changeset
630 -(BOOL)isFlipped { return YES; }
701
c91a1b345f2e Fix for button press and context menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 700
diff changeset
631 -(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
632 -(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
633 -(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
634 -(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
635 -(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
636 -(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
637 -(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
638 -(void)setColor:(unsigned long)input
f31a47b055f8 Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 656
diff changeset
639 {
755
f574028932cc Fix for crash when changing background colors, needed retain and release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 754
diff changeset
640 id orig = bgcolor;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
641
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
642 if(input == _colors[DW_CLR_DEFAULT])
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
643 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
644 bgcolor = nil;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
645 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
646 else
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
647 {
755
f574028932cc Fix for crash when changing background colors, needed retain and release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 754
diff changeset
648 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
649 [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
650 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
651 [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
652 }
f574028932cc Fix for crash when changing background colors, needed retain and release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 754
diff changeset
653 [orig release];
657
f31a47b055f8 Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 656
diff changeset
654 }
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
655 @end
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
656
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
657 /* Subclass for a group box type */
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
658 @interface DWGroupBox : NSBox
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
659 {
fc6a626a96cc Initial groupbox support. Sizing of the content frame is not quite right yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 768
diff changeset
660 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
661 NSColor *bgcolor;
928
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
662 NSSize borderSize;
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
663 }
fc6a626a96cc Initial groupbox support. Sizing of the content frame is not quite right yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 768
diff changeset
664 -(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
665 -(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
666 -(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
667 @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
668
fc6a626a96cc Initial groupbox support. Sizing of the content frame is not quite right yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 768
diff changeset
669 @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
670 -(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
671 -(void *)userdata { return userdata; }
928
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
672 -(NSSize)borderSize { return borderSize; }
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
673 -(NSSize)initBorder
928
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
674 {
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
675 NSSize frameSize = [self frame].size;
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
676
928
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
677 if(frameSize.height < 20 || frameSize.width < 20)
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
678 {
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
679 frameSize.width = frameSize.height = 100;
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
680 [self setFrameSize:frameSize];
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
681 }
928
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
682 NSSize contentSize = [[self contentView] frame].size;
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
683 NSSize titleSize = [self titleRect].size;
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
684
928
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
685 borderSize.width = 100-contentSize.width;
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
686 borderSize.height = (100-contentSize.height)-titleSize.height;
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
687 return borderSize;
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
688 }
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
689 -(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
690 @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
691
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
692 @interface DWWindow : NSWindow
1101
d7eafaa054ab Added support for dw_window_redraw() causing splitbar panes to redraw without
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1100
diff changeset
693 {
d7eafaa054ab Added support for dw_window_redraw() causing splitbar panes to redraw without
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1100
diff changeset
694 int redraw;
d7eafaa054ab Added support for dw_window_redraw() causing splitbar panes to redraw without
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1100
diff changeset
695 }
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
696 -(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
697 -(void)keyDown:(NSEvent *)theEvent;
932
ed10b5284f36 Fixes for dw_window_capture(), dw_window_release() and motion notify events on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 931
diff changeset
698 -(void)mouseDragged:(NSEvent *)theEvent;
1101
d7eafaa054ab Added support for dw_window_redraw() causing splitbar panes to redraw without
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1100
diff changeset
699 -(int)redraw;
d7eafaa054ab Added support for dw_window_redraw() causing splitbar panes to redraw without
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1100
diff changeset
700 -(void)setRedraw:(int)val;
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
701 @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
702
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
703 @implementation DWWindow
1129
ab73d0269a5b Ensure default keypress event is not processed if handler returns 1
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1128
diff changeset
704 -(void)sendEvent:(NSEvent *)theEvent
ab73d0269a5b Ensure default keypress event is not processed if handler returns 1
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1128
diff changeset
705 {
1133
25bea6526ca1 Similar Mac fix to what I just commited on Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1130
diff changeset
706 int rcode = -1;
1129
ab73d0269a5b Ensure default keypress event is not processed if handler returns 1
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1128
diff changeset
707 if([theEvent type] == NSKeyDown)
ab73d0269a5b Ensure default keypress event is not processed if handler returns 1
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1128
diff changeset
708 {
ab73d0269a5b Ensure default keypress event is not processed if handler returns 1
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1128
diff changeset
709 rcode = _event_handler(self, theEvent, 2);
ab73d0269a5b Ensure default keypress event is not processed if handler returns 1
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1128
diff changeset
710 }
1133
25bea6526ca1 Similar Mac fix to what I just commited on Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1130
diff changeset
711 if ( rcode != TRUE )
1129
ab73d0269a5b Ensure default keypress event is not processed if handler returns 1
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1128
diff changeset
712 [super sendEvent:theEvent];
ab73d0269a5b Ensure default keypress event is not processed if handler returns 1
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1128
diff changeset
713 }
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
714 -(void)keyDown:(NSEvent *)theEvent { }
949
451c71b7fdb1 Changed dw_window_capture() an dw_window_release() because the mouseDragged method does this already.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 948
diff changeset
715 -(void)mouseDragged:(NSEvent *)theEvent { _event_handler(self, theEvent, 5); }
1101
d7eafaa054ab Added support for dw_window_redraw() causing splitbar panes to redraw without
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1100
diff changeset
716 -(int)redraw { return redraw; }
d7eafaa054ab Added support for dw_window_redraw() causing splitbar panes to redraw without
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1100
diff changeset
717 -(void)setRedraw:(int)val { redraw = val; }
949
451c71b7fdb1 Changed dw_window_capture() an dw_window_release() because the mouseDragged method does this already.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 948
diff changeset
718 @end
451c71b7fdb1 Changed dw_window_capture() an dw_window_release() because the mouseDragged method does this already.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 948
diff changeset
719
451c71b7fdb1 Changed dw_window_capture() an dw_window_release() because the mouseDragged method does this already.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 948
diff changeset
720 /* Subclass for a render area type */
451c71b7fdb1 Changed dw_window_capture() an dw_window_release() because the mouseDragged method does this already.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 948
diff changeset
721 @interface DWRender : NSControl
451c71b7fdb1 Changed dw_window_capture() an dw_window_release() because the mouseDragged method does this already.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 948
diff changeset
722 {
451c71b7fdb1 Changed dw_window_capture() an dw_window_release() because the mouseDragged method does this already.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 948
diff changeset
723 void *userdata;
451c71b7fdb1 Changed dw_window_capture() an dw_window_release() because the mouseDragged method does this already.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 948
diff changeset
724 NSFont *font;
451c71b7fdb1 Changed dw_window_capture() an dw_window_release() because the mouseDragged method does this already.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 948
diff changeset
725 NSSize size;
451c71b7fdb1 Changed dw_window_capture() an dw_window_release() because the mouseDragged method does this already.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 948
diff changeset
726 }
451c71b7fdb1 Changed dw_window_capture() an dw_window_release() because the mouseDragged method does this already.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 948
diff changeset
727 -(void *)userdata;
451c71b7fdb1 Changed dw_window_capture() an dw_window_release() because the mouseDragged method does this already.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 948
diff changeset
728 -(void)setUserdata:(void *)input;
451c71b7fdb1 Changed dw_window_capture() an dw_window_release() because the mouseDragged method does this already.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 948
diff changeset
729 -(void)setFont:(NSFont *)input;
451c71b7fdb1 Changed dw_window_capture() an dw_window_release() because the mouseDragged method does this already.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 948
diff changeset
730 -(NSFont *)font;
451c71b7fdb1 Changed dw_window_capture() an dw_window_release() because the mouseDragged method does this already.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 948
diff changeset
731 -(void)setSize:(NSSize)input;
451c71b7fdb1 Changed dw_window_capture() an dw_window_release() because the mouseDragged method does this already.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 948
diff changeset
732 -(NSSize)size;
451c71b7fdb1 Changed dw_window_capture() an dw_window_release() because the mouseDragged method does this already.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 948
diff changeset
733 -(void)mouseDown:(NSEvent *)theEvent;
451c71b7fdb1 Changed dw_window_capture() an dw_window_release() because the mouseDragged method does this already.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 948
diff changeset
734 -(void)mouseUp:(NSEvent *)theEvent;
451c71b7fdb1 Changed dw_window_capture() an dw_window_release() because the mouseDragged method does this already.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 948
diff changeset
735 -(NSMenu *)menuForEvent:(NSEvent *)theEvent;
451c71b7fdb1 Changed dw_window_capture() an dw_window_release() because the mouseDragged method does this already.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 948
diff changeset
736 -(void)rightMouseUp:(NSEvent *)theEvent;
451c71b7fdb1 Changed dw_window_capture() an dw_window_release() because the mouseDragged method does this already.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 948
diff changeset
737 -(void)otherMouseDown:(NSEvent *)theEvent;
451c71b7fdb1 Changed dw_window_capture() an dw_window_release() because the mouseDragged method does this already.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 948
diff changeset
738 -(void)otherMouseUp:(NSEvent *)theEvent;
451c71b7fdb1 Changed dw_window_capture() an dw_window_release() because the mouseDragged method does this already.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 948
diff changeset
739 -(void)drawRect:(NSRect)rect;
451c71b7fdb1 Changed dw_window_capture() an dw_window_release() because the mouseDragged method does this already.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 948
diff changeset
740 -(void)keyDown:(NSEvent *)theEvent;
451c71b7fdb1 Changed dw_window_capture() an dw_window_release() because the mouseDragged method does this already.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 948
diff changeset
741 -(BOOL)isFlipped;
451c71b7fdb1 Changed dw_window_capture() an dw_window_release() because the mouseDragged method does this already.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 948
diff changeset
742 @end
451c71b7fdb1 Changed dw_window_capture() an dw_window_release() because the mouseDragged method does this already.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 948
diff changeset
743
451c71b7fdb1 Changed dw_window_capture() an dw_window_release() because the mouseDragged method does this already.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 948
diff changeset
744 @implementation DWRender
451c71b7fdb1 Changed dw_window_capture() an dw_window_release() because the mouseDragged method does this already.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 948
diff changeset
745 -(void *)userdata { return userdata; }
451c71b7fdb1 Changed dw_window_capture() an dw_window_release() because the mouseDragged method does this already.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 948
diff changeset
746 -(void)setUserdata:(void *)input { userdata = input; }
451c71b7fdb1 Changed dw_window_capture() an dw_window_release() because the mouseDragged method does this already.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 948
diff changeset
747 -(void)setFont:(NSFont *)input { [font release]; font = input; [font retain]; }
451c71b7fdb1 Changed dw_window_capture() an dw_window_release() because the mouseDragged method does this already.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 948
diff changeset
748 -(NSFont *)font { return font; }
451c71b7fdb1 Changed dw_window_capture() an dw_window_release() because the mouseDragged method does this already.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 948
diff changeset
749 -(void)setSize:(NSSize)input { size = input; }
451c71b7fdb1 Changed dw_window_capture() an dw_window_release() because the mouseDragged method does this already.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 948
diff changeset
750 -(NSSize)size { return size; }
451c71b7fdb1 Changed dw_window_capture() an dw_window_release() because the mouseDragged method does this already.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 948
diff changeset
751 -(void)mouseDown:(NSEvent *)theEvent { _event_handler(self, theEvent, 3); }
451c71b7fdb1 Changed dw_window_capture() an dw_window_release() because the mouseDragged method does this already.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 948
diff changeset
752 -(void)mouseUp:(NSEvent *)theEvent { _event_handler(self, theEvent, 4); }
451c71b7fdb1 Changed dw_window_capture() an dw_window_release() because the mouseDragged method does this already.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 948
diff changeset
753 -(NSMenu *)menuForEvent:(NSEvent *)theEvent { _event_handler(self, theEvent, 3); return nil; }
451c71b7fdb1 Changed dw_window_capture() an dw_window_release() because the mouseDragged method does this already.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 948
diff changeset
754 -(void)rightMouseUp:(NSEvent *)theEvent { _event_handler(self, theEvent, 4); }
451c71b7fdb1 Changed dw_window_capture() an dw_window_release() because the mouseDragged method does this already.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 948
diff changeset
755 -(void)otherMouseDown:(NSEvent *)theEvent { _event_handler(self, theEvent, 3); }
451c71b7fdb1 Changed dw_window_capture() an dw_window_release() because the mouseDragged method does this already.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 948
diff changeset
756 -(void)otherMouseUp:(NSEvent *)theEvent { _event_handler(self, theEvent, 4); }
451c71b7fdb1 Changed dw_window_capture() an dw_window_release() because the mouseDragged method does this already.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 948
diff changeset
757 -(void)mouseDragged:(NSEvent *)theEvent { _event_handler(self, theEvent, 5); }
451c71b7fdb1 Changed dw_window_capture() an dw_window_release() because the mouseDragged method does this already.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 948
diff changeset
758 -(void)drawRect:(NSRect)rect { _event_handler(self, nil, 7); }
451c71b7fdb1 Changed dw_window_capture() an dw_window_release() because the mouseDragged method does this already.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 948
diff changeset
759 -(void)keyDown:(NSEvent *)theEvent { _event_handler(self, theEvent, 2); }
954
cfb12bf3bb06 Fixes for some more coordinate system issues on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 953
diff changeset
760 -(BOOL)isFlipped { return YES; }
949
451c71b7fdb1 Changed dw_window_capture() an dw_window_release() because the mouseDragged method does this already.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 948
diff changeset
761 -(void)dealloc { UserData *root = userdata; _remove_userdata(&root, NULL, TRUE); [font release]; [super dealloc]; }
451c71b7fdb1 Changed dw_window_capture() an dw_window_release() because the mouseDragged method does this already.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 948
diff changeset
762 -(BOOL)acceptsFirstResponder { return YES; }
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
763 @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
764
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
765 /* Subclass for a top-level window */
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
766 @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
767 #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
768 <NSWindowDelegate>
d44bb4c4902d Fixed an error on the close event handler on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 853
diff changeset
769 #endif
654
80e253df49fd Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 653
diff changeset
770 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
771 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
772 NSSize oldsize;
654
80e253df49fd Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 653
diff changeset
773 }
653
36c6669422d2 Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 652
diff changeset
774 -(BOOL)windowShouldClose:(id)sender;
654
80e253df49fd Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 653
diff changeset
775 -(void)setMenu:(NSMenu *)input;
80e253df49fd Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 653
diff changeset
776 -(void)windowDidBecomeMain:(id)sender;
80e253df49fd Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 653
diff changeset
777 -(void)menuHandler:(id)sender;
932
ed10b5284f36 Fixes for dw_window_capture(), dw_window_release() and motion notify events on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 931
diff changeset
778 -(void)mouseDragged:(NSEvent *)theEvent;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
779 @end
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
780
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
781 @implementation DWView
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
782 -(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
783 {
1018
a943f973c3ff If there is no close event handler, the window should close by default on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 992
diff changeset
784 if(_event_handler(sender, nil, 6) > 0)
a943f973c3ff If there is no close event handler, the window should close by default on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 992
diff changeset
785 return NO;
a943f973c3ff If there is no close event handler, the window should close by default on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 992
diff changeset
786 return YES;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
787 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
788 - (void)viewDidMoveToWindow
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
789 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
790 [[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
791 [[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
792 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
793 - (void)dealloc
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
794 {
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
795 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
796 {
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
797 [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
798 }
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
799 [[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
800 [super dealloc];
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
801 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
802 - (void)windowResized:(NSNotification *)notification;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
803 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
804 NSSize size = [self frame].size;
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
805
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
806 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
807 {
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
808 _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
809 _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
810 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
811 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
812 _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
813 }
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
814 }
930
b6ee515cad8a When getting dw_window_show() called on an unresized window... trigger a relayout on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 929
diff changeset
815 -(void)showWindow
b6ee515cad8a When getting dw_window_show() called on an unresized window... trigger a relayout on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 929
diff changeset
816 {
b6ee515cad8a When getting dw_window_show() called on an unresized window... trigger a relayout on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 929
diff changeset
817 NSSize size = [self frame].size;
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
818
930
b6ee515cad8a When getting dw_window_show() called on an unresized window... trigger a relayout on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 929
diff changeset
819 if(oldsize.width == size.width && oldsize.height == size.height)
b6ee515cad8a When getting dw_window_show() called on an unresized window... trigger a relayout on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 929
diff changeset
820 {
b6ee515cad8a When getting dw_window_show() called on an unresized window... trigger a relayout on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 929
diff changeset
821 _do_resize(box, size.width, size.height);
b6ee515cad8a When getting dw_window_show() called on an unresized window... trigger a relayout on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 929
diff changeset
822 _handle_resize_events(box);
b6ee515cad8a When getting dw_window_show() called on an unresized window... trigger a relayout on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 929
diff changeset
823 }
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
824
930
b6ee515cad8a When getting dw_window_show() called on an unresized window... trigger a relayout on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 929
diff changeset
825 }
654
80e253df49fd Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 653
diff changeset
826 -(void)windowDidBecomeMain:(id)sender
80e253df49fd Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 653
diff changeset
827 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
828 if(windowmenu)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
829 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
830 [DWApp setMainMenu:windowmenu];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
831 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
832 else
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
833 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
834 [DWApp setMainMenu:DWMainMenu];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
835 }
1026
f15dc5226c35 Fixed focus event was getting ignored because wrong handle passed to the event handler on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1023
diff changeset
836 _event_handler([self window], nil, 13);
654
80e253df49fd Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 653
diff changeset
837 }
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
838 -(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
839 -(void)menuHandler:(id)sender { _event_handler(sender, nil, 8); }
949
451c71b7fdb1 Changed dw_window_capture() an dw_window_release() because the mouseDragged method does this already.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 948
diff changeset
840 -(void)mouseDragged:(NSEvent *)theEvent { _event_handler(self, theEvent, 5); }
952
abb9203adc05 Use NSCompositeSourceOver for bitblting that respects transparency of the source
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 951
diff changeset
841 -(void)mouseMoved:(NSEvent *)theEvent
abb9203adc05 Use NSCompositeSourceOver for bitblting that respects transparency of the source
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 951
diff changeset
842 {
944
cdb7a53e5515 Some motion notify changes... so it can handle events without the mouse button pressed on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 943
diff changeset
843 id hit = [self hitTest:[theEvent locationInWindow]];
952
abb9203adc05 Use NSCompositeSourceOver for bitblting that respects transparency of the source
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 951
diff changeset
844
949
451c71b7fdb1 Changed dw_window_capture() an dw_window_release() because the mouseDragged method does this already.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 948
diff changeset
845 if([hit isMemberOfClass:[DWRender class]])
952
abb9203adc05 Use NSCompositeSourceOver for bitblting that respects transparency of the source
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 951
diff changeset
846 {
abb9203adc05 Use NSCompositeSourceOver for bitblting that respects transparency of the source
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 951
diff changeset
847 _event_handler(hit, theEvent, 5);
949
451c71b7fdb1 Changed dw_window_capture() an dw_window_release() because the mouseDragged method does this already.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 948
diff changeset
848 }
944
cdb7a53e5515 Some motion notify changes... so it can handle events without the mouse button pressed on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 943
diff changeset
849 }
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
850 @end
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
851
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
852 /* Subclass for a button type */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
853 @interface DWButton : NSButton
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
854 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
855 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
856 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
857 DWBox *parent;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
858 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
859 -(void *)userdata;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
860 -(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
861 -(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
862 -(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
863 -(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
864 -(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
865 -(DWBox *)parent;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
866 @end
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
867
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
868 @implementation DWButton
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
869 -(void *)userdata { return userdata; }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
870 -(void)setUserdata:(void *)input { userdata = input; }
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
871 -(void)buttonClicked:(id)sender
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
872 {
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
873 _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
874 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
875 {
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
876 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
877 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
878 int z;
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
879
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
880 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
881 {
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
882 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
883 {
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
884 id object = thisbox->items[z].hwnd;
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
885
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
886 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
887 {
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
888 DWButton *button = object;
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
889
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
890 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
891 {
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
892 [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
893 }
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
894 }
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
895 }
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
896 }
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
897 }
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
898 }
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
899 -(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
900 -(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
901 -(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
902 -(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
903 -(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
904 @end
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
905
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
906 /* Subclass for a progress type */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
907 @interface DWPercent : NSProgressIndicator
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
908 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
909 void *userdata;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
910 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
911 -(void *)userdata;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
912 -(void)setUserdata:(void *)input;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
913 @end
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
914
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
915 @implementation DWPercent
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
916 -(void *)userdata { return userdata; }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
917 -(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
918 -(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
919 @end
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
920
837
89d4bad9c96e Initial attempt at implementing the scrollbox on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 831
diff changeset
921 /* 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
922 @interface DWScrollBox : NSScrollView
89d4bad9c96e Initial attempt at implementing the scrollbox on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 831
diff changeset
923 {
89d4bad9c96e Initial attempt at implementing the scrollbox on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 831
diff changeset
924 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
925 id box;
837
89d4bad9c96e Initial attempt at implementing the scrollbox on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 831
diff changeset
926 }
89d4bad9c96e Initial attempt at implementing the scrollbox on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 831
diff changeset
927 -(void *)userdata;
89d4bad9c96e Initial attempt at implementing the scrollbox on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 831
diff changeset
928 -(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
929 -(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
930 -(id)box;
837
89d4bad9c96e Initial attempt at implementing the scrollbox on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 831
diff changeset
931 @end
89d4bad9c96e Initial attempt at implementing the scrollbox on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 831
diff changeset
932
89d4bad9c96e Initial attempt at implementing the scrollbox on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 831
diff changeset
933 @implementation DWScrollBox
89d4bad9c96e Initial attempt at implementing the scrollbox on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 831
diff changeset
934 -(void *)userdata { return userdata; }
89d4bad9c96e Initial attempt at implementing the scrollbox on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 831
diff changeset
935 -(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
936 -(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
937 -(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
938 -(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
939 @end
89d4bad9c96e Initial attempt at implementing the scrollbox on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 831
diff changeset
940
859
80a88c91ccf6 Implemented vertical centering on text fields.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 858
diff changeset
941 /* 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
942 @interface DWTextFieldCell : NSTextFieldCell
80a88c91ccf6 Implemented vertical centering on text fields.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 858
diff changeset
943 {
860
93ac372941c4 Formatting cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 859
diff changeset
944 BOOL vcenter;
859
80a88c91ccf6 Implemented vertical centering on text fields.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 858
diff changeset
945 }
80a88c91ccf6 Implemented vertical centering on text fields.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 858
diff changeset
946 -(NSRect)drawingRectForBounds:(NSRect)theRect;
80a88c91ccf6 Implemented vertical centering on text fields.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 858
diff changeset
947 -(void)setVCenter:(BOOL)input;
80a88c91ccf6 Implemented vertical centering on text fields.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 858
diff changeset
948 @end
80a88c91ccf6 Implemented vertical centering on text fields.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 858
diff changeset
949
80a88c91ccf6 Implemented vertical centering on text fields.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 858
diff changeset
950 @implementation DWTextFieldCell
80a88c91ccf6 Implemented vertical centering on text fields.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 858
diff changeset
951 -(NSRect)drawingRectForBounds:(NSRect)theRect
80a88c91ccf6 Implemented vertical centering on text fields.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 858
diff changeset
952 {
860
93ac372941c4 Formatting cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 859
diff changeset
953 /* Get the parent's idea of where we should draw */
93ac372941c4 Formatting cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 859
diff changeset
954 NSRect newRect = [super drawingRectForBounds:theRect];
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
955
859
80a88c91ccf6 Implemented vertical centering on text fields.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 858
diff changeset
956 /* If we are being vertically centered */
80a88c91ccf6 Implemented vertical centering on text fields.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 858
diff changeset
957 if(vcenter)
80a88c91ccf6 Implemented vertical centering on text fields.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 858
diff changeset
958 {
80a88c91ccf6 Implemented vertical centering on text fields.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 858
diff changeset
959 /* Get our ideal size for current text */
80a88c91ccf6 Implemented vertical centering on text fields.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 858
diff changeset
960 NSSize textSize = [self cellSizeForBounds:theRect];
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
961
860
93ac372941c4 Formatting cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 859
diff changeset
962 /* Center that in the proposed rect */
93ac372941c4 Formatting cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 859
diff changeset
963 float heightDelta = newRect.size.height - textSize.height;
93ac372941c4 Formatting cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 859
diff changeset
964 if (heightDelta > 0)
93ac372941c4 Formatting cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 859
diff changeset
965 {
93ac372941c4 Formatting cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 859
diff changeset
966 newRect.size.height -= heightDelta;
93ac372941c4 Formatting cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 859
diff changeset
967 newRect.origin.y += (heightDelta / 2);
93ac372941c4 Formatting cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 859
diff changeset
968 }
93ac372941c4 Formatting cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 859
diff changeset
969 }
859
80a88c91ccf6 Implemented vertical centering on text fields.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 858
diff changeset
970
860
93ac372941c4 Formatting cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 859
diff changeset
971 return newRect;
859
80a88c91ccf6 Implemented vertical centering on text fields.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 858
diff changeset
972 }
80a88c91ccf6 Implemented vertical centering on text fields.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 858
diff changeset
973 -(void)setVCenter:(BOOL)input { vcenter = input; }
80a88c91ccf6 Implemented vertical centering on text fields.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 858
diff changeset
974 @end
80a88c91ccf6 Implemented vertical centering on text fields.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 858
diff changeset
975
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
976 @interface DWEntryFieldFormatter : NSFormatter
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
977 {
29d8ae25a78c Implemented dw_entryfield_set_limit() on the Mac using a custom formatter class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 886
diff changeset
978 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
979 }
29d8ae25a78c Implemented dw_entryfield_set_limit() on the Mac using a custom formatter class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 886
diff changeset
980 - (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
981 - (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
982 @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
983
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
984 /* This formatter subclass will allow us to limit
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
985 * 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
986 */
29d8ae25a78c Implemented dw_entryfield_set_limit() on the Mac using a custom formatter class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 886
diff changeset
987 @implementation DWEntryFieldFormatter
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
988 -(id)init
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
989 {
1063
2ebaea72ac95 Fix for some release calls causing issues on MacOS 10.7 Lion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1061
diff changeset
990 self = [super init];
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
991 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
992 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
993 }
29d8ae25a78c Implemented dw_entryfield_set_limit() on the Mac using a custom formatter class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 886
diff changeset
994 -(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
995 -(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
996 -(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
997 -(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
998 -(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
999 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
1000 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
1001 originalSelectedRange:(NSRange)origSelRange
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
1002 errorDescription:(NSString **)error
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
1003 {
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
1004 if([*partialStringPtr length] > maxLength)
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
1005 {
29d8ae25a78c Implemented dw_entryfield_set_limit() on the Mac using a custom formatter class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 886
diff changeset
1006 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
1007 }
29d8ae25a78c Implemented dw_entryfield_set_limit() on the Mac using a custom formatter class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 886
diff changeset
1008 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
1009 }
29d8ae25a78c Implemented dw_entryfield_set_limit() on the Mac using a custom formatter class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 886
diff changeset
1010 -(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
1011 @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
1012
651
270580896dac Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 650
diff changeset
1013 /* Subclass for a entryfield type */
270580896dac Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 650
diff changeset
1014 @interface DWEntryField : NSTextField
270580896dac Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 650
diff changeset
1015 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1016 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
1017 id clickDefault;
651
270580896dac Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 650
diff changeset
1018 }
270580896dac Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 650
diff changeset
1019 -(void *)userdata;
270580896dac Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 650
diff changeset
1020 -(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
1021 -(void)setClickDefault:(id)input;
651
270580896dac Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 650
diff changeset
1022 @end
270580896dac Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 650
diff changeset
1023
270580896dac Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 650
diff changeset
1024 @implementation DWEntryField
270580896dac Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 650
diff changeset
1025 -(void *)userdata { return userdata; }
270580896dac Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 650
diff changeset
1026 -(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
1027 -(void)setClickDefault:(id)input { clickDefault = input; }
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
1028 -(void)keyUp:(NSEvent *)theEvent
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
1029 {
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
1030 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
1031 if(clickDefault && vk == VK_RETURN)
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
1032 {
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
1033 [[self window] makeFirstResponder:clickDefault];
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
1034 } else
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
1035 {
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
1036 [super keyUp:theEvent];
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
1037 }
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
1038 }
678
0ec8edbb82cf Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 677
diff changeset
1039 -(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
1040 @end
270580896dac Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 650
diff changeset
1041
270580896dac Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 650
diff changeset
1042 /* Subclass for a entryfield password type */
270580896dac Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 650
diff changeset
1043 @interface DWEntryFieldPassword : NSSecureTextField
270580896dac Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 650
diff changeset
1044 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1045 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
1046 id clickDefault;
651
270580896dac Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 650
diff changeset
1047 }
270580896dac Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 650
diff changeset
1048 -(void *)userdata;
270580896dac Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 650
diff changeset
1049 -(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
1050 -(void)setClickDefault:(id)input;
651
270580896dac Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 650
diff changeset
1051 @end
270580896dac Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 650
diff changeset
1052
270580896dac Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 650
diff changeset
1053 @implementation DWEntryFieldPassword
270580896dac Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 650
diff changeset
1054 -(void *)userdata { return userdata; }
270580896dac Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 650
diff changeset
1055 -(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
1056 -(void)setClickDefault:(id)input { clickDefault = input; }
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
1057 -(void)keyUp:(NSEvent *)theEvent
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
1058 {
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
1059 if(clickDefault && [[theEvent charactersIgnoringModifiers] characterAtIndex:0] == VK_RETURN)
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
1060 {
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
1061 [[self window] makeFirstResponder:clickDefault];
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
1062 } else
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
1063 {
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
1064 [super keyUp:theEvent];
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
1065 }
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
1066 }
678
0ec8edbb82cf Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 677
diff changeset
1067 -(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
1068 @end
270580896dac Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 650
diff changeset
1069
652
ef0f484c6c4b Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 651
diff changeset
1070 /* Subclass for a Notebook control type */
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
1071 @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
1072 #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
1073 <NSTabViewDelegate>
17923b931393 Fixes for building for MacOS 10.5 and PPC
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 715
diff changeset
1074 #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
1075 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1076 void *userdata;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1077 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
1078 }
ef0f484c6c4b Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 651
diff changeset
1079 -(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
1080 -(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
1081 -(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
1082 -(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
1083 -(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
1084 @end
ef0f484c6c4b Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 651
diff changeset
1085
ef0f484c6c4b Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 651
diff changeset
1086 /* 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
1087 @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
1088 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1089 void *userdata;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1090 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
1091 }
ef0f484c6c4b Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 651
diff changeset
1092 -(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
1093 -(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
1094 -(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
1095 -(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
1096 @end
ef0f484c6c4b Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 651
diff changeset
1097
703
329736825f9b Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 702
diff changeset
1098 @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
1099 -(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
1100 -(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
1101 -(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
1102 -(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
1103 -(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
1104 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1105 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
1106 DWNotebookPage *page = (DWNotebookPage *)notepage;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
1107
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1108 if([object isMemberOfClass:[DWBox class]])
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1109 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1110 DWBox *view = object;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1111 Box *box = [view box];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1112 NSSize size = [view frame].size;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1113 _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
1114 _handle_resize_events(box);
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1115 }
1102
cfe7d2b6bc16 Added DW_INT_TO_POINTER/DW_UINT_TO_POINTER/DW_POINTER_TO_INT/DW_POINTER_TO_UINT macros.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1101
diff changeset
1116 _event_handler(self, DW_INT_TO_POINTER([page pageid]), 15);
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
1117 }
703
329736825f9b Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 702
diff changeset
1118 -(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
1119 @end
329736825f9b Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 702
diff changeset
1120
652
ef0f484c6c4b Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 651
diff changeset
1121 @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
1122 -(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
1123 -(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
1124 -(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
1125 -(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
1126 -(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
1127 @end
ef0f484c6c4b Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 651
diff changeset
1128
ef0f484c6c4b Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 651
diff changeset
1129 /* Subclass for a color chooser type */
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
1130 @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
1131 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1132 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
1133 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
1134 }
ef0f484c6c4b Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 651
diff changeset
1135 -(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
1136 -(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
1137 -(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
1138 @end
ef0f484c6c4b Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 651
diff changeset
1139
ef0f484c6c4b Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 651
diff changeset
1140 @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
1141 -(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
1142 -(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
1143 -(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
1144 -(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
1145 @end
ef0f484c6c4b Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 651
diff changeset
1146
1050
48f43c975533 Added dw_font_choose() on the Mac for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1048
diff changeset
1147 /* Subclass for a font chooser type */
48f43c975533 Added dw_font_choose() on the Mac for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1048
diff changeset
1148 @interface DWFontChoose : NSFontPanel
48f43c975533 Added dw_font_choose() on the Mac for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1048
diff changeset
1149 {
48f43c975533 Added dw_font_choose() on the Mac for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1048
diff changeset
1150 DWDialog *dialog;
48f43c975533 Added dw_font_choose() on the Mac for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1048
diff changeset
1151 NSFontManager *fontManager;
48f43c975533 Added dw_font_choose() on the Mac for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1048
diff changeset
1152 }
48f43c975533 Added dw_font_choose() on the Mac for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1048
diff changeset
1153 -(void)setDialog:(DWDialog *)input;
48f43c975533 Added dw_font_choose() on the Mac for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1048
diff changeset
1154 -(void)setFontManager:(NSFontManager *)input;
48f43c975533 Added dw_font_choose() on the Mac for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1048
diff changeset
1155 -(DWDialog *)dialog;
48f43c975533 Added dw_font_choose() on the Mac for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1048
diff changeset
1156 @end
48f43c975533 Added dw_font_choose() on the Mac for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1048
diff changeset
1157
48f43c975533 Added dw_font_choose() on the Mac for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1048
diff changeset
1158 @implementation DWFontChoose
1068
efaa9ceeb253 Removed test for class member for itemdata in dw_tree_item_get_data()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1067
diff changeset
1159 -(BOOL)windowShouldClose:(id)window
efaa9ceeb253 Removed test for class member for itemdata in dw_tree_item_get_data()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1067
diff changeset
1160 {
1050
48f43c975533 Added dw_font_choose() on the Mac for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1048
diff changeset
1161 DWDialog *d = dialog; dialog = nil;
48f43c975533 Added dw_font_choose() on the Mac for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1048
diff changeset
1162 NSFont *pickedfont = [fontManager selectedFont];
1068
efaa9ceeb253 Removed test for class member for itemdata in dw_tree_item_get_data()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1067
diff changeset
1163 dw_dialog_dismiss(d, pickedfont);
efaa9ceeb253 Removed test for class member for itemdata in dw_tree_item_get_data()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1067
diff changeset
1164 [window orderOut:nil];
efaa9ceeb253 Removed test for class member for itemdata in dw_tree_item_get_data()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1067
diff changeset
1165 return NO;
1050
48f43c975533 Added dw_font_choose() on the Mac for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1048
diff changeset
1166 }
48f43c975533 Added dw_font_choose() on the Mac for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1048
diff changeset
1167 -(void)setDialog:(DWDialog *)input { dialog = input; }
48f43c975533 Added dw_font_choose() on the Mac for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1048
diff changeset
1168 -(void)setFontManager:(NSFontManager *)input { fontManager = input; }
48f43c975533 Added dw_font_choose() on the Mac for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1048
diff changeset
1169 -(DWDialog *)dialog { return dialog; }
48f43c975533 Added dw_font_choose() on the Mac for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1048
diff changeset
1170 @end
48f43c975533 Added dw_font_choose() on the Mac for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1048
diff changeset
1171
652
ef0f484c6c4b Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 651
diff changeset
1172 /* Subclass for a splitbar type */
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
1173 @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
1174 #ifdef BUILDING_FOR_SNOW_LEOPARD
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
1175 <NSSplitViewDelegate>
717
17923b931393 Fixes for building for MacOS 10.5 and PPC
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 715
diff changeset
1176 #endif
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
1177 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1178 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
1179 float percent;
99002595f549 Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 676
diff changeset
1180 }
99002595f549 Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 676
diff changeset
1181 -(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
1182 -(void *)userdata;
99002595f549 Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 676
diff changeset
1183 -(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
1184 -(float)percent;
99002595f549 Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 676
diff changeset
1185 -(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
1186 @end
ef0f484c6c4b Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 651
diff changeset
1187
ef0f484c6c4b Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 651
diff changeset
1188 @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
1189 -(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
1190 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1191 NSArray *views = [self subviews];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1192 id object;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
1193
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1194 for(object in views)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1195 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1196 if([object isMemberOfClass:[DWBox class]])
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1197 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1198 DWBox *view = object;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1199 Box *box = [view box];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1200 NSSize size = [view frame].size;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1201 _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
1202 _handle_resize_events(box);
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1203 }
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
1204 }
652
ef0f484c6c4b Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 651
diff changeset
1205 }
677
99002595f549 Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 676
diff changeset
1206 -(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
1207 -(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
1208 -(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
1209 -(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
1210 -(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
1211 @end
ef0f484c6c4b Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 651
diff changeset
1212
653
36c6669422d2 Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 652
diff changeset
1213 /* 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
1214 @interface DWSlider : NSSlider
36c6669422d2 Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 652
diff changeset
1215 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1216 void *userdata;
653
36c6669422d2 Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 652
diff changeset
1217 }
36c6669422d2 Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 652
diff changeset
1218 -(void *)userdata;
36c6669422d2 Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 652
diff changeset
1219 -(void)setUserdata:(void *)input;
704
336800e9e648 Fixes to the slider control so events happen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 703
diff changeset
1220 -(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
1221 @end
36c6669422d2 Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 652
diff changeset
1222
36c6669422d2 Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 652
diff changeset
1223 @implementation DWSlider
36c6669422d2 Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 652
diff changeset
1224 -(void *)userdata { return userdata; }
36c6669422d2 Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 652
diff changeset
1225 -(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
1226 -(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
1227 -(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
1228 @end
36c6669422d2 Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 652
diff changeset
1229
36c6669422d2 Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 652
diff changeset
1230 /* 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
1231 @interface DWScrollbar : NSScroller
36c6669422d2 Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 652
diff changeset
1232 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1233 void *userdata;
933
b19e6e55fc8e Rewrote the scrollbar handler with a more accurate method and fixed a bug setting the position on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 932
diff changeset
1234 double range;
b19e6e55fc8e Rewrote the scrollbar handler with a more accurate method and fixed a bug setting the position on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 932
diff changeset
1235 double visible;
653
36c6669422d2 Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 652
diff changeset
1236 }
36c6669422d2 Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 652
diff changeset
1237 -(void *)userdata;
36c6669422d2 Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 652
diff changeset
1238 -(void)setUserdata:(void *)input;
36c6669422d2 Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 652
diff changeset
1239 -(float)range;
36c6669422d2 Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 652
diff changeset
1240 -(float)visible;
933
b19e6e55fc8e Rewrote the scrollbar handler with a more accurate method and fixed a bug setting the position on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 932
diff changeset
1241 -(void)setRange:(double)input1 andVisible:(double)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
1242 -(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
1243 @end
36c6669422d2 Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 652
diff changeset
1244
36c6669422d2 Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 652
diff changeset
1245 @implementation DWScrollbar
36c6669422d2 Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 652
diff changeset
1246 -(void *)userdata { return userdata; }
36c6669422d2 Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 652
diff changeset
1247 -(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
1248 -(float)range { return range; }
36c6669422d2 Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 652
diff changeset
1249 -(float)visible { return visible; }
933
b19e6e55fc8e Rewrote the scrollbar handler with a more accurate method and fixed a bug setting the position on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 932
diff changeset
1250 -(void)setRange:(double)input1 andVisible:(double)input2 { range = input1; visible = input2; }
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
1251 -(void)scrollerChanged:(id)sender
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
1252 {
933
b19e6e55fc8e Rewrote the scrollbar handler with a more accurate method and fixed a bug setting the position on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 932
diff changeset
1253 double max = (range - visible);
923
0ac67b62b594 Fix int to double conversion issues causing scrollbar issues on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 922
diff changeset
1254 double result = ([self doubleValue] * max);
0ac67b62b594 Fix int to double conversion issues causing scrollbar issues on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 922
diff changeset
1255 double newpos = result;
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
1256
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
1257 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
1258 {
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
1259
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
1260 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
1261 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
1262 {
86d76fc09237 Added support for scrollbar line and page scrolling. Need to check the calculations...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 706
diff changeset
1263 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
1264 }
86d76fc09237 Added support for scrollbar line and page scrolling. Need to check the calculations...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 706
diff changeset
1265 break;
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
1266
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
1267 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
1268 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
1269 {
86d76fc09237 Added support for scrollbar line and page scrolling. Need to check the calculations...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 706
diff changeset
1270 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
1271 }
86d76fc09237 Added support for scrollbar line and page scrolling. Need to check the calculations...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 706
diff changeset
1272 break;
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
1273
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
1274 case NSScrollerDecrementPage:
933
b19e6e55fc8e Rewrote the scrollbar handler with a more accurate method and fixed a bug setting the position on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 932
diff changeset
1275 newpos -= visible;
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
1276 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
1277 {
86d76fc09237 Added support for scrollbar line and page scrolling. Need to check the calculations...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 706
diff changeset
1278 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
1279 }
86d76fc09237 Added support for scrollbar line and page scrolling. Need to check the calculations...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 706
diff changeset
1280 break;
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
1281
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
1282 case NSScrollerIncrementPage:
933
b19e6e55fc8e Rewrote the scrollbar handler with a more accurate method and fixed a bug setting the position on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 932
diff changeset
1283 newpos += visible;
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
1284 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
1285 {
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
1286 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
1287 }
86d76fc09237 Added support for scrollbar line and page scrolling. Need to check the calculations...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 706
diff changeset
1288 break;
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
1289
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
1290 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
1291 ; /* 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
1292 }
933
b19e6e55fc8e Rewrote the scrollbar handler with a more accurate method and fixed a bug setting the position on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 932
diff changeset
1293 int newposi = (int)newpos;
b19e6e55fc8e Rewrote the scrollbar handler with a more accurate method and fixed a bug setting the position on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 932
diff changeset
1294 newpos = (newpos - (double)newposi) > 0.5 ? (double)(newposi + 1) : (double)newposi;
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
1295 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
1296 {
923
0ac67b62b594 Fix int to double conversion issues causing scrollbar issues on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 922
diff changeset
1297 [self setDoubleValue:(newpos/max)];
0ac67b62b594 Fix int to double conversion issues causing scrollbar issues on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 922
diff changeset
1298 }
1102
cfe7d2b6bc16 Added DW_INT_TO_POINTER/DW_UINT_TO_POINTER/DW_POINTER_TO_INT/DW_POINTER_TO_UINT macros.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1101
diff changeset
1299 _event_handler(self, DW_INT_TO_POINTER((int)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
1300 }
678
0ec8edbb82cf Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 677
diff changeset
1301 -(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
1302 @end
36c6669422d2 Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 652
diff changeset
1303
36c6669422d2 Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 652
diff changeset
1304 /* Subclass for a MLE type */
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
1305 @interface DWMLE : NSTextView
653
36c6669422d2 Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 652
diff changeset
1306 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1307 void *userdata;
653
36c6669422d2 Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 652
diff changeset
1308 }
36c6669422d2 Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 652
diff changeset
1309 -(void *)userdata;
36c6669422d2 Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 652
diff changeset
1310 -(void)setUserdata:(void *)input;
36c6669422d2 Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 652
diff changeset
1311 @end
36c6669422d2 Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 652
diff changeset
1312
36c6669422d2 Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 652
diff changeset
1313 @implementation DWMLE
36c6669422d2 Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 652
diff changeset
1314 -(void *)userdata { return userdata; }
36c6669422d2 Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 652
diff changeset
1315 -(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
1316 -(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
1317 @end
36c6669422d2 Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 652
diff changeset
1318
1206
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1319 /* Subclass NSTextFieldCell for displaying image and text */
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1320 @interface DWImageAndTextCell : NSTextFieldCell
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1321 {
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1322 @private
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1323 NSImage *image;
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1324 }
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1325 -(void)setImage:(NSImage *)anImage;
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1326 -(NSImage *)image;
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1327 -(void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView;
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1328 -(NSSize)cellSize;
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1329 @end
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1330
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1331 @implementation DWImageAndTextCell
1210
5a016a5a7412 Slight change in design behavior for dw_container_set_row_bg()...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1206
diff changeset
1332 -(void)dealloc
1206
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1333 {
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1334 [image release];
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1335 image = nil;
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1336 [super dealloc];
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1337 }
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1338 -copyWithZone:(NSZone *)zone
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1339 {
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1340 DWImageAndTextCell *cell = (DWImageAndTextCell *)[super copyWithZone:zone];
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1341 cell->image = [image retain];
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1342 return cell;
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1343 }
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1344 -(void)setImage:(NSImage *)anImage
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1345 {
1210
5a016a5a7412 Slight change in design behavior for dw_container_set_row_bg()...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1206
diff changeset
1346 if(anImage != image)
1206
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1347 {
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1348 [image release];
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1349 image = [anImage retain];
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1350 }
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1351 }
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1352 -(NSImage *)image
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1353 {
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1354 return [[image retain] autorelease];
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1355 }
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1356 -(NSRect)imageFrameForCellFrame:(NSRect)cellFrame
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1357 {
1210
5a016a5a7412 Slight change in design behavior for dw_container_set_row_bg()...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1206
diff changeset
1358 if(image != nil)
1206
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1359 {
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1360 NSRect imageFrame;
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1361 imageFrame.size = [image size];
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1362 imageFrame.origin = cellFrame.origin;
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1363 imageFrame.origin.x += 3;
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1364 imageFrame.origin.y += ceil((cellFrame.size.height - imageFrame.size.height) / 2);
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1365 return imageFrame;
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1366 }
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1367 else
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1368 return NSZeroRect;
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1369 }
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1370 -(void)editWithFrame:(NSRect)aRect inView:(NSView *)controlView editor:(NSText *)textObj delegate:(id)anObject event:(NSEvent *)theEvent
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1371 {
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1372 NSRect textFrame, imageFrame;
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1373 NSDivideRect (aRect, &imageFrame, &textFrame, 3 + [image size].width, NSMinXEdge);
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1374 [super editWithFrame: textFrame inView: controlView editor:textObj delegate:anObject event: theEvent];
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1375 }
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1376 -(void)selectWithFrame:(NSRect)aRect inView:(NSView *)controlView editor:(NSText *)textObj delegate:(id)anObject start:(NSInteger)selStart length:(NSInteger)selLength
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1377 {
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1378 NSRect textFrame, imageFrame;
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1379 NSDivideRect (aRect, &imageFrame, &textFrame, 3 + [image size].width, NSMinXEdge);
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1380 [super selectWithFrame: textFrame inView: controlView editor:textObj delegate:anObject start:selStart length:selLength];
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1381 }
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1382 -(void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1383 {
1210
5a016a5a7412 Slight change in design behavior for dw_container_set_row_bg()...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1206
diff changeset
1384 if(image != nil)
5a016a5a7412 Slight change in design behavior for dw_container_set_row_bg()...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1206
diff changeset
1385 {
1206
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1386 NSSize imageSize;
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1387 NSRect imageFrame;
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1388
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1389 imageSize = [image size];
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1390 NSDivideRect(cellFrame, &imageFrame, &cellFrame, 3 + imageSize.width, NSMinXEdge);
1210
5a016a5a7412 Slight change in design behavior for dw_container_set_row_bg()...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1206
diff changeset
1391 if ([self drawsBackground])
5a016a5a7412 Slight change in design behavior for dw_container_set_row_bg()...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1206
diff changeset
1392 {
1206
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1393 [[self backgroundColor] set];
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1394 NSRectFill(imageFrame);
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1395 }
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1396 imageFrame.origin.x += 3;
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1397 imageFrame.size = imageSize;
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1398
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1399 if ([controlView isFlipped])
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1400 imageFrame.origin.y += ceil((cellFrame.size.height + imageFrame.size.height) / 2);
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1401 else
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1402 imageFrame.origin.y += ceil((cellFrame.size.height - imageFrame.size.height) / 2);
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1403
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1404 [image compositeToPoint:imageFrame.origin operation:NSCompositeSourceOver];
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1405 }
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1406 [super drawWithFrame:cellFrame inView:controlView];
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1407 }
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1408 -(NSSize)cellSize
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1409 {
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1410 NSSize cellSize = [super cellSize];
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1411 cellSize.width += (image ? [image size].width : 0) + 3;
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1412 return cellSize;
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1413 }
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1414 @end
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1415
655
27eb39d2577b Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 654
diff changeset
1416 /* Subclass for a Container/List type */
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
1417 @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
1418 #ifdef BUILDING_FOR_SNOW_LEOPARD
813
7fa26d8cc8d0 Fix for column click handler not working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 812
diff changeset
1419 <NSTableViewDataSource,NSTableViewDelegate>
717
17923b931393 Fixes for building for MacOS 10.5 and PPC
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 715
diff changeset
1420 #endif
654
80e253df49fd Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 653
diff changeset
1421 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1422 void *userdata;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1423 NSMutableArray *tvcols;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1424 NSMutableArray *data;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1425 NSMutableArray *types;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1426 NSPointerArray *titles;
1206
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1427 NSColor *fgcolor, *oddcolor, *evencolor;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1428 int lastAddPoint, lastQueryPoint;
668
7b99731c6484 Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 667
diff changeset
1429 id scrollview;
813
7fa26d8cc8d0 Fix for column click handler not working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 812
diff changeset
1430 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
1431 }
0502e5b6743b Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 657
diff changeset
1432 -(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
1433 -(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
1434 -(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
1435 -(void *)userdata;
80e253df49fd Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 653
diff changeset
1436 -(void)setUserdata:(void *)input;
813
7fa26d8cc8d0 Fix for column click handler not working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 812
diff changeset
1437 -(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
1438 -(int)filesystem;
668
7b99731c6484 Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 667
diff changeset
1439 -(id)scrollview;
7b99731c6484 Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 667
diff changeset
1440 -(void)setScrollview:(id)input;
657
f31a47b055f8 Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 656
diff changeset
1441 -(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
1442 -(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
1443 -(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
1444 -(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
1445 -(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
1446 -(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
1447 -(void)removeRow:(int)row;
659
756015085da7 Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 658
diff changeset
1448 -(void)setRow:(int)row title:(void *)input;
756015085da7 Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 658
diff changeset
1449 -(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
1450 -(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
1451 -(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
1452 -(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
1453 -(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
1454 -(void)setLastQueryPoint:(int)input;
657
f31a47b055f8 Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 656
diff changeset
1455 -(void)clear;
f31a47b055f8 Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 656
diff changeset
1456 -(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
1457 -(void)optimize;
810
746cdd753e7a Added coloring support for the Container/Tree/Listbox controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 809
diff changeset
1458 -(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
1459 -(void)doubleClicked:(id)sender;
829
f7b6c88bac47 Implemented Enter/Return triggering the item enter event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 828
diff changeset
1460 -(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
1461 -(void)tableView:(NSTableView *)tableView didClickTableColumn:(NSTableColumn *)tableColumn;
659
756015085da7 Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 658
diff changeset
1462 -(void)selectionChanged:(id)sender;
756015085da7 Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 658
diff changeset
1463 -(NSMenu *)menuForEvent:(NSEvent *)event;
654
80e253df49fd Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 653
diff changeset
1464 @end
80e253df49fd Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 653
diff changeset
1465
80e253df49fd Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 653
diff changeset
1466 @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
1467 -(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
1468 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1469 if(tvcols && data)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1470 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1471 int cols = (int)[tvcols count];
1134
41a93f9896e3 Avoid an array out of bounds after container clear on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1133
diff changeset
1472 int total = (int)[data count];
41a93f9896e3 Avoid an array out of bounds after container clear on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1133
diff changeset
1473 if(cols && total)
41a93f9896e3 Avoid an array out of bounds after container clear on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1133
diff changeset
1474 {
41a93f9896e3 Avoid an array out of bounds after container clear on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1133
diff changeset
1475 return total / cols;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1476 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1477 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1478 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
1479 }
0502e5b6743b Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 657
diff changeset
1480 -(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
1481 {
1134
41a93f9896e3 Avoid an array out of bounds after container clear on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1133
diff changeset
1482 if(tvcols && data)
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1483 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1484 int z, col = -1;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1485 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
1486
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1487 for(z=0;z<count;z++)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1488 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1489 if([tvcols objectAtIndex:z] == aCol)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1490 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1491 col = z;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1492 break;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1493 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1494 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1495 if(col != -1)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1496 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1497 int index = (int)(aRow * count) + col;
1134
41a93f9896e3 Avoid an array out of bounds after container clear on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1133
diff changeset
1498 if(index < [data count])
41a93f9896e3 Avoid an array out of bounds after container clear on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1133
diff changeset
1499 {
41a93f9896e3 Avoid an array out of bounds after container clear on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1133
diff changeset
1500 id this = [data objectAtIndex:index];
41a93f9896e3 Avoid an array out of bounds after container clear on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1133
diff changeset
1501 return ([this isKindOfClass:[NSNull class]]) ? nil : this;
41a93f9896e3 Avoid an array out of bounds after container clear on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1133
diff changeset
1502 }
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1503 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1504 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1505 return nil;
657
f31a47b055f8 Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 656
diff changeset
1506 }
708
5fe2ca5ef88b Fixes for container event handling. Also made container/listbox cells non-editable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 707
diff changeset
1507 -(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
1508 -(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
1509 -(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
1510 -(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
1511 -(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
1512 -(id)scrollview { return scrollview; }
17923b931393 Fixes for building for MacOS 10.5 and PPC
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 715
diff changeset
1513 -(void)setScrollview:(id)input { scrollview = input; }
657
f31a47b055f8 Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 656
diff changeset
1514 -(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
1515 -(NSTableColumn *)getColumn:(int)col { if(tvcols) { return [tvcols objectAtIndex:col]; } return nil; }
1206
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1516 -(void)setRowBgOdd:(unsigned long)oddcol andEven:(unsigned long)evencol
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1517 {
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1518 NSColor *oldodd = oddcolor;
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1519 NSColor *oldeven = evencolor;
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1520 unsigned long _odd = _get_color(oddcol);
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1521 unsigned long _even = _get_color(evencol);
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1522
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1523 /* Get the NSColor for non-default colors */
1210
5a016a5a7412 Slight change in design behavior for dw_container_set_row_bg()...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1206
diff changeset
1524 if(oddcol != DW_RGB_TRANSPARENT)
1206
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1525 oddcolor = [[NSColor colorWithDeviceRed: DW_RED_VALUE(_odd)/255.0 green: DW_GREEN_VALUE(_odd)/255.0 blue: DW_BLUE_VALUE(_odd)/255.0 alpha: 1] retain];
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1526 else
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1527 oddcolor = NULL;
1210
5a016a5a7412 Slight change in design behavior for dw_container_set_row_bg()...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1206
diff changeset
1528 if(evencol != DW_RGB_TRANSPARENT)
1206
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1529 evencolor = [[NSColor colorWithDeviceRed: DW_RED_VALUE(_even)/255.0 green: DW_GREEN_VALUE(_even)/255.0 blue: DW_BLUE_VALUE(_even)/255.0 alpha: 1] retain];
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1530 else
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1531 evencolor = NULL;
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1532 [oldodd release];
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1533 [oldeven release];
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1534 }
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
1535 -(int)insertRow:(NSArray *)input at:(int)index
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
1536 {
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
1537 if(data)
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
1538 {
687
5dde8d34bc69 Implemented dw_listbox_insert for containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 686
diff changeset
1539 unsigned long start = [tvcols count] * index;
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
1540 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
1541 if(index < lastAddPoint)
5dde8d34bc69 Implemented dw_listbox_insert for containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 686
diff changeset
1542 {
5dde8d34bc69 Implemented dw_listbox_insert for containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 686
diff changeset
1543 lastAddPoint++;
5dde8d34bc69 Implemented dw_listbox_insert for containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 686
diff changeset
1544 }
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
1545 [data insertObjects:input atIndexes:set];
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
1546 [titles insertPointer:NULL atIndex:index];
687
5dde8d34bc69 Implemented dw_listbox_insert for containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 686
diff changeset
1547 [set release];
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
1548 return (int)[titles count];
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
1549 }
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
1550 return 0;
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
1551 }
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
1552 -(int)addRow:(NSArray *)input
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
1553 {
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
1554 if(data)
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
1555 {
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
1556 lastAddPoint = (int)[titles count];
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
1557 [data addObjectsFromArray:input];
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
1558 [titles addPointer:NULL];
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
1559 return (int)[titles count];
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
1560 }
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
1561 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
1562 }
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
1563 -(int)addRows:(int)number
657
f31a47b055f8 Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 656
diff changeset
1564 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1565 if(tvcols)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1566 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1567 int count = (int)(number * [tvcols count]);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1568 int z;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
1569
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1570 lastAddPoint = (int)[titles count];
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
1571
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1572 for(z=0;z<count;z++)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1573 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1574 [data addObject:[NSNull null]];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1575 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1576 for(z=0;z<number;z++)
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 [titles addPointer:NULL];
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 (int)[titles count];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1581 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1582 return 0;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
1583 }
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
1584 -(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
1585 {
1206
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1586 DWImageAndTextCell *bcell = cell;
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1587
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1588 /* Handle drawing image and text if necessary */
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1589 if([cell isMemberOfClass:[DWImageAndTextCell class]])
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
1590 {
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
1591 int index = (int)(row * [tvcols count]);
1206
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1592 DWImageAndTextCell *browsercell = [data objectAtIndex:index];
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
1593 NSImage *img = [browsercell image];
1206
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1594 [bcell setImage:img];
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1595 }
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1596 /* Handle drawing alternating row colors if enabled */
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1597 if ((row % 2) == 0)
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1598 {
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1599 if(evencolor)
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1600 {
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1601 [bcell setDrawsBackground:YES];
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1602 [bcell setBackgroundColor:evencolor];
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1603 }
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1604 else
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1605 [bcell setDrawsBackground:NO];
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1606 }
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1607 else
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1608 {
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1609 if(oddcolor)
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1610 {
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1611 [bcell setDrawsBackground:YES];
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1612 [bcell setBackgroundColor:oddcolor];
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1613 }
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1614 else
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1615 [bcell setDrawsBackground:NO];
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
1616 }
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
1617 }
657
f31a47b055f8 Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 656
diff changeset
1618 -(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
1619 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1620 if(tvcols && input)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1621 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1622 int index = (int)(row * [tvcols count]) + col;
934
13384e89964c Put in a bounds check just on a hunch when editing containers on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 933
diff changeset
1623 if(index < [data count])
13384e89964c Put in a bounds check just on a hunch when editing containers on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 933
diff changeset
1624 {
13384e89964c Put in a bounds check just on a hunch when editing containers on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 933
diff changeset
1625 [data replaceObjectAtIndex:index withObject:input];
13384e89964c Put in a bounds check just on a hunch when editing containers on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 933
diff changeset
1626 }
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1627 }
657
f31a47b055f8 Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 656
diff changeset
1628 }
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
1629 -(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
1630 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1631 if(tvcols)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1632 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1633 int z, start, end;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1634 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
1635
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1636 start = count * row;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1637 end = start + count;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
1638
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1639 for(z=start;z<end;z++)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1640 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1641 [data removeObjectAtIndex:z];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1642 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1643 [titles removePointerAtIndex:row];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1644 if(lastAddPoint > 0 && lastAddPoint < row)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1645 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1646 lastAddPoint--;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1647 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1648 }
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
1649 }
659
756015085da7 Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 658
diff changeset
1650 -(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
1651 -(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
1652 -(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
1653 -(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
1654 -(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
1655 -(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
1656 -(void)setLastQueryPoint:(int)input { lastQueryPoint = input; }
659
756015085da7 Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 658
diff changeset
1657 -(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
1658 -(void)setup
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
1659 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1660 tvcols = [[[NSMutableArray alloc] init] retain];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1661 data = [[[NSMutableArray alloc] init] retain];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1662 types = [[[NSMutableArray alloc] init] retain];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1663 titles = [[NSPointerArray pointerArrayWithWeakObjects] retain];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1664 [[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
1665 }
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
1666 -(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
1667 {
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
1668 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
1669 {
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
1670 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
1671 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
1672 int rowcount = (int)[self numberOfRowsInTableView:self];
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
1673
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
1674 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
1675 {
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
1676 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
1677 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
1678 {
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
1679 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
1680 {
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
1681 int x;
1135
6828a01ecf3c Include the header column text width during container optimize on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1134
diff changeset
1682 NSCell *colcell = [column headerCell];
6828a01ecf3c Include the header column text width during container optimize on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1134
diff changeset
1683 int width = [colcell cellSize].width;
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
1684
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
1685 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
1686 {
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
1687 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
1688 int thiswidth = [cell cellSize].width;
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
1689
866
ba9d38b8d0bc Added code to check the image size inside the cell during optimize.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 864
diff changeset
1690 /* 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
1691 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
1692 {
ba9d38b8d0bc Added code to check the image size inside the cell during optimize.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 864
diff changeset
1693 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
1694 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
1695 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
1696 {
ba9d38b8d0bc Added code to check the image size inside the cell during optimize.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 864
diff changeset
1697 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
1698 }
ba9d38b8d0bc Added code to check the image size inside the cell during optimize.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 864
diff changeset
1699 }
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
1700
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
1701 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
1702 {
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
1703 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
1704 }
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
1705 }
866
ba9d38b8d0bc Added code to check the image size inside the cell during optimize.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 864
diff changeset
1706 /* 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
1707 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
1708 {
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
1709 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
1710 }
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
1711 /* 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
1712 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
1713 {
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
1714 [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
1715 }
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
1716 }
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
1717 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
1718 {
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
1719 [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
1720 }
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
1721 }
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
1722 }
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
1723 }
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
1724 }
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
1725 -(void)setForegroundColor:(NSColor *)input
810
746cdd753e7a Added coloring support for the Container/Tree/Listbox controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 809
diff changeset
1726 {
746cdd753e7a Added coloring support for the Container/Tree/Listbox controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 809
diff changeset
1727 int z, count = (int)[tvcols count];
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
1728
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
1729 fgcolor = input;
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
1730 [fgcolor retain];
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
1731
810
746cdd753e7a Added coloring support for the Container/Tree/Listbox controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 809
diff changeset
1732 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
1733 {
746cdd753e7a Added coloring support for the Container/Tree/Listbox controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 809
diff changeset
1734 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
1735 NSTextFieldCell *cell = [tableColumn dataCell];
746cdd753e7a Added coloring support for the Container/Tree/Listbox controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 809
diff changeset
1736 [cell setTextColor:fgcolor];
746cdd753e7a Added coloring support for the Container/Tree/Listbox controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 809
diff changeset
1737 }
746cdd753e7a Added coloring support for the Container/Tree/Listbox controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 809
diff changeset
1738 }
708
5fe2ca5ef88b Fixes for container event handling. Also made container/listbox cells non-editable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 707
diff changeset
1739 -(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
1740 {
5fe2ca5ef88b Fixes for container event handling. Also made container/listbox cells non-editable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 707
diff changeset
1741 /* Handler for container class */
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1742 _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
1743 }
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
1744 -(void)keyUp:(NSEvent *)theEvent
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
1745 {
829
f7b6c88bac47 Implemented Enter/Return triggering the item enter event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 828
diff changeset
1746 if([[theEvent charactersIgnoringModifiers] characterAtIndex:0] == VK_RETURN)
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
1747 {
829
f7b6c88bac47 Implemented Enter/Return triggering the item enter event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 828
diff changeset
1748 _event_handler(self, (NSEvent *)[self getRowTitle:(int)[self selectedRow]], 9);
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
1749 }
829
f7b6c88bac47 Implemented Enter/Return triggering the item enter event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 828
diff changeset
1750 [super keyUp:theEvent];
f7b6c88bac47 Implemented Enter/Return triggering the item enter event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 828
diff changeset
1751 }
f7b6c88bac47 Implemented Enter/Return triggering the item enter event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 828
diff changeset
1752
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
1753 -(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
1754 {
7fa26d8cc8d0 Fix for column click handler not working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 812
diff changeset
1755 NSUInteger index = [tvcols indexOfObject:tableColumn];
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
1756
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
1757 /* Handler for column click class */
813
7fa26d8cc8d0 Fix for column click handler not working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 812
diff changeset
1758 _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
1759 }
659
756015085da7 Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 658
diff changeset
1760 -(void)selectionChanged:(id)sender
756015085da7 Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 658
diff changeset
1761 {
703
329736825f9b Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 702
diff changeset
1762 /* Handler for container class */
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1763 _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
1764 /* Handler for listbox class */
1102
cfe7d2b6bc16 Added DW_INT_TO_POINTER/DW_UINT_TO_POINTER/DW_POINTER_TO_INT/DW_POINTER_TO_UINT macros.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1101
diff changeset
1765 _event_handler(self, DW_INT_TO_POINTER((int)[self selectedRow]), 11);
659
756015085da7 Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 658
diff changeset
1766 }
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
1767 -(NSMenu *)menuForEvent:(NSEvent *)event
659
756015085da7 Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 658
diff changeset
1768 {
710
78460ff977c1 Finishing up tree event/signal handlers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 709
diff changeset
1769 int row;
78460ff977c1 Finishing up tree event/signal handlers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 709
diff changeset
1770 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
1771 row = (int)[self rowAtPoint:where];
78460ff977c1 Finishing up tree event/signal handlers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 709
diff changeset
1772 _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
1773 return nil;
659
756015085da7 Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 658
diff changeset
1774 }
678
0ec8edbb82cf Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 677
diff changeset
1775 -(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
1776 @end
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1777
1100
13ea7575d9e8 Fixed a problem with dw_tree_item_delete() due to earlier tree data storage changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1099
diff changeset
1778 /* Dive into the tree freeing all desired child nodes */
1065
25e0317335fc Switched from using NSPointerArray to NSMutableArray on Mac to avoid the duplicate string crashes
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1064
diff changeset
1779 void _free_tree_recurse(NSMutableArray *node, NSMutableArray *item)
25e0317335fc Switched from using NSPointerArray to NSMutableArray on Mac to avoid the duplicate string crashes
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1064
diff changeset
1780 {
1100
13ea7575d9e8 Fixed a problem with dw_tree_item_delete() due to earlier tree data storage changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1099
diff changeset
1781 if(node && ([node isKindOfClass:[NSArray class]]))
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
1782 {
de4aa126fb2f Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 681
diff changeset
1783 int count = (int)[node count];
1100
13ea7575d9e8 Fixed a problem with dw_tree_item_delete() due to earlier tree data storage changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1099
diff changeset
1784 NSInteger index = -1;
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
1785 int z;
1128
7d7535f6bc4e Added ability to set background color of MLE; setting foreground still outstanding.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1120
diff changeset
1786
1100
13ea7575d9e8 Fixed a problem with dw_tree_item_delete() due to earlier tree data storage changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1099
diff changeset
1787 if(item)
13ea7575d9e8 Fixed a problem with dw_tree_item_delete() due to earlier tree data storage changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1099
diff changeset
1788 index = [node indexOfObject:item];
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
1789
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
1790 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
1791 {
1065
25e0317335fc Switched from using NSPointerArray to NSMutableArray on Mac to avoid the duplicate string crashes
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1064
diff changeset
1792 NSMutableArray *pnt = [node objectAtIndex:z];
25e0317335fc Switched from using NSPointerArray to NSMutableArray on Mac to avoid the duplicate string crashes
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1064
diff changeset
1793 NSMutableArray *children = nil;
1068
efaa9ceeb253 Removed test for class member for itemdata in dw_tree_item_get_data()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1067
diff changeset
1794
1100
13ea7575d9e8 Fixed a problem with dw_tree_item_delete() due to earlier tree data storage changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1099
diff changeset
1795 if(pnt && [pnt isKindOfClass:[NSArray class]])
1065
25e0317335fc Switched from using NSPointerArray to NSMutableArray on Mac to avoid the duplicate string crashes
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1064
diff changeset
1796 {
25e0317335fc Switched from using NSPointerArray to NSMutableArray on Mac to avoid the duplicate string crashes
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1064
diff changeset
1797 children = (NSMutableArray *)[pnt objectAtIndex:3];
25e0317335fc Switched from using NSPointerArray to NSMutableArray on Mac to avoid the duplicate string crashes
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1064
diff changeset
1798 }
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
1799
1100
13ea7575d9e8 Fixed a problem with dw_tree_item_delete() due to earlier tree data storage changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1099
diff changeset
1800 if(z == index)
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
1801 {
1048
70bad8a91370 Fix for dw_tree_item_delete() not working if there are no child nodes on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1045
diff changeset
1802 _free_tree_recurse(children, NULL);
70bad8a91370 Fix for dw_tree_item_delete() not working if there are no child nodes on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1045
diff changeset
1803 [node removeObjectAtIndex:z];
70bad8a91370 Fix for dw_tree_item_delete() not working if there are no child nodes on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1045
diff changeset
1804 count = (int)[node count];
1100
13ea7575d9e8 Fixed a problem with dw_tree_item_delete() due to earlier tree data storage changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1099
diff changeset
1805 index = -1;
1048
70bad8a91370 Fix for dw_tree_item_delete() not working if there are no child nodes on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1045
diff changeset
1806 z--;
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
1807 }
1048
70bad8a91370 Fix for dw_tree_item_delete() not working if there are no child nodes on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1045
diff changeset
1808 else if(item == NULL)
70bad8a91370 Fix for dw_tree_item_delete() not working if there are no child nodes on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1045
diff changeset
1809 {
1065
25e0317335fc Switched from using NSPointerArray to NSMutableArray on Mac to avoid the duplicate string crashes
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1064
diff changeset
1810 NSString *oldstr = [pnt objectAtIndex:1];
1048
70bad8a91370 Fix for dw_tree_item_delete() not working if there are no child nodes on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1045
diff changeset
1811 [oldstr release];
70bad8a91370 Fix for dw_tree_item_delete() not working if there are no child nodes on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1045
diff changeset
1812 _free_tree_recurse(children, item);
70bad8a91370 Fix for dw_tree_item_delete() not working if there are no child nodes on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1045
diff changeset
1813 }
70bad8a91370 Fix for dw_tree_item_delete() not working if there are no child nodes on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1045
diff changeset
1814 else
70bad8a91370 Fix for dw_tree_item_delete() not working if there are no child nodes on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1045
diff changeset
1815 _free_tree_recurse(children, item);
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
1816 }
de4aa126fb2f Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 681
diff changeset
1817 }
de4aa126fb2f Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 681
diff changeset
1818 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
1819 {
de4aa126fb2f Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 681
diff changeset
1820 [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
1821 }
de4aa126fb2f Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 681
diff changeset
1822 }
de4aa126fb2f Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 681
diff changeset
1823
680
db315779a283 Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 679
diff changeset
1824 /* Subclass for a Tree type */
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
1825 @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
1826 #ifdef BUILDING_FOR_SNOW_LEOPARD
813
7fa26d8cc8d0 Fix for column click handler not working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 812
diff changeset
1827 <NSOutlineViewDataSource,NSOutlineViewDelegate>
717
17923b931393 Fixes for building for MacOS 10.5 and PPC
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 715
diff changeset
1828 #endif
680
db315779a283 Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 679
diff changeset
1829 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1830 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
1831 NSTableColumn *treecol;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1832 NSMutableArray *data;
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
1833 /* 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
1834 * 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
1835 */
db315779a283 Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 679
diff changeset
1836 id scrollview;
810
746cdd753e7a Added coloring support for the Container/Tree/Listbox controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 809
diff changeset
1837 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
1838 }
db315779a283 Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 679
diff changeset
1839 -(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
1840 -(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
1841 -(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
1842 -(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
1843 -(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
1844 -(BOOL)outlineView:(NSOutlineView *)outlineView shouldEditTableColumn:(NSTableColumn *)tableColumn item:(id)item;
1065
25e0317335fc Switched from using NSPointerArray to NSMutableArray on Mac to avoid the duplicate string crashes
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1064
diff changeset
1845 -(void)addTree:(NSMutableArray *)item and:(NSMutableArray *)parent after:(NSMutableArray *)after;
680
db315779a283 Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 679
diff changeset
1846 -(void *)userdata;
db315779a283 Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 679
diff changeset
1847 -(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
1848 -(void)treeSelectionChanged:(id)sender;
722
5a8d5161651d Implemented tree expand event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 721
diff changeset
1849 -(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
1850 -(NSScrollView *)scrollview;
db315779a283 Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 679
diff changeset
1851 -(void)setScrollview:(NSScrollView *)input;
1065
25e0317335fc Switched from using NSPointerArray to NSMutableArray on Mac to avoid the duplicate string crashes
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1064
diff changeset
1852 -(void)deleteNode:(NSMutableArray *)item;
810
746cdd753e7a Added coloring support for the Container/Tree/Listbox controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 809
diff changeset
1853 -(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
1854 -(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
1855 @end
db315779a283 Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 679
diff changeset
1856
db315779a283 Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 679
diff changeset
1857 @implementation DWTree
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
1858 -(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
1859 {
db315779a283 Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 679
diff changeset
1860 self = [super init];
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
1861
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
1862 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
1863 {
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
1864 treecol = [[NSTableColumn alloc] init];
1206
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1865 DWImageAndTextCell *browsercell = [[[DWImageAndTextCell alloc] init] autorelease];
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
1866 [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
1867 [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
1868 [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
1869 [[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
1870 [[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
1871 }
db315779a283 Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 679
diff changeset
1872 return self;
db315779a283 Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 679
diff changeset
1873 }
db315779a283 Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 679
diff changeset
1874 -(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
1875 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1876 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
1877 {
1065
25e0317335fc Switched from using NSPointerArray to NSMutableArray on Mac to avoid the duplicate string crashes
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1064
diff changeset
1878 NSMutableArray *array = [item objectAtIndex:3];
25e0317335fc Switched from using NSPointerArray to NSMutableArray on Mac to avoid the duplicate string crashes
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1064
diff changeset
1879 return ([array isKindOfClass:[NSNull class]]) ? nil : [array objectAtIndex:index];
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1880 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1881 else
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 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
1884 }
db315779a283 Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 679
diff changeset
1885 }
db315779a283 Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 679
diff changeset
1886 -(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
1887 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1888 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
1889 }
db315779a283 Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 679
diff changeset
1890 -(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
1891 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1892 if(item)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1893 {
1065
25e0317335fc Switched from using NSPointerArray to NSMutableArray on Mac to avoid the duplicate string crashes
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1064
diff changeset
1894 if([item isKindOfClass:[NSMutableArray class]])
25e0317335fc Switched from using NSPointerArray to NSMutableArray on Mac to avoid the duplicate string crashes
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1064
diff changeset
1895 {
25e0317335fc Switched from using NSPointerArray to NSMutableArray on Mac to avoid the duplicate string crashes
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1064
diff changeset
1896 NSMutableArray *array = [item objectAtIndex:3];
25e0317335fc Switched from using NSPointerArray to NSMutableArray on Mac to avoid the duplicate string crashes
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1064
diff changeset
1897 return ([array isKindOfClass:[NSNull class]]) ? 0 : (int)[array count];
680
db315779a283 Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 679
diff changeset
1898 }
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1899 else
680
db315779a283 Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 679
diff changeset
1900 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1901 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
1902 }
db315779a283 Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 679
diff changeset
1903 }
db315779a283 Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 679
diff changeset
1904 else
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
1905 {
680
db315779a283 Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 679
diff changeset
1906 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
1907 }
db315779a283 Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 679
diff changeset
1908 }
db315779a283 Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 679
diff changeset
1909 -(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
1910 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1911 if(item)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1912 {
1065
25e0317335fc Switched from using NSPointerArray to NSMutableArray on Mac to avoid the duplicate string crashes
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1064
diff changeset
1913 if([item isKindOfClass:[NSMutableArray class]])
25e0317335fc Switched from using NSPointerArray to NSMutableArray on Mac to avoid the duplicate string crashes
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1064
diff changeset
1914 {
25e0317335fc Switched from using NSPointerArray to NSMutableArray on Mac to avoid the duplicate string crashes
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1064
diff changeset
1915 NSMutableArray *this = (NSMutableArray *)item;
25e0317335fc Switched from using NSPointerArray to NSMutableArray on Mac to avoid the duplicate string crashes
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1064
diff changeset
1916 return [this objectAtIndex:1];
680
db315779a283 Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 679
diff changeset
1917 }
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1918 else
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
1919 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1920 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
1921 }
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1922 }
680
db315779a283 Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 679
diff changeset
1923 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
1924 }
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
1925 -(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
1926 {
1206
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1927 if([cell isMemberOfClass:[DWImageAndTextCell class]])
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
1928 {
1065
25e0317335fc Switched from using NSPointerArray to NSMutableArray on Mac to avoid the duplicate string crashes
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1064
diff changeset
1929 NSMutableArray *this = (NSMutableArray *)item;
25e0317335fc Switched from using NSPointerArray to NSMutableArray on Mac to avoid the duplicate string crashes
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1064
diff changeset
1930 NSImage *img = [this objectAtIndex:0];
1067
6ca1132a240e Allow tree nodes without icons using the new NSMutableArray tree code on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1065
diff changeset
1931 if([img isKindOfClass:[NSImage class]])
1206
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1932 [(DWImageAndTextCell*)cell setImage:img];
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
1933 }
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
1934 }
710
78460ff977c1 Finishing up tree event/signal handlers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 709
diff changeset
1935 -(BOOL)outlineView:(NSOutlineView *)outlineView shouldEditTableColumn:(NSTableColumn *)tableColumn item:(id)item { return NO; }
1065
25e0317335fc Switched from using NSPointerArray to NSMutableArray on Mac to avoid the duplicate string crashes
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1064
diff changeset
1936 -(void)addTree:(NSMutableArray *)item and:(NSMutableArray *)parent after:(NSMutableArray *)after
680
db315779a283 Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 679
diff changeset
1937 {
db315779a283 Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 679
diff changeset
1938 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
1939 if(parent)
db315779a283 Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 679
diff changeset
1940 {
1065
25e0317335fc Switched from using NSPointerArray to NSMutableArray on Mac to avoid the duplicate string crashes
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1064
diff changeset
1941 children = [parent objectAtIndex:3];
25e0317335fc Switched from using NSPointerArray to NSMutableArray on Mac to avoid the duplicate string crashes
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1064
diff changeset
1942 if([children isKindOfClass:[NSNull class]])
680
db315779a283 Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 679
diff changeset
1943 {
692
bd909322f40d Added "retain"s to the DWTree/DWContainer/DWListBox classes memory allocation
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 691
diff changeset
1944 children = [[[NSMutableArray alloc] init] retain];
1065
25e0317335fc Switched from using NSPointerArray to NSMutableArray on Mac to avoid the duplicate string crashes
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1064
diff changeset
1945 [parent replaceObjectAtIndex:3 withObject:children];
680
db315779a283 Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 679
diff changeset
1946 }
db315779a283 Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 679
diff changeset
1947 }
db315779a283 Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 679
diff changeset
1948 else
db315779a283 Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 679
diff changeset
1949 {
db315779a283 Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 679
diff changeset
1950 if(!data)
db315779a283 Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 679
diff changeset
1951 {
692
bd909322f40d Added "retain"s to the DWTree/DWContainer/DWListBox classes memory allocation
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 691
diff changeset
1952 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
1953 }
db315779a283 Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 679
diff changeset
1954 }
1064
b673b25bbd77 Fixed dw_tree_insert_after() so it works on Mac it previously functioned identical to dw_tree_insert().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1063
diff changeset
1955 if(after)
b673b25bbd77 Fixed dw_tree_insert_after() so it works on Mac it previously functioned identical to dw_tree_insert().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1063
diff changeset
1956 {
b673b25bbd77 Fixed dw_tree_insert_after() so it works on Mac it previously functioned identical to dw_tree_insert().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1063
diff changeset
1957 NSInteger index = [children indexOfObject:after];
1100
13ea7575d9e8 Fixed a problem with dw_tree_item_delete() due to earlier tree data storage changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1099
diff changeset
1958 int count = (int)[children count];
13ea7575d9e8 Fixed a problem with dw_tree_item_delete() due to earlier tree data storage changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1099
diff changeset
1959 if(index != NSNotFound && (index+1) < count)
13ea7575d9e8 Fixed a problem with dw_tree_item_delete() due to earlier tree data storage changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1099
diff changeset
1960 [children insertObject:item atIndex:(index+1)];
13ea7575d9e8 Fixed a problem with dw_tree_item_delete() due to earlier tree data storage changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1099
diff changeset
1961 else
13ea7575d9e8 Fixed a problem with dw_tree_item_delete() due to earlier tree data storage changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1099
diff changeset
1962 [children addObject:item];
1064
b673b25bbd77 Fixed dw_tree_insert_after() so it works on Mac it previously functioned identical to dw_tree_insert().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1063
diff changeset
1963 }
b673b25bbd77 Fixed dw_tree_insert_after() so it works on Mac it previously functioned identical to dw_tree_insert().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1063
diff changeset
1964 else
b673b25bbd77 Fixed dw_tree_insert_after() so it works on Mac it previously functioned identical to dw_tree_insert().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1063
diff changeset
1965 {
b673b25bbd77 Fixed dw_tree_insert_after() so it works on Mac it previously functioned identical to dw_tree_insert().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1063
diff changeset
1966 [children addObject:item];
b673b25bbd77 Fixed dw_tree_insert_after() so it works on Mac it previously functioned identical to dw_tree_insert().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1063
diff changeset
1967 }
680
db315779a283 Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 679
diff changeset
1968 }
db315779a283 Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 679
diff changeset
1969 -(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
1970 -(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
1971 -(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
1972 {
710
78460ff977c1 Finishing up tree event/signal handlers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 709
diff changeset
1973 /* 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
1974 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
1975
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
1976 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
1977 {
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
1978 _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
1979 }
710
78460ff977c1 Finishing up tree event/signal handlers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 709
diff changeset
1980 }
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
1981 -(void)treeItemExpanded:(NSNotification *)notification
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
1982 {
722
5a8d5161651d Implemented tree expand event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 721
diff changeset
1983 id item = [[notification userInfo ] objectForKey: @"NSObject"];
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
1984
722
5a8d5161651d Implemented tree expand event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 721
diff changeset
1985 if(item)
5a8d5161651d Implemented tree expand event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 721
diff changeset
1986 {
5a8d5161651d Implemented tree expand event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 721
diff changeset
1987 _event_handler(self, (void *)item, 16);
5a8d5161651d Implemented tree expand event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 721
diff changeset
1988 }
5a8d5161651d Implemented tree expand event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 721
diff changeset
1989 }
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
1990 -(NSMenu *)menuForEvent:(NSEvent *)event
710
78460ff977c1 Finishing up tree event/signal handlers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 709
diff changeset
1991 {
78460ff977c1 Finishing up tree event/signal handlers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 709
diff changeset
1992 int row;
78460ff977c1 Finishing up tree event/signal handlers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 709
diff changeset
1993 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
1994 row = (int)[self rowAtPoint:where];
78460ff977c1 Finishing up tree event/signal handlers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 709
diff changeset
1995 id item = [self itemAtRow:row];
1061
d91e09dc3865 Fix for the item data field of the context event always being NULL even for tree items on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1051
diff changeset
1996 _event_handler(self, (NSEvent *)item, 10);
710
78460ff977c1 Finishing up tree event/signal handlers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 709
diff changeset
1997 return nil;
709
5a268d5f1cfa Fixes for tree event handling. Still more to come shortly...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 708
diff changeset
1998 }
680
db315779a283 Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 679
diff changeset
1999 -(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
2000 -(void)setScrollview:(NSScrollView *)input { scrollview = input; }
1065
25e0317335fc Switched from using NSPointerArray to NSMutableArray on Mac to avoid the duplicate string crashes
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1064
diff changeset
2001 -(void)deleteNode:(NSMutableArray *)item { _free_tree_recurse(data, item); }
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
2002 -(void)setForegroundColor:(NSColor *)input
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
2003 {
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
2004 NSTextFieldCell *cell = [treecol dataCell];
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
2005 fgcolor = input;
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
2006 [fgcolor retain];
810
746cdd753e7a Added coloring support for the Container/Tree/Listbox controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 809
diff changeset
2007 [cell setTextColor:fgcolor];
746cdd753e7a Added coloring support for the Container/Tree/Listbox controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 809
diff changeset
2008 }
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
2009 -(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
2010 -(void)dealloc
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
2011 {
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
2012 UserData *root = userdata;
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
2013 _remove_userdata(&root, NULL, TRUE);
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
2014 _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
2015 [treecol release];
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
2016 [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
2017 }
680
db315779a283 Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 679
diff changeset
2018 @end
db315779a283 Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 679
diff changeset
2019
656
6c8b95ca877b Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 655
diff changeset
2020 /* Subclass for a Calendar type */
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
2021 @interface DWCalendar : NSDatePicker
655
27eb39d2577b Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 654
diff changeset
2022 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2023 void *userdata;
655
27eb39d2577b Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 654
diff changeset
2024 }
27eb39d2577b Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 654
diff changeset
2025 -(void *)userdata;
27eb39d2577b Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 654
diff changeset
2026 -(void)setUserdata:(void *)input;
27eb39d2577b Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 654
diff changeset
2027 @end
27eb39d2577b Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 654
diff changeset
2028
27eb39d2577b Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 654
diff changeset
2029 @implementation DWCalendar
27eb39d2577b Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 654
diff changeset
2030 -(void *)userdata { return userdata; }
27eb39d2577b Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 654
diff changeset
2031 -(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
2032 -(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
2033 @end
27eb39d2577b Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 654
diff changeset
2034
656
6c8b95ca877b Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 655
diff changeset
2035 /* Subclass for a Combobox type */
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
2036 @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
2037 #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
2038 <NSComboBoxDelegate>
17923b931393 Fixes for building for MacOS 10.5 and PPC
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 715
diff changeset
2039 #endif
656
6c8b95ca877b Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 655
diff changeset
2040 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2041 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
2042 id clickDefault;
656
6c8b95ca877b Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 655
diff changeset
2043 }
6c8b95ca877b Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 655
diff changeset
2044 -(void *)userdata;
6c8b95ca877b Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 655
diff changeset
2045 -(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
2046 -(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
2047 -(void)setClickDefault:(id)input;
656
6c8b95ca877b Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 655
diff changeset
2048 @end
6c8b95ca877b Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 655
diff changeset
2049
6c8b95ca877b Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 655
diff changeset
2050 @implementation DWComboBox
6c8b95ca877b Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 655
diff changeset
2051 -(void *)userdata { return userdata; }
6c8b95ca877b Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 655
diff changeset
2052 -(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
2053 -(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
2054 -(void)setClickDefault:(id)input { clickDefault = input; }
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
2055 -(void)keyUp:(NSEvent *)theEvent
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
2056 {
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
2057 if(clickDefault && [[theEvent charactersIgnoringModifiers] characterAtIndex:0] == VK_RETURN)
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
2058 {
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
2059 [[self window] makeFirstResponder:clickDefault];
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
2060 } else
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
2061 {
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
2062 [super keyUp:theEvent];
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
2063 }
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
2064 }
678
0ec8edbb82cf Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 677
diff changeset
2065 -(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
2066 @end
0ec8edbb82cf Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 677
diff changeset
2067
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
2068 /* 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
2069 /* 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
2070 @interface DWStepper : NSStepper
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
2071 {
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
2072 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
2073 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
2074 }
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
2075 -(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
2076 -(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
2077 -(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
2078 -(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
2079 -(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
2080 -(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
2081 @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
2082
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
2083 @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
2084 -(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
2085 -(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
2086 -(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
2087 -(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
2088 -(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
2089 {
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
2090 [super mouseDown:event];
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
2091 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
2092 {
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
2093 [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
2094 _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
2095 }
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
2096 }
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
2097 -(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
2098 {
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
2099 [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
2100 _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
2101 }
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
2102 @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
2103
678
0ec8edbb82cf Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 677
diff changeset
2104 /* Subclass for a Spinbutton type */
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
2105 @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
2106 #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
2107 <NSTextFieldDelegate>
17923b931393 Fixes for building for MacOS 10.5 and PPC
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 715
diff changeset
2108 #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
2109 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2110 void *userdata;
678
0ec8edbb82cf Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 677
diff changeset
2111 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
2112 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
2113 id clickDefault;
678
0ec8edbb82cf Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 677
diff changeset
2114 }
0ec8edbb82cf Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 677
diff changeset
2115 -(id)init;
0ec8edbb82cf Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 677
diff changeset
2116 -(void *)userdata;
0ec8edbb82cf Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 677
diff changeset
2117 -(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
2118 -(NSTextField *)textfield;
0ec8edbb82cf Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 677
diff changeset
2119 -(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
2120 -(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
2121 -(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
2122 @end
0ec8edbb82cf Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 677
diff changeset
2123
0ec8edbb82cf Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 677
diff changeset
2124 @implementation DWSpinButton
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
2125 -(id)init
678
0ec8edbb82cf Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 677
diff changeset
2126 {
0ec8edbb82cf Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 677
diff changeset
2127 self = [super init];
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
2128
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
2129 if(self)
678
0ec8edbb82cf Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 677
diff changeset
2130 {
0ec8edbb82cf Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 677
diff changeset
2131 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
2132 [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
2133 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
2134 [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
2135 [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
2136 [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
2137 [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
2138 [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
2139 }
0ec8edbb82cf Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 677
diff changeset
2140 return self;
0ec8edbb82cf Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 677
diff changeset
2141 }
0ec8edbb82cf Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 677
diff changeset
2142 -(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
2143 -(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
2144 -(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
2145 -(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
2146 -(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
2147 {
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
2148 [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
2149 [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
2150 _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
2151 }
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
2152 -(void)setClickDefault:(id)input { clickDefault = input; }
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
2153 -(void)keyUp:(NSEvent *)theEvent
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
2154 {
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
2155 if(clickDefault && [[theEvent charactersIgnoringModifiers] characterAtIndex:0] == VK_RETURN)
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
2156 {
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
2157 [[self window] makeFirstResponder:clickDefault];
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
2158 }
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
2159 else
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
2160 {
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
2161 [super keyUp:theEvent];
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
2162 }
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
2163 }
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
2164 -(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
2165 -(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
2166 @end
6c8b95ca877b Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 655
diff changeset
2167
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
2168 /* 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
2169 * 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
2170 * 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
2171 */
014b02436c1f Added MDI simulation code... the MDI "window" will just be a box for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 683
diff changeset
2172 @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
2173 @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
2174
014b02436c1f Added MDI simulation code... the MDI "window" will just be a box for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 683
diff changeset
2175 @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
2176 @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
2177
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2178 /* 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
2179 */
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
2180 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
2181 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2182 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
2183
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2184 new->message = message;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2185 new->window = window;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2186 new->id = msgid;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2187 new->signalfunction = signalfunction;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2188 new->data = data;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2189 new->next = NULL;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
2190
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2191 if (!Root)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2192 Root = new;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2193 else
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2194 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2195 SignalHandler *prev = NULL, *tmp = Root;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2196 while(tmp)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2197 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2198 if(tmp->message == message &&
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2199 tmp->window == window &&
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2200 tmp->id == msgid &&
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2201 tmp->signalfunction == signalfunction)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2202 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2203 tmp->data = data;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2204 free(new);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2205 return;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2206 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2207 prev = tmp;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2208 tmp = tmp->next;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2209 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2210 if(prev)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2211 prev->next = new;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2212 else
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2213 Root = new;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2214 }
650
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
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2217 /* 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
2218 ULONG _findsigmessage(char *signame)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2219 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2220 int z;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
2221
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2222 for(z=0;z<SIGNALMAX;z++)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2223 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2224 if(strcasecmp(signame, SignalTranslate[z].name) == 0)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2225 return SignalTranslate[z].message;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2226 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2227 return 0L;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2228 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2229
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2230 unsigned long _foreground = 0xAAAAAA, _background = 0;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2231
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
2232 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
2233 {
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
2234 int z;
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
2235
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
2236 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
2237 {
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
2238 id handle = thisbox->items[z].hwnd;
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
2239
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
2240 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
2241 {
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
2242 Box *tmp = [handle box];
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
2243
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
2244 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
2245 {
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
2246 _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
2247 }
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
2248 }
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
2249 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
2250 {
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
2251 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
2252 {
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
2253 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
2254 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
2255 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
2256 NSWindow *window = [render window];
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
2257
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
2258 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
2259 {
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
2260 [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
2261 }
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
2262
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
2263 /* 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
2264 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
2265 {
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
2266 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
2267 {
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
2268 [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
2269 _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
2270 }
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
2271 }
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
2272 }
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
2273 /* 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
2274 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
2275 {
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
2276 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
2277 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
2278 id view = [notepage view];
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
2279
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
2280 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
2281 {
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
2282 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
2283 _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
2284 }
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
2285 }
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
2286 /* 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
2287 * 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
2288 */
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
2289 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
2290 {
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
2291 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
2292 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
2293 Box *thisbox = [contentbox box];
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
2294
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
2295 /* 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
2296 _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
2297 }
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
2298 }
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
2299 }
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
2300 }
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
2301
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2302 /* 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
2303 * and does expansion as necessary.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2304 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2305 static int _resize_box(Box *thisbox, int *depth, int x, int y, int *usedx, int *usedy,
928
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2306 int pass, int *usedpadx, int *usedpady)
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2307 {
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2308 int z, currentx = 0, currenty = 0;
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2309 int uymax = 0, uxmax = 0;
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2310 int upymax = 0, upxmax = 0;
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2311 /* Used for the SIZEEXPAND */
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2312 int nux = *usedx, nuy = *usedy;
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2313 int nupx = *usedpadx, nupy = *usedpady;
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2314 int thispadx = thisbox->pad * 2;
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2315 int thispady = thisbox->pad * 2;
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
2316
798
1b0a0775ec19 Ok... groupbox calculation fix try #2!
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 797
diff changeset
2317 /* Handle special groupbox case */
1b0a0775ec19 Ok... groupbox calculation fix try #2!
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 797
diff changeset
2318 if(thisbox->grouphwnd)
1b0a0775ec19 Ok... groupbox calculation fix try #2!
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 797
diff changeset
2319 {
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
2320 DWGroupBox *groupbox = thisbox->grouphwnd;
928
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2321 NSSize borderSize = [groupbox borderSize];
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
2322 NSRect titleRect;
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
2323
928
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2324 if(borderSize.width == 0 || borderSize.height == 0)
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2325 {
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2326 borderSize = [groupbox initBorder];
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2327 }
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
2328 /* 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
2329 titleRect = [groupbox titleRect];
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
2330
928
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2331 thisbox->grouppadx = borderSize.width;
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2332 thisbox->grouppady = borderSize.height + titleRect.size.height;
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
2333
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
2334 (*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
2335 (*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
2336 (*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
2337 (*usedpady) += thisbox->grouppady;
798
1b0a0775ec19 Ok... groupbox calculation fix try #2!
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 797
diff changeset
2338 }
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
2339
928
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2340 (*usedx) += thispadx;
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2341 (*usedy) += thispady;
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
2342
928
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2343 for(z=0;z<thisbox->count;z++)
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2344 {
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2345 if(thisbox->items[z].type == TYPEBOX)
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2346 {
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2347 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
2348 id box = thisbox->items[z].hwnd;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2349 Box *tmp = [box box];
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
2350
928
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2351 initialx = x - (*usedx);
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2352 initialy = y - (*usedy);
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
2353
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2354 if(tmp)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2355 {
928
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2356 int newx, newy;
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2357 int nux = *usedx, nuy = *usedy;
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2358 int tmppadx = tmp->pad*2;
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2359 int tmppady = tmp->pad*2;
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2360 int upx, upy;
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
2361
928
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2362 upx = *usedpadx + tmppadx;
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2363 upy = *usedpady + tmppady;
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
2364
928
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2365 /* On the second pass we know how big the box needs to be and how
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2366 * much space we have, so we can calculate a ratio for the new box.
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2367 */
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2368 if(pass > 1)
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2369 {
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2370 int deep = *depth + 1;
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2371 int tux = nux, tuy = nuy, tupx = upx, tupy = upy;
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
2372
928
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2373 _resize_box(tmp, &deep, x, y, &tux, &tuy, 1, &tupx, &tupy);
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
2374
928
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2375 tmp->upx = tupx - *usedpadx;
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2376 tmp->upy = tupy - *usedpady;
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
2377
928
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2378 newx = x - tux;
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2379 newy = y - tuy;
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
2380
928
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2381 tmp->width = thisbox->items[z].width = initialx - newx;
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2382 tmp->height = thisbox->items[z].height = initialy - newy;
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
2383
928
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2384 tmp->parentxratio = thisbox->xratio;
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2385 tmp->parentyratio = thisbox->yratio;
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
2386
928
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2387 tmp->parentpad = tmp->pad;
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
2388
928
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2389 /* Just in case */
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2390 tmp->xratio = thisbox->xratio;
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2391 tmp->yratio = thisbox->yratio;
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
2392
928
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2393 if(thisbox->type == DW_VERT)
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2394 {
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2395 int tmppad = (thisbox->items[z].pad*2)+(tmp->pad*2)+tmp->grouppady;
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
2396
928
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2397 if((thisbox->items[z].width - tmppad)!=0)
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2398 tmp->xratio = ((float)((thisbox->items[z].width * thisbox->xratio)-tmppad))/((float)(thisbox->items[z].width-tmppad));
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2399 }
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2400 else
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2401 {
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2402 if((thisbox->items[z].width-tmp->upx)!=0)
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2403 tmp->xratio = ((float)((thisbox->items[z].width * thisbox->xratio)-tmp->upx))/((float)(thisbox->items[z].width-tmp->upx));
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2404 }
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2405 if(thisbox->type == DW_HORZ)
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2406 {
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2407 int tmppad = (thisbox->items[z].pad*2)+(tmp->pad*2)+tmp->grouppadx;
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
2408
928
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2409 if((thisbox->items[z].height-tmppad)!=0)
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2410 tmp->yratio = ((float)((thisbox->items[z].height * thisbox->yratio)-tmppad))/((float)(thisbox->items[z].height-tmppad));
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2411 }
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2412 else
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2413 {
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2414 if((thisbox->items[z].height-tmp->upy)!=0)
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2415 tmp->yratio = ((float)((thisbox->items[z].height * thisbox->yratio)-tmp->upy))/((float)(thisbox->items[z].height-tmp->upy));
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2416 }
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2417 }
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
2418
928
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2419 (*depth)++;
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
2420
928
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2421 _resize_box(tmp, depth, x, y, &nux, &nuy, pass, &upx, &upy);
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
2422
928
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2423 (*depth)--;
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
2424
928
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2425 newx = x - nux;
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2426 newy = y - nuy;
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
2427
928
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2428 tmp->minwidth = thisbox->items[z].width = initialx - newx;
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2429 tmp->minheight = thisbox->items[z].height = initialy - newy;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2430 }
928
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2431 }
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
2432
928
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2433 if(pass > 1 && *depth > 0)
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2434 {
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2435 if(thisbox->type == DW_VERT)
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2436 {
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2437 int tmppad = (thisbox->items[z].pad*2)+(thisbox->parentpad*2)+thisbox->grouppadx;
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
2438
928
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2439 if((thisbox->minwidth-tmppad) == 0)
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2440 thisbox->items[z].xratio = 1.0;
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2441 else
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2442 thisbox->items[z].xratio = ((float)((thisbox->width * thisbox->parentxratio)-tmppad))/((float)(thisbox->minwidth-tmppad));
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2443 }
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2444 else
928
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2445 {
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2446 if(thisbox->minwidth-thisbox->upx == 0)
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2447 thisbox->items[z].xratio = 1.0;
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2448 else
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2449 thisbox->items[z].xratio = ((float)((thisbox->width * thisbox->parentxratio)-thisbox->upx))/((float)(thisbox->minwidth-thisbox->upx));
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2450 }
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
2451
928
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2452 if(thisbox->type == DW_HORZ)
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2453 {
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2454 int tmppad = (thisbox->items[z].pad*2)+(thisbox->parentpad*2)+thisbox->grouppady;
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
2455
928
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2456 if((thisbox->minheight-tmppad) == 0)
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2457 thisbox->items[z].yratio = 1.0;
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2458 else
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2459 thisbox->items[z].yratio = ((float)((thisbox->height * thisbox->parentyratio)-tmppad))/((float)(thisbox->minheight-tmppad));
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2460 }
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2461 else
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2462 {
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2463 if(thisbox->minheight-thisbox->upy == 0)
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2464 thisbox->items[z].yratio = 1.0;
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2465 else
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2466 thisbox->items[z].yratio = ((float)((thisbox->height * thisbox->parentyratio)-thisbox->upy))/((float)(thisbox->minheight-thisbox->upy));
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2467 }
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
2468
928
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2469 if(thisbox->items[z].type == TYPEBOX)
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2470 {
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2471 id box = thisbox->items[z].hwnd;
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2472 Box *tmp = [box box];
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
2473
928
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2474 if(tmp)
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2475 {
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2476 tmp->parentxratio = thisbox->items[z].xratio;
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2477 tmp->parentyratio = thisbox->items[z].yratio;
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2478 }
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2479 }
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2480 }
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2481 else
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2482 {
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2483 thisbox->items[z].xratio = thisbox->xratio;
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2484 thisbox->items[z].yratio = thisbox->yratio;
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2485 }
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
2486
928
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2487 if(thisbox->type == DW_VERT)
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2488 {
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2489 if((thisbox->items[z].width + (thisbox->items[z].pad*2)) > uxmax)
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2490 uxmax = (thisbox->items[z].width + (thisbox->items[z].pad*2));
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2491 if(thisbox->items[z].hsize != SIZEEXPAND)
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2492 {
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2493 if(((thisbox->items[z].pad*2) + thisbox->items[z].width) > upxmax)
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2494 upxmax = (thisbox->items[z].pad*2) + thisbox->items[z].width;
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2495 }
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2496 else
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2497 {
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2498 if(thisbox->items[z].pad*2 > upxmax)
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2499 upxmax = thisbox->items[z].pad*2;
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2500 }
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2501 }
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2502 else
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2503 {
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2504 if(thisbox->items[z].width == -1)
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2505 {
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2506 /* figure out how much space this item requires */
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2507 /* thisbox->items[z].width = */
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2508 }
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2509 else
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2510 {
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2511 (*usedx) += thisbox->items[z].width + (thisbox->items[z].pad*2);
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2512 if(thisbox->items[z].hsize != SIZEEXPAND)
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2513 (*usedpadx) += (thisbox->items[z].pad*2) + thisbox->items[z].width;
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2514 else
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2515 (*usedpadx) += thisbox->items[z].pad*2;
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2516 }
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2517 }
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2518 if(thisbox->type == DW_HORZ)
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2519 {
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2520 if((thisbox->items[z].height + (thisbox->items[z].pad*2)) > uymax)
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2521 uymax = (thisbox->items[z].height + (thisbox->items[z].pad*2));
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2522 if(thisbox->items[z].vsize != SIZEEXPAND)
928
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2523 {
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2524 if(((thisbox->items[z].pad*2) + thisbox->items[z].height) > upymax)
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2525 upymax = (thisbox->items[z].pad*2) + thisbox->items[z].height;
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2526 }
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2527 else
928
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2528 {
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2529 if(thisbox->items[z].pad*2 > upymax)
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2530 upymax = thisbox->items[z].pad*2;
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2531 }
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2532 }
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2533 else
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2534 {
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2535 if(thisbox->items[z].height == -1)
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2536 {
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2537 /* figure out how much space this item requires */
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2538 /* thisbox->items[z].height = */
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2539 }
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2540 else
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2541 {
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2542 (*usedy) += thisbox->items[z].height + (thisbox->items[z].pad*2);
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2543 if(thisbox->items[z].vsize != SIZEEXPAND)
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2544 (*usedpady) += (thisbox->items[z].pad*2) + thisbox->items[z].height;
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2545 else
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2546 (*usedpady) += thisbox->items[z].pad*2;
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2547 }
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2548 }
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2549 }
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
2550
928
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2551 (*usedx) += uxmax;
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2552 (*usedy) += uymax;
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2553 (*usedpadx) += upxmax;
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2554 (*usedpady) += upymax;
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
2555
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
2556 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
2557 currenty += thisbox->pad;
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
2558
928
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2559 /* The second pass is for expansion. */
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2560 if(pass > 1)
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2561 {
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2562 /* Any SIZEEXPAND items should be set to uxmax/uymax */
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2563 for(z=0;z<thisbox->count;z++)
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2564 {
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2565 if(thisbox->items[z].hsize == SIZEEXPAND && thisbox->type == DW_VERT)
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2566 thisbox->items[z].width = uxmax-(thisbox->items[z].pad*2);
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2567 if(thisbox->items[z].vsize == SIZEEXPAND && thisbox->type == DW_HORZ)
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2568 thisbox->items[z].height = uymax-(thisbox->items[z].pad*2);
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2569 /* Run this code segment again to finalize the sized after setting uxmax/uymax values. */
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2570 if(thisbox->items[z].type == TYPEBOX)
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2571 {
928
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2572 int tux = nux, tuy = nuy, tupx = nupx, tupy = nupy;
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2573 id box = thisbox->items[z].hwnd;
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2574 Box *tmp = [box box];
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
2575
928
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2576 if(tmp)
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2577 {
928
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2578 if(*depth > 0)
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2579 {
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2580 float calcval;
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
2581
928
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2582 if(thisbox->type == DW_VERT)
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2583 {
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2584 calcval = (float)(tmp->minwidth-((thisbox->items[z].pad*2)+thispadx));
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2585 if(calcval == 0.0)
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2586 tmp->xratio = thisbox->xratio;
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2587 else
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2588 tmp->xratio = ((float)((thisbox->items[z].width * thisbox->xratio)-((thisbox->items[z].pad*2)+thispadx)))/calcval;
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2589 tmp->width = thisbox->items[z].width;
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2590 }
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2591 if(thisbox->type == DW_HORZ)
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2592 {
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2593 calcval = (float)(tmp->minheight-((thisbox->items[z].pad*2)+thispady));
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2594 if(calcval == 0.0)
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2595 tmp->yratio = thisbox->yratio;
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2596 else
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2597 tmp->yratio = ((float)((thisbox->items[z].height * thisbox->yratio)-((thisbox->items[z].pad*2)+thispady)))/calcval;
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2598 tmp->height = thisbox->items[z].height;
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2599 }
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2600 }
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
2601
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
2602
928
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2603 (*depth)++;
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
2604
928
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2605 _resize_box(tmp, depth, x, y, &tux, &tuy, pass, &tupx, &tupy);
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
2606
928
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2607 (*depth)--;
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
2608
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2609 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2610 }
928
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2611 }
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2612 }
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
2613
928
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2614 /* The third pass is for actual placement. */
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2615 if(pass > 2)
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2616 {
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2617 for(z=0;z<(thisbox->count);z++)
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2618 {
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2619 int height = thisbox->items[z].height;
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2620 int width = thisbox->items[z].width;
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2621 int pad = thisbox->items[z].pad;
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2622 NSView *handle = thisbox->items[z].hwnd;
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2623 NSPoint point;
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2624 NSSize size;
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2625 int vectorx, vectory;
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
2626
928
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2627 /* When upxmax != pad*2 then ratios are incorrect. */
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2628 vectorx = (int)((width*thisbox->items[z].xratio)-width);
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2629 vectory = (int)((height*thisbox->items[z].yratio)-height);
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
2630
928
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2631 if(width > 0 && height > 0)
837
89d4bad9c96e Initial attempt at implementing the scrollbox on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 831
diff changeset
2632 {
928
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2633 /* This is a hack to fix rounding of the sizing */
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2634 if(*depth == 0)
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2635 {
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2636 vectorx++;
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2637 vectory++;
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2638 }
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
2639
928
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2640 /* If this item isn't going to expand... reset the vectors to 0 */
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2641 if(thisbox->items[z].vsize != SIZEEXPAND)
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2642 vectory = 0;
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2643 if(thisbox->items[z].hsize != SIZEEXPAND)
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2644 vectorx = 0;
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
2645
928
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2646 point.x = currentx + pad;
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2647 point.y = currenty + pad;
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2648 size.width = width + vectorx;
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2649 size.height = height + vectory;
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2650 [handle setFrameOrigin:point];
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2651 [handle setFrameSize:size];
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
2652
928
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2653 /* After placing a box... place its components */
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2654 if(thisbox->items[z].type == TYPEBOX)
837
89d4bad9c96e Initial attempt at implementing the scrollbox on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 831
diff changeset
2655 {
928
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2656 id box = thisbox->items[z].hwnd;
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2657 Box *tmp = [box box];
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
2658
928
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2659 if(tmp)
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2660 {
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2661 (*depth)++;
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2662 _resize_box(tmp, depth, x, y, &nux, &nuy, pass, &nupx, &nupy);
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2663 (*depth)--;
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2664 }
837
89d4bad9c96e Initial attempt at implementing the scrollbox on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 831
diff changeset
2665 }
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
2666
928
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2667 /* Special handling for notebook controls */
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2668 if([handle isMemberOfClass:[DWNotebook class]])
837
89d4bad9c96e Initial attempt at implementing the scrollbox on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 831
diff changeset
2669 {
928
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2670 DWNotebook *notebook = (DWNotebook *)handle;
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2671 DWNotebookPage *notepage = (DWNotebookPage *)[notebook selectedTabViewItem];
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2672 id view = [notepage view];
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
2673
928
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2674 if(view != nil)
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2675 {
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2676 Box *box = [view box];
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2677 NSSize size = [view frame].size;
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2678 _do_resize(box, size.width, size.height);
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2679 _handle_resize_events(box);
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2680 }
837
89d4bad9c96e Initial attempt at implementing the scrollbox on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 831
diff changeset
2681 }
928
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2682 /* Handle laying out scrollviews... if required space is less
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2683 * than available space, then expand. Otherwise use required space.
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2684 */
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2685 else if([handle isMemberOfClass:[DWScrollBox class]])
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2686 {
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2687 int usedx = 0, usedy = 0, usedpadx = 0, usedpady = 0, depth = 0;
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2688 DWScrollBox *scrollbox = (DWScrollBox *)handle;
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2689 DWBox *contentbox = [scrollbox documentView];
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2690 Box *thisbox = [contentbox box];
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2691 NSSize contentsize = [scrollbox contentSize];
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
2692
928
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2693 /* Get the required space for the box */
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2694 _resize_box(thisbox, &depth, x, y, &usedx, &usedy, 1, &usedpadx, &usedpady);
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
2695
928
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2696 if(contentsize.width < usedx)
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2697 {
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2698 contentsize.width = usedx;
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2699 }
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2700 if(contentsize.height < usedy)
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2701 {
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2702 contentsize.height = usedy;
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2703 }
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2704 [contentbox setFrameSize:contentsize];
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
2705
928
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2706 /* Layout the content of the scrollbox */
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2707 _do_resize(thisbox, contentsize.width, contentsize.height);
929
d7e88ac1647c Removed some code that had been used for debugging the layout code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 928
diff changeset
2708 _handle_resize_events(thisbox);
928
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2709 }
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2710 /* Special handling for spinbutton controls */
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2711 else if([handle isMemberOfClass:[DWSpinButton class]])
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2712 {
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2713 DWSpinButton *spinbutton = (DWSpinButton *)handle;
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2714 NSTextField *textfield = [spinbutton textfield];
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2715 NSStepper *stepper = [spinbutton stepper];
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2716 [textfield setFrameOrigin:NSMakePoint(0,0)];
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2717 [textfield setFrameSize:NSMakeSize(size.width-20,size.height)];
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2718 [stepper setFrameOrigin:NSMakePoint(size.width-20,0)];
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2719 [stepper setFrameSize:NSMakeSize(20,size.height)];
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2720 }
1101
d7eafaa054ab Added support for dw_window_redraw() causing splitbar panes to redraw without
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1100
diff changeset
2721 else if([handle isMemberOfClass:[DWSplitBar class]])
928
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2722 {
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2723 DWSplitBar *split = (DWSplitBar *)handle;
1101
d7eafaa054ab Added support for dw_window_redraw() causing splitbar panes to redraw without
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1100
diff changeset
2724 DWWindow *window = (DWWindow *)[split window];
928
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2725 float percent = [split percent];
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
2726
1101
d7eafaa054ab Added support for dw_window_redraw() causing splitbar panes to redraw without
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1100
diff changeset
2727 if(percent > 0 && size.width > 20 && size.height > 20)
928
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2728 {
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2729 dw_splitbar_set(handle, percent);
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2730 [split setPercent:0];
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2731 }
1101
d7eafaa054ab Added support for dw_window_redraw() causing splitbar panes to redraw without
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1100
diff changeset
2732 else if([window redraw])
d7eafaa054ab Added support for dw_window_redraw() causing splitbar panes to redraw without
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1100
diff changeset
2733 {
1128
7d7535f6bc4e Added ability to set background color of MLE; setting foreground still outstanding.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1120
diff changeset
2734 [split splitViewDidResizeSubviews:nil];
1101
d7eafaa054ab Added support for dw_window_redraw() causing splitbar panes to redraw without
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1100
diff changeset
2735 }
928
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2736 }
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2737 if(thisbox->type == DW_HORZ)
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2738 currentx += width + vectorx + (pad * 2);
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2739 if(thisbox->type == DW_VERT)
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2740 currenty += height + vectory + (pad * 2);
678
0ec8edbb82cf Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 677
diff changeset
2741 }
928
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2742 }
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2743 }
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2744 return 0;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2745 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2746
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2747 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
2748 {
943
675c12b1b90e Changed check from x and y not being zero to x and y being greater than zero since it seems values can be negative on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 942
diff changeset
2749 if(x > 0 && y > 0)
928
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2750 {
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2751 if(thisbox)
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2752 {
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2753 int usedx = 0, usedy = 0, usedpadx = 0, usedpady = 0, depth = 0;
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
2754
928
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2755 /* Calculate space requirements */
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2756 _resize_box(thisbox, &depth, x, y, &usedx, &usedy, 1, &usedpadx, &usedpady);
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
2757
928
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2758 if(usedx-usedpadx == 0 || usedy-usedpady == 0)
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2759 return;
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
2760
928
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2761 thisbox->xratio = ((float)(x-usedpadx))/((float)(usedx-usedpadx));
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2762 thisbox->yratio = ((float)(y-usedpady))/((float)(usedy-usedpady));
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
2763
928
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2764 usedx = usedy = usedpadx = usedpady = depth = 0;
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
2765
928
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2766 /* Calculate sub-box ratios for expansion */
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2767 _resize_box(thisbox, &depth, x, y, &usedx, &usedy, 2, &usedpadx, &usedpady);
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
2768
928
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2769 thisbox->xratio = ((float)(x-usedpadx))/((float)(usedx-usedpadx));
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2770 thisbox->yratio = ((float)(y-usedpady))/((float)(usedy-usedpady));
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
2771
928
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2772 usedx = usedy = usedpadx = usedpady = depth = 0;
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
2773
928
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2774 /* Finally place all the boxes and controls */
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2775 _resize_box(thisbox, &depth, x, y, &usedx, &usedy, 3, &usedpadx, &usedpady);
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2776 }
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2777 }
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2778 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2779
654
80e253df49fd Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 653
diff changeset
2780 NSMenu *_generate_main_menu()
80e253df49fd Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 653
diff changeset
2781 {
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
2782 NSString *applicationName = nil;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
2783
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
2784 /* 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
2785 #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
2786 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
2787 #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
2788 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
2789 {
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 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
2791 }
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
2792
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2793 /* Create the main menu */
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2794 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
2795
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2796 NSMenuItem * mitem = [mainMenu addItemWithTitle:@"Apple" action:NULL keyEquivalent:@""];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2797 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
2798
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2799 [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
2800
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2801 /* Setup the Application menu */
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2802 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
2803 action:@selector(orderFrontStandardAboutPanel:)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2804 keyEquivalent:@""];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2805 [item setTarget:DWApp];
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
2806
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2807 [menu addItem:[NSMenuItem separatorItem]];
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
2808
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2809 item = [menu addItemWithTitle:NSLocalizedString(@"Services", nil)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2810 action:NULL
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2811 keyEquivalent:@""];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2812 NSMenu * servicesMenu = [[[NSMenu alloc] initWithTitle:@"Services"] autorelease];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2813 [menu setSubmenu:servicesMenu forItem:item];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2814 [DWApp setServicesMenu:servicesMenu];
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
2815
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2816 [menu addItem:[NSMenuItem separatorItem]];
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
2817
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2818 item = [menu addItemWithTitle:[NSString stringWithFormat:@"%@ %@", NSLocalizedString(@"Hide", nil), applicationName]
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2819 action:@selector(hide:)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2820 keyEquivalent:@"h"];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2821 [item setTarget:DWApp];
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
2822
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2823 item = [menu addItemWithTitle:NSLocalizedString(@"Hide Others", nil)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2824 action:@selector(hideOtherApplications:)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2825 keyEquivalent:@"h"];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2826 [item setKeyEquivalentModifierMask:NSCommandKeyMask | NSAlternateKeyMask];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2827 [item setTarget:DWApp];
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
2828
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2829 item = [menu addItemWithTitle:NSLocalizedString(@"Show All", nil)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2830 action:@selector(unhideAllApplications:)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2831 keyEquivalent:@""];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2832 [item setTarget:DWApp];
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
2833
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2834 [menu addItem:[NSMenuItem separatorItem]];
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
2835
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2836 item = [menu addItemWithTitle:[NSString stringWithFormat:@"%@ %@", NSLocalizedString(@"Quit", nil), applicationName]
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2837 action:@selector(terminate:)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2838 keyEquivalent:@"q"];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2839 [item setTarget:DWApp];
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 [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
2842
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2843 return mainMenu;
654
80e253df49fd Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 653
diff changeset
2844 }
80e253df49fd Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 653
diff changeset
2845
80e253df49fd Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 653
diff changeset
2846 /*
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2847 * 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
2848 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2849 void API dw_main(void)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2850 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
2851 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
2852 DWThread = dw_thread_id();
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2853 [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
2854 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
2855 dw_mutex_unlock(DWRunMutex);
650
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
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2858 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2859 * 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
2860 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2861 * 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
2862 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2863 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
2864 {
694
130ca42c4ae3 Reimplementation of dw_main_iteration and dw_main_sleep that actually work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 693
diff changeset
2865 DWTID curr = pthread_self();
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
2866
694
130ca42c4ae3 Reimplementation of dw_main_iteration and dw_main_sleep that actually work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 693
diff changeset
2867 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
2868 {
130ca42c4ae3 Reimplementation of dw_main_iteration and dw_main_sleep that actually work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 693
diff changeset
2869 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
2870 NSDate *until = [NSDate dateWithTimeIntervalSinceNow:(milliseconds/1000.0)];
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
2871
695
3b17111499bf Minor updates to the last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 694
diff changeset
2872 if(orig == (DWTID)-1)
3b17111499bf Minor updates to the last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 694
diff changeset
2873 {
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
2874 dw_mutex_lock(DWRunMutex);
695
3b17111499bf Minor updates to the last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 694
diff changeset
2875 DWThread = curr;
3b17111499bf Minor updates to the last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 694
diff changeset
2876 }
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
2877 /* 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
2878 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
2879 {
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
2880 /* Just loop */
695
3b17111499bf Minor updates to the last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 694
diff changeset
2881 }
3b17111499bf Minor updates to the last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 694
diff changeset
2882 if(orig == (DWTID)-1)
3b17111499bf Minor updates to the last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 694
diff changeset
2883 {
3b17111499bf Minor updates to the last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 694
diff changeset
2884 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
2885 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
2886 }
130ca42c4ae3 Reimplementation of dw_main_iteration and dw_main_sleep that actually work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 693
diff changeset
2887 }
130ca42c4ae3 Reimplementation of dw_main_iteration and dw_main_sleep that actually work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 693
diff changeset
2888 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
2889 {
694
130ca42c4ae3 Reimplementation of dw_main_iteration and dw_main_sleep that actually work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 693
diff changeset
2890 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
2891 }
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2892 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2893
700
7953f0471e4d Some cleanups for the run loop iteration and thread system.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 699
diff changeset
2894 /* 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
2895 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
2896 {
694
130ca42c4ae3 Reimplementation of dw_main_iteration and dw_main_sleep that actually work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 693
diff changeset
2897 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
2898 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
2899 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
2900 dequeue:YES];
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
2901 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
2902 {
130ca42c4ae3 Reimplementation of dw_main_iteration and dw_main_sleep that actually work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 693
diff changeset
2903 [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
2904 [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
2905 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
2906 }
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
2907 return 0;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2908 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2909
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2910 /*
700
7953f0471e4d Some cleanups for the run loop iteration and thread system.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 699
diff changeset
2911 * 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
2912 */
7953f0471e4d Some cleanups for the run loop iteration and thread system.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 699
diff changeset
2913 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
2914 {
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
2915 DWTID curr = pthread_self();
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
2916
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
2917 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
2918 {
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
2919 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
2920 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
2921 _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
2922 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
2923 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
2924 }
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
2925 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
2926 {
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
2927 _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
2928 }
700
7953f0471e4d Some cleanups for the run loop iteration and thread system.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 699
diff changeset
2929 }
7953f0471e4d Some cleanups for the run loop iteration and thread system.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 699
diff changeset
2930
7953f0471e4d Some cleanups for the run loop iteration and thread system.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 699
diff changeset
2931 /*
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2932 * 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
2933 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2934 * 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
2935 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2936 void API dw_exit(int exitcode)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2937 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2938 exit(exitcode);
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2939 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2940
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2941 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2942 * 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
2943 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2944 * ptr: Pointer to dynamic windows allocated
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2945 * memory to be free()'d.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2946 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2947 void API dw_free(void *ptr)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2948 {
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2949 free(ptr);
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2950 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2951
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2952 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2953 * 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
2954 * 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
2955 * OS/2 and Windows).
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2956 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2957 char *dw_user_dir(void)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2958 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2959 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
2960
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2961 if(!_user_dir[0])
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2962 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2963 char *home = getenv("HOME");
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
2964
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2965 if(home)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2966 strcpy(_user_dir, home);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2967 else
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2968 strcpy(_user_dir, "/");
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2969 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2970 return _user_dir;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2971 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2972
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2973 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2974 * 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
2975 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2976 * 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
2977 * 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
2978 * format: printf style format string.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2979 * ...: 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
2980 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2981 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
2982 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2983 int iResponse;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2984 NSString *button1 = @"OK";
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2985 NSString *button2 = nil;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2986 NSString *button3 = nil;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2987 va_list args;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2988 char outbuf[1000];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2989
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2990 va_start(args, format);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2991 vsprintf(outbuf, format, args);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2992 va_end(args);
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
2993
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2994 if(flags & DW_MB_OKCANCEL)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2995 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2996 button2 = @"Cancel";
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2997 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2998 else if(flags & DW_MB_YESNO)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2999 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3000 button1 = @"Yes";
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3001 button2 = @"No";
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3002 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3003 else if(flags & DW_MB_YESNOCANCEL)
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 button1 = @"Yes";
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3006 button2 = @"No";
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3007 button3 = @"Cancel";
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3008 }
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
3009
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3010 if(flags & DW_MB_ERROR)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3011 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3012 iResponse = (int)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3013 NSRunCriticalAlertPanel([ NSString stringWithUTF8String:title ],
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3014 [ NSString stringWithUTF8String:outbuf ],
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
3015 button1, button2, button3);
936
4be0c9f963f8 Implement informational messagebox style on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 935
diff changeset
3016 }
4be0c9f963f8 Implement informational messagebox style on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 935
diff changeset
3017 else if(flags & DW_MB_INFORMATION)
4be0c9f963f8 Implement informational messagebox style on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 935
diff changeset
3018 {
4be0c9f963f8 Implement informational messagebox style on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 935
diff changeset
3019 iResponse = (int)
4be0c9f963f8 Implement informational messagebox style on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 935
diff changeset
3020 NSRunInformationalAlertPanel([ NSString stringWithUTF8String:title ],
4be0c9f963f8 Implement informational messagebox style on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 935
diff changeset
3021 [ NSString stringWithUTF8String:outbuf ],
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
3022 button1, button2, button3);
936
4be0c9f963f8 Implement informational messagebox style on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 935
diff changeset
3023 }
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3024 else
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3025 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3026 iResponse = (int)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3027 NSRunAlertPanel([ NSString stringWithUTF8String:title ],
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3028 [ NSString stringWithUTF8String:outbuf ],
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3029 button1, button2, button3);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3030 }
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
3031
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3032 switch(iResponse)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3033 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3034 case NSAlertDefaultReturn: /* user pressed OK */
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3035 if(flags & DW_MB_YESNO || flags & DW_MB_YESNOCANCEL)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3036 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3037 return DW_MB_RETURN_YES;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3038 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3039 return DW_MB_RETURN_OK;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3040 case NSAlertAlternateReturn: /* user pressed Cancel */
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3041 if(flags & DW_MB_OKCANCEL)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3042 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3043 return DW_MB_RETURN_CANCEL;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3044 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3045 return DW_MB_RETURN_NO;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3046 case NSAlertOtherReturn: /* user pressed the third button */
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3047 return DW_MB_RETURN_CANCEL;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3048 case NSAlertErrorReturn: /* an error occurred */
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3049 break;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3050 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3051 return 0;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3052 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3053
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3054 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3055 * 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
3056 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3057 * title: Title bar text for dialog.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3058 * 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
3059 * ext: Default file extention.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3060 * 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
3061 * Returns:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3062 * 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
3063 * the file path on success.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3064 *
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3065 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3066 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
3067 {
825
8a2e3138e1e4 Implemented DW_DIRECTORY_OPEN on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 821
diff changeset
3068 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
3069 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3070 /* Create the File Open Dialog class. */
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3071 NSOpenPanel* openDlg = [NSOpenPanel openPanel];
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
3072
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3073 /* 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
3074 if(flags == DW_FILE_OPEN)
8a2e3138e1e4 Implemented DW_DIRECTORY_OPEN on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 821
diff changeset
3075 {
8a2e3138e1e4 Implemented DW_DIRECTORY_OPEN on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 821
diff changeset
3076 [openDlg setCanChooseFiles:YES];
8a2e3138e1e4 Implemented DW_DIRECTORY_OPEN on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 821
diff changeset
3077 [openDlg setCanChooseDirectories:NO];
8a2e3138e1e4 Implemented DW_DIRECTORY_OPEN on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 821
diff changeset
3078 }
8a2e3138e1e4 Implemented DW_DIRECTORY_OPEN on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 821
diff changeset
3079 else
8a2e3138e1e4 Implemented DW_DIRECTORY_OPEN on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 821
diff changeset
3080 {
8a2e3138e1e4 Implemented DW_DIRECTORY_OPEN on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 821
diff changeset
3081 [openDlg setCanChooseFiles:NO];
8a2e3138e1e4 Implemented DW_DIRECTORY_OPEN on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 821
diff changeset
3082 [openDlg setCanChooseDirectories:YES];
8a2e3138e1e4 Implemented DW_DIRECTORY_OPEN on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 821
diff changeset
3083 }
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
3084
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3085 /* Disable multiple selection */
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3086 [openDlg setAllowsMultipleSelection:NO];
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
3087
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3088 /* Display the dialog. If the OK button was pressed,
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3089 * process the files.
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3090 */
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3091 if([openDlg runModal] == NSOKButton)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3092 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3093 /* Get an array containing the full filenames of all
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3094 * files and directories selected.
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3095 */
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3096 NSArray* files = [openDlg filenames];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3097 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
3098 return strdup([ fileName UTF8String ]);
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3099 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3100 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3101 else
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3102 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3103 /* Create the File Save Dialog class. */
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3104 NSSavePanel* saveDlg = [NSSavePanel savePanel];
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 /* Enable the creation of directories in the dialog. */
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3107 [saveDlg setCanCreateDirectories:YES];
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
3108
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3109 /* Display the dialog. If the OK button was pressed,
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3110 * process the files.
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3111 */
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3112 if([saveDlg runModal] == NSFileHandlingPanelOKButton)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3113 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3114 /* Get an array containing the full filenames of all
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3115 * files and directories selected.
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3116 */
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3117 NSString* fileName = [saveDlg filename];
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
3118 return strdup([ fileName UTF8String ]);
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
3119 }
752
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 return NULL;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3123 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3124
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3125 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3126 * 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
3127 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3128 * None.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3129 * Returns:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3130 * 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
3131 * be converted to text.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3132 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3133 char *dw_clipboard_get_text()
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3134 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3135 NSPasteboard *pasteboard = [NSPasteboard generalPasteboard];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3136 NSString *str = [pasteboard stringForType:NSStringPboardType];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3137 if(str != nil)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3138 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3139 return strdup([ str UTF8String ]);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3140 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3141 return NULL;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3142 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3143
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3144 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3145 * 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
3146 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3147 * Text.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3148 */
651
270580896dac Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 650
diff changeset
3149 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
3150 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3151 NSPasteboard *pasteboard = [NSPasteboard generalPasteboard];
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
3152
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
3153 /* 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
3154 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
3155 {
eba6ab48c952 Runtime Snow Leopard checks where possible and visual fix for Leopard status text.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 749
diff changeset
3156 [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
3157 }
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
3158
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3159 [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
3160 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3161
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3162
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3163 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3164 * Allocates and initializes a dialog struct.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3165 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3166 * 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
3167 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3168 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
3169 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3170 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
3171
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3172 if(tmp)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3173 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3174 tmp->eve = dw_event_new();
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3175 dw_event_reset(tmp->eve);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3176 tmp->data = data;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3177 tmp->done = FALSE;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3178 tmp->result = NULL;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3179 }
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
3180 return tmp;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3181 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3182
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3183 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3184 * 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
3185 * initial called of dw_dialog_wait().
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3186 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3187 * 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
3188 * 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
3189 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3190 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
3191 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3192 dialog->result = result;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3193 dw_event_post(dialog->eve);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3194 dialog->done = TRUE;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3195 return 0;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3196 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3197
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3198 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3199 * 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
3200 * 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
3201 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3202 * 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
3203 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3204 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
3205 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3206 void *tmp;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
3207
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3208 while(!dialog->done)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3209 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3210 _dw_main_iteration([NSDate dateWithTimeIntervalSinceNow:0.01]);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3211 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3212 dw_event_close(&dialog->eve);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3213 tmp = dialog->result;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3214 free(dialog);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3215 return tmp;
650
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
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3218 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3219 * 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
3220 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3221 * 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
3222 * 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
3223 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3224 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
3225 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
3226 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
3227 DW_MUTEX_LOCK;
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
3228 DWBox *view = [[DWBox alloc] init];
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3229 Box *newbox = [view box];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3230 memset(newbox, 0, sizeof(Box));
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3231 newbox->pad = pad;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3232 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
3233 DW_MUTEX_UNLOCK;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3234 return view;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3235 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3236
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3237 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3238 * 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
3239 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3240 * 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
3241 * 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
3242 * 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
3243 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3244 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
3245 {
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
3246 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
3247 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
3248 Box *box = [thisbox box];
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
3249
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
3250 [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
3251 [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
3252 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
3253 [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
3254 return groupbox;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3255 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3256
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
3257 /*
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
3258 * Create a new scrollable Box to be packed.
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
3259 * Parameters:
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
3260 * 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
3261 * 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
3262 */
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
3263 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
3264 {
837
89d4bad9c96e Initial attempt at implementing the scrollbox on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 831
diff changeset
3265 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
3266 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
3267 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
3268 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
3269 [scrollbox setHasVerticalScroller:YES];
89d4bad9c96e Initial attempt at implementing the scrollbox on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 831
diff changeset
3270 [scrollbox setHasHorizontalScroller:YES];
89d4bad9c96e Initial attempt at implementing the scrollbox on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 831
diff changeset
3271 [scrollbox setBorderType:NSNoBorder];
838
8e0405435d0a Minor scrollbox fixes...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 837
diff changeset
3272 [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
3273 [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
3274 [scrollbox setDocumentView:tmpbox];
837
89d4bad9c96e Initial attempt at implementing the scrollbox on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 831
diff changeset
3275 return scrollbox;
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
3276 }
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
3277
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
3278 /*
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
3279 * 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
3280 * Parameters:
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
3281 * handle: Handle to the scrollbox to be queried.
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
3282 * orient: The vertical or horizontal scrollbar.
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
3283 */
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
3284 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
3285 {
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
3286 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
3287 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
3288 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
3289 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
3290 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
3291 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
3292 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
3293 {
5103d132c3cd Implemented dw_scrollbox_get_range() and dw_scrollbox_get_pos() on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 840
diff changeset
3294 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
3295 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
3296 }
5103d132c3cd Implemented dw_scrollbox_get_range() and dw_scrollbox_get_pos() on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 840
diff changeset
3297 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
3298 {
5103d132c3cd Implemented dw_scrollbox_get_range() and dw_scrollbox_get_pos() on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 840
diff changeset
3299 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
3300 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
3301 }
5103d132c3cd Implemented dw_scrollbox_get_range() and dw_scrollbox_get_pos() on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 840
diff changeset
3302 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
3303 {
5103d132c3cd Implemented dw_scrollbox_get_range() and dw_scrollbox_get_pos() on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 840
diff changeset
3304 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
3305 }
5103d132c3cd Implemented dw_scrollbox_get_range() and dw_scrollbox_get_pos() on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 840
diff changeset
3306 return val;
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
3307 }
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
3308
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
3309 /*
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
3310 * 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
3311 * Parameters:
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
3312 * handle: Handle to the scrollbox to be queried.
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
3313 * orient: The vertical or horizontal scrollbar.
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
3314 */
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
3315 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
3316 {
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
3317 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
3318 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
3319 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
3320 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
3321 {
5103d132c3cd Implemented dw_scrollbox_get_range() and dw_scrollbox_get_pos() on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 840
diff changeset
3322 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
3323 }
5103d132c3cd Implemented dw_scrollbox_get_range() and dw_scrollbox_get_pos() on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 840
diff changeset
3324 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
3325 {
5103d132c3cd Implemented dw_scrollbox_get_range() and dw_scrollbox_get_pos() on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 840
diff changeset
3326 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
3327 }
5103d132c3cd Implemented dw_scrollbox_get_range() and dw_scrollbox_get_pos() on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 840
diff changeset
3328 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
3329 }
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
3330
1086
4254c9b6d50d Merge all 3 box packing functions into one internal function on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1079
diff changeset
3331 /* Internal box packing function called by the other 3 functions */
4254c9b6d50d Merge all 3 box packing functions into one internal function on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1079
diff changeset
3332 void _dw_box_pack(HWND box, HWND item, int index, int width, int height, int hsize, int vsize, int pad, char *funcname)
1077
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
3333 {
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
3334 int _locked_by_me = FALSE;
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
3335 DW_MUTEX_LOCK;
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
3336 id object = box;
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
3337 DWBox *view = box;
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
3338 DWBox *this = item;
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
3339 Box *thisbox;
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
3340 int z, x = 0;
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
3341 Item *tmpitem, *thisitem;
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
3342
1086
4254c9b6d50d Merge all 3 box packing functions into one internal function on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1079
diff changeset
3343 /*
4254c9b6d50d Merge all 3 box packing functions into one internal function on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1079
diff changeset
3344 * If you try and pack an item into itself VERY bad things can happen; like at least an
4254c9b6d50d Merge all 3 box packing functions into one internal function on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1079
diff changeset
3345 * infinite loop on GTK! Lets be safe!
4254c9b6d50d Merge all 3 box packing functions into one internal function on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1079
diff changeset
3346 */
4254c9b6d50d Merge all 3 box packing functions into one internal function on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1079
diff changeset
3347 if(box == item)
4254c9b6d50d Merge all 3 box packing functions into one internal function on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1079
diff changeset
3348 {
4254c9b6d50d Merge all 3 box packing functions into one internal function on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1079
diff changeset
3349 dw_messagebox(funcname, DW_MB_OK|DW_MB_ERROR, "Danger! Danger! Will Robinson; box and item are the same!");
4254c9b6d50d Merge all 3 box packing functions into one internal function on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1079
diff changeset
3350 return;
4254c9b6d50d Merge all 3 box packing functions into one internal function on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1079
diff changeset
3351 }
1128
7d7535f6bc4e Added ability to set background color of MLE; setting foreground still outstanding.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1120
diff changeset
3352
1077
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
3353 /* Query the objects */
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
3354 if([ object isKindOfClass:[ NSWindow class ] ])
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
3355 {
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
3356 NSWindow *window = box;
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
3357 view = [window contentView];
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
3358 }
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
3359 else if([ object isMemberOfClass:[ DWScrollBox class ] ])
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
3360 {
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
3361 DWScrollBox *scrollbox = box;
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
3362 view = [scrollbox box];
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
3363 }
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
3364
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
3365 thisbox = [view box];
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
3366 thisitem = thisbox->items;
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
3367 object = item;
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
3368
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
3369 /* Query the objects */
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
3370 if([ object isKindOfClass:[ DWContainer class ] ])
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
3371 {
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
3372 DWContainer *cont = item;
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
3373 this = item = [cont scrollview];
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
3374 }
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
3375 else if([ object isKindOfClass:[ DWTree class ] ])
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
3376 {
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
3377 DWTree *tree = item;
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
3378 this = item = [tree scrollview];
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
3379 }
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
3380
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
3381 /* Do some sanity bounds checking */
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
3382 if(index < 0)
1079
5d3acda4acd4 Fixed a minor cut and paste error and formatting on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1077
diff changeset
3383 index = 0;
1077
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
3384 if(index > thisbox->count)
1079
5d3acda4acd4 Fixed a minor cut and paste error and formatting on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1077
diff changeset
3385 index = thisbox->count;
1128
7d7535f6bc4e Added ability to set background color of MLE; setting foreground still outstanding.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1120
diff changeset
3386
1077
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
3387 /* Duplicate the existing data */
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
3388 tmpitem = malloc(sizeof(Item)*(thisbox->count+1));
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
3389
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
3390 for(z=0;z<thisbox->count;z++)
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
3391 {
1079
5d3acda4acd4 Fixed a minor cut and paste error and formatting on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1077
diff changeset
3392 if(z == index)
5d3acda4acd4 Fixed a minor cut and paste error and formatting on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1077
diff changeset
3393 x++;
5d3acda4acd4 Fixed a minor cut and paste error and formatting on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1077
diff changeset
3394 tmpitem[x] = thisitem[z];
5d3acda4acd4 Fixed a minor cut and paste error and formatting on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1077
diff changeset
3395 x++;
1077
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
3396 }
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
3397
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
3398 /* Sanity checks */
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
3399 if(vsize && !height)
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
3400 height = 1;
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
3401 if(hsize && !width)
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
3402 width = 1;
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
3403
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
3404 /* Fill in the item data appropriately */
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
3405 if([object isKindOfClass:[DWBox class]] || [object isMemberOfClass:[DWGroupBox class]])
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
3406 tmpitem[index].type = TYPEBOX;
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
3407 else
1086
4254c9b6d50d Merge all 3 box packing functions into one internal function on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1079
diff changeset
3408 {
4254c9b6d50d Merge all 3 box packing functions into one internal function on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1079
diff changeset
3409 if ( width == 0 && hsize == FALSE )
4254c9b6d50d Merge all 3 box packing functions into one internal function on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1079
diff changeset
3410 dw_messagebox(funcname, DW_MB_OK|DW_MB_ERROR, "Width and expand Horizonal both unset for box: %x item: %x",box,item);
4254c9b6d50d Merge all 3 box packing functions into one internal function on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1079
diff changeset
3411 if ( height == 0 && vsize == FALSE )
4254c9b6d50d Merge all 3 box packing functions into one internal function on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1079
diff changeset
3412 dw_messagebox(funcname, DW_MB_OK|DW_MB_ERROR, "Height and expand Vertical both unset for box: %x item: %x",box,item);
1128
7d7535f6bc4e Added ability to set background color of MLE; setting foreground still outstanding.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1120
diff changeset
3413
1086
4254c9b6d50d Merge all 3 box packing functions into one internal function on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1079
diff changeset
3414 tmpitem[index].type = TYPEITEM;
4254c9b6d50d Merge all 3 box packing functions into one internal function on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1079
diff changeset
3415 }
1077
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
3416
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
3417 tmpitem[index].hwnd = item;
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
3418 tmpitem[index].origwidth = tmpitem[index].width = width;
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
3419 tmpitem[index].origheight = tmpitem[index].height = height;
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
3420 tmpitem[index].pad = pad;
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
3421 if(hsize)
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
3422 tmpitem[index].hsize = SIZEEXPAND;
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
3423 else
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
3424 tmpitem[index].hsize = SIZESTATIC;
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
3425
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
3426 if(vsize)
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
3427 tmpitem[index].vsize = SIZEEXPAND;
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
3428 else
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
3429 tmpitem[index].vsize = SIZESTATIC;
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
3430
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
3431 thisbox->items = tmpitem;
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
3432
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
3433 /* Update the item count */
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
3434 thisbox->count++;
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
3435
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
3436 /* Add the item to the box */
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
3437 [view addSubview:this];
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
3438 /* If we are packing a button... */
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
3439 if([this isMemberOfClass:[DWButton class]])
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
3440 {
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
3441 DWButton *button = (DWButton *)this;
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
3442
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
3443 /* Save the parent box so radio
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
3444 * buttons can use it later.
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
3445 */
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
3446 [button setParent:view];
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
3447 }
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
3448
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
3449 /* Free the old data */
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
3450 if(thisbox->count)
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
3451 free(thisitem);
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
3452 DW_MUTEX_UNLOCK;
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
3453 }
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
3454
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
3455 /*
1086
4254c9b6d50d Merge all 3 box packing functions into one internal function on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1079
diff changeset
3456 * Pack windows (widgets) into a box at an arbitrary location.
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3457 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3458 * 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
3459 * item: Window handle of the item to be back.
1128
7d7535f6bc4e Added ability to set background color of MLE; setting foreground still outstanding.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1120
diff changeset
3460 * index: 0 based index of packed items.
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3461 * 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
3462 * 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
3463 * 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
3464 * 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
3465 * 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
3466 */
1086
4254c9b6d50d Merge all 3 box packing functions into one internal function on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1079
diff changeset
3467 void API dw_box_pack_at_index(HWND box, HWND item, int index, int width, int height, int hsize, int vsize, int pad)
4254c9b6d50d Merge all 3 box packing functions into one internal function on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1079
diff changeset
3468 {
4254c9b6d50d Merge all 3 box packing functions into one internal function on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1079
diff changeset
3469 _dw_box_pack(box, item, index, width, height, hsize, vsize, pad, "dw_box_pack_at_index()");
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3470 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3471
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3472 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3473 * 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
3474 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3475 * 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
3476 * 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
3477 * 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
3478 * 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
3479 * 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
3480 * 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
3481 * 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
3482 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3483 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
3484 {
1128
7d7535f6bc4e Added ability to set background color of MLE; setting foreground still outstanding.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1120
diff changeset
3485 /* 65536 is the table limit on GTK...
1086
4254c9b6d50d Merge all 3 box packing functions into one internal function on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1079
diff changeset
3486 * seems like a high enough value we will never hit it here either.
4254c9b6d50d Merge all 3 box packing functions into one internal function on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1079
diff changeset
3487 */
4254c9b6d50d Merge all 3 box packing functions into one internal function on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1079
diff changeset
3488 _dw_box_pack(box, item, 65536, width, height, hsize, vsize, pad, "dw_box_pack_start()");
4254c9b6d50d Merge all 3 box packing functions into one internal function on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1079
diff changeset
3489 }
4254c9b6d50d Merge all 3 box packing functions into one internal function on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1079
diff changeset
3490
4254c9b6d50d Merge all 3 box packing functions into one internal function on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1079
diff changeset
3491 /*
4254c9b6d50d Merge all 3 box packing functions into one internal function on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1079
diff changeset
3492 * Pack windows (widgets) into a box from the end (or bottom).
4254c9b6d50d Merge all 3 box packing functions into one internal function on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1079
diff changeset
3493 * Parameters:
4254c9b6d50d Merge all 3 box packing functions into one internal function on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1079
diff changeset
3494 * box: Window handle of the box to be packed into.
4254c9b6d50d Merge all 3 box packing functions into one internal function on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1079
diff changeset
3495 * item: Window handle of the item to be back.
4254c9b6d50d Merge all 3 box packing functions into one internal function on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1079
diff changeset
3496 * width: Width in pixels of the item or -1 to be self determined.
4254c9b6d50d Merge all 3 box packing functions into one internal function on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1079
diff changeset
3497 * height: Height in pixels of the item or -1 to be self determined.
4254c9b6d50d Merge all 3 box packing functions into one internal function on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1079
diff changeset
3498 * hsize: TRUE if the window (widget) should expand horizontally to fill space given.
4254c9b6d50d Merge all 3 box packing functions into one internal function on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1079
diff changeset
3499 * vsize: TRUE if the window (widget) should expand vertically to fill space given.
4254c9b6d50d Merge all 3 box packing functions into one internal function on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1079
diff changeset
3500 * pad: Number of pixels of padding around the item.
4254c9b6d50d Merge all 3 box packing functions into one internal function on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1079
diff changeset
3501 */
4254c9b6d50d Merge all 3 box packing functions into one internal function on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1079
diff changeset
3502 void API dw_box_pack_end(HWND box, HWND item, int width, int height, int hsize, int vsize, int pad)
4254c9b6d50d Merge all 3 box packing functions into one internal function on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1079
diff changeset
3503 {
4254c9b6d50d Merge all 3 box packing functions into one internal function on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1079
diff changeset
3504 _dw_box_pack(box, item, 0, width, height, hsize, vsize, pad, "dw_box_pack_end()");
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3505 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3506
685
314a12dccd20 Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 684
diff changeset
3507 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
3508 {
744
9882b0dfa304 Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 743
diff changeset
3509 DWButton *button = [[DWButton alloc] init];
983
6abf763838c6 Allow checboxes and other "buttons" to have a blank title instead of the default "Button"
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 982
diff changeset
3510 if(text)
744
9882b0dfa304 Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 743
diff changeset
3511 {
9882b0dfa304 Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 743
diff changeset
3512 [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
3513 }
9882b0dfa304 Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 743
diff changeset
3514 [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
3515 [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
3516 [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
3517 [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
3518 [button setBezelStyle:NSThickerSquareBezelStyle];
1093
25707e9f5ad1 Reverted the image scaling on buttons on Mac so it remains consistent on other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1086
diff changeset
3519 /* TODO: Reenable scaling in the future if it is possible on other platforms.
25707e9f5ad1 Reverted the image scaling on buttons on Mac so it remains consistent on other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1086
diff changeset
3520 [[button cell] setImageScaling:NSImageScaleProportionallyDown]; */
744
9882b0dfa304 Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 743
diff changeset
3521 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
3522 {
9882b0dfa304 Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 743
diff changeset
3523 [[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
3524 }
669
62aae18e7b7d Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 668
diff changeset
3525 return button;
62aae18e7b7d Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 668
diff changeset
3526 }
62aae18e7b7d Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 668
diff changeset
3527
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3528 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3529 * 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
3530 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3531 * 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
3532 * 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
3533 */
685
314a12dccd20 Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 684
diff changeset
3534 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
3535 {
314a12dccd20 Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 684
diff changeset
3536 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
3537 [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
3538 [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
3539 [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
3540 [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
3541 [[button cell] setControlTint:NSBlueControlTint];
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3542 return button;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3543 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3544
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 * 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
3547 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3548 * 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
3549 * 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
3550 */
685
314a12dccd20 Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 684
diff changeset
3551 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
3552 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3553 DWEntryField *entry = [[DWEntryField alloc] init];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3554 [entry setStringValue:[ NSString stringWithUTF8String:text ]];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3555 [entry setTag:cid];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3556 return entry;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3557 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3558
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3559 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3560 * 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
3561 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3562 * 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
3563 * 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
3564 */
685
314a12dccd20 Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 684
diff changeset
3565 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
3566 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3567 DWEntryFieldPassword *entry = [[DWEntryFieldPassword alloc] init];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3568 [entry setStringValue:[ NSString stringWithUTF8String:text ]];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3569 [entry setTag:cid];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3570 return entry;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3571 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3572
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3573 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3574 * Sets the entryfield character limit.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3575 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3576 * 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
3577 * 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
3578 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3579 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
3580 {
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
3581 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
3582 DWEntryFieldFormatter *formatter = [[DWEntryFieldFormatter alloc] init];
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
3583
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
3584 [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
3585 [[entry cell] setFormatter:formatter];
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3586 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3587
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3588 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3589 * 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
3590 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3591 * 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
3592 * 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
3593 */
670
0b920d0dc13e Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 669
diff changeset
3594 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
3595 {
0b920d0dc13e Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 669
diff changeset
3596 NSBundle *bundle = [NSBundle mainBundle];
0b920d0dc13e Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 669
diff changeset
3597 NSString *respath = [bundle resourcePath];
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
3598 NSString *filepath = [respath stringByAppendingFormat:@"/%u.png", resid];
749
9e147366147b Code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 748
diff changeset
3599 NSImage *image = [[NSImage alloc] initWithContentsOfFile:filepath];
9e147366147b Code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 748
diff changeset
3600 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
3601 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
3602 {
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
3603 [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
3604 }
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
3605 [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
3606 [image release];
749
9e147366147b Code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 748
diff changeset
3607 return button;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3608 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3609
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3610 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3611 * 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
3612 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3613 * 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
3614 * 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
3615 * 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
3616 * DW pick the appropriate file extension.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3617 * (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
3618 */
685
314a12dccd20 Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 684
diff changeset
3619 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
3620 {
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
3621 char *ext = _dw_get_image_extension( filename );
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
3622
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
3623 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
3624 NSImage *image = [[NSImage alloc] initWithContentsOfFile:nstr];
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
3625
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
3626 if(!image && ext)
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
3627 {
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
3628 nstr = [nstr stringByAppendingString: [NSString stringWithUTF8String:ext]];
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
3629 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
3630 }
749
9e147366147b Code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 748
diff changeset
3631 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
3632 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
3633 {
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
3634 [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
3635 }
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
3636 [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
3637 [image release];
749
9e147366147b Code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 748
diff changeset
3638 return button;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3639 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3640
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3641 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3642 * 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
3643 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3644 * 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
3645 * 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
3646 * data: The contents of the image
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3647 * (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
3648 * len: length of str
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3649 */
685
314a12dccd20 Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 684
diff changeset
3650 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
3651 {
760
2fb17622a455 Possible fix for exception in dw_bitmapbutton_new_from_data()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 755
diff changeset
3652 NSData *thisdata = [NSData dataWithBytes:data length:len];
749
9e147366147b Code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 748
diff changeset
3653 NSImage *image = [[NSImage alloc] initWithData:thisdata];
9e147366147b Code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 748
diff changeset
3654 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
3655 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
3656 {
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
3657 [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
3658 }
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
3659 [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
3660 [image release];
749
9e147366147b Code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 748
diff changeset
3661 return button;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3662 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3663
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3664 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3665 * 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
3666 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3667 * 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
3668 * 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
3669 */
685
314a12dccd20 Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 684
diff changeset
3670 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
3671 {
678
0ec8edbb82cf Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 677
diff changeset
3672 DWSpinButton *spinbutton = [[DWSpinButton alloc] init];
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3673 NSStepper *stepper = [spinbutton stepper];
1023
8188f818eb9f Changed initial spinbutton limits to -65536 to 65536 on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1018
diff changeset
3674 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
3675 [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
3676 [stepper setTag:cid];
1023
8188f818eb9f Changed initial spinbutton limits to -65536 to 65536 on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1018
diff changeset
3677 [stepper setMinValue:-65536];
8188f818eb9f Changed initial spinbutton limits to -65536 to 65536 on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1018
diff changeset
3678 [stepper setMaxValue:65536];
8188f818eb9f Changed initial spinbutton limits to -65536 to 65536 on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1018
diff changeset
3679 [stepper setIntValue:atoi(text)];
8188f818eb9f Changed initial spinbutton limits to -65536 to 65536 on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1018
diff changeset
3680 [textfield takeIntValueFrom:stepper];
678
0ec8edbb82cf Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 677
diff changeset
3681 return spinbutton;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3682 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3683
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3684 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3685 * Sets the spinbutton value.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3686 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3687 * 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
3688 * position: Current value of the spinbutton.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3689 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3690 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
3691 {
678
0ec8edbb82cf Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 677
diff changeset
3692 DWSpinButton *spinbutton = handle;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3693 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
3694 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
3695 [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
3696 [textfield takeIntValueFrom:stepper];
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3697 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3698
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3699 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3700 * Sets the spinbutton limits.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3701 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3702 * 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
3703 * upper: Upper limit.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3704 * lower: Lower limit.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3705 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3706 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
3707 {
678
0ec8edbb82cf Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 677
diff changeset
3708 DWSpinButton *spinbutton = handle;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3709 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
3710 [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
3711 [stepper setMaxValue:(double)upper];
650
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
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3714 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3715 * 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
3716 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3717 * 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
3718 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3719 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
3720 {
678
0ec8edbb82cf Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 677
diff changeset
3721 DWSpinButton *spinbutton = handle;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3722 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
3723 return (long)[stepper integerValue];
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3724 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3725
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3726 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3727 * 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
3728 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3729 * 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
3730 * 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
3731 */
685
314a12dccd20 Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 684
diff changeset
3732 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
3733 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3734 DWButton *button = _button_new(text, cid);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3735 [button setButtonType:NSRadioButton];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3736 return button;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3737 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3738
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3739 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3740 * 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
3741 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3742 * 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
3743 * increments: Number of increments available.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3744 * 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
3745 */
685
314a12dccd20 Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 684
diff changeset
3746 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
3747 {
704
336800e9e648 Fixes to the slider control so events happen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 703
diff changeset
3748 DWSlider *slider = [[DWSlider alloc] init];
336800e9e648 Fixes to the slider control so events happen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 703
diff changeset
3749 [slider setMaxValue:(double)increments];
336800e9e648 Fixes to the slider control so events happen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 703
diff changeset
3750 [slider setMinValue:0];
336800e9e648 Fixes to the slider control so events happen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 703
diff changeset
3751 [slider setContinuous:YES];
336800e9e648 Fixes to the slider control so events happen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 703
diff changeset
3752 [slider setTarget:slider];
336800e9e648 Fixes to the slider control so events happen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 703
diff changeset
3753 [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
3754 [slider setTag:cid];
704
336800e9e648 Fixes to the slider control so events happen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 703
diff changeset
3755 return slider;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3756 }
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 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3759 * Returns the position of the slider.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3760 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3761 * 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
3762 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3763 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
3764 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3765 DWSlider *slider = handle;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3766 double val = [slider doubleValue];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3767 return (int)val;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3768 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3769
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3770 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3771 * Sets the slider position.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3772 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3773 * 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
3774 * 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
3775 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3776 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
3777 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3778 DWSlider *slider = handle;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3779 [slider setDoubleValue:(double)position];
650
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 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3783 * 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
3784 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3785 * 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
3786 * increments: Number of increments available.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3787 * 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
3788 */
685
314a12dccd20 Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 684
diff changeset
3789 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
3790 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
3791 DWScrollbar *scrollbar;
689
4199730e9889 Fixed errors creating scrollbars.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 688
diff changeset
3792 if(vertical)
4199730e9889 Fixed errors creating scrollbars.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 688
diff changeset
3793 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
3794 scrollbar = [[DWScrollbar alloc] init];
689
4199730e9889 Fixed errors creating scrollbars.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 688
diff changeset
3795 }
4199730e9889 Fixed errors creating scrollbars.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 688
diff changeset
3796 else
4199730e9889 Fixed errors creating scrollbars.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 688
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 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
3799 }
4199730e9889 Fixed errors creating scrollbars.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 688
diff changeset
3800 [scrollbar setArrowsPosition:NSScrollerArrowsDefaultSetting];
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
3801 [scrollbar setTarget:scrollbar];
689
4199730e9889 Fixed errors creating scrollbars.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 688
diff changeset
3802 [scrollbar setAction:@selector(changed:)];
4199730e9889 Fixed errors creating scrollbars.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 688
diff changeset
3803 [scrollbar setRange:0.0 andVisible:0.0];
4199730e9889 Fixed errors creating scrollbars.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 688
diff changeset
3804 [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
3805 [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
3806 [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
3807 [scrollbar setTag:cid];
689
4199730e9889 Fixed errors creating scrollbars.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 688
diff changeset
3808 [scrollbar setEnabled:YES];
4199730e9889 Fixed errors creating scrollbars.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 688
diff changeset
3809 return scrollbar;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3810 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3811
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3812 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3813 * Returns the position of the scrollbar.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3814 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3815 * 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
3816 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3817 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
3818 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3819 DWScrollbar *scrollbar = handle;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3820 float range = [scrollbar range];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3821 float fresult = [scrollbar doubleValue] * range;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3822 return (int)fresult;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3823 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3824
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3825 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3826 * Sets the scrollbar position.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3827 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3828 * 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
3829 * 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
3830 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3831 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
3832 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3833 DWScrollbar *scrollbar = handle;
933
b19e6e55fc8e Rewrote the scrollbar handler with a more accurate method and fixed a bug setting the position on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 932
diff changeset
3834 double range = [scrollbar range];
b19e6e55fc8e Rewrote the scrollbar handler with a more accurate method and fixed a bug setting the position on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 932
diff changeset
3835 double visible = [scrollbar visible];
b19e6e55fc8e Rewrote the scrollbar handler with a more accurate method and fixed a bug setting the position on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 932
diff changeset
3836 double newpos = (double)position/(range-visible);
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3837 [scrollbar setDoubleValue:newpos];
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3838 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3839
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3840 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3841 * Sets the scrollbar range.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3842 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3843 * 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
3844 * range: Maximum range value.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3845 * 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
3846 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3847 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
3848 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3849 DWScrollbar *scrollbar = handle;
933
b19e6e55fc8e Rewrote the scrollbar handler with a more accurate method and fixed a bug setting the position on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 932
diff changeset
3850 double knob = (double)visible/(double)range;
b19e6e55fc8e Rewrote the scrollbar handler with a more accurate method and fixed a bug setting the position on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 932
diff changeset
3851 [scrollbar setRange:(double)range andVisible:(double)visible];
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3852 [scrollbar setKnobProportion:knob];
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3853 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3854
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3855 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3856 * 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
3857 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3858 * 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
3859 */
685
314a12dccd20 Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 684
diff changeset
3860 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
3861 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3862 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
3863 [percent setStyle:NSProgressIndicatorBarStyle];
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3864 [percent setBezeled:YES];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3865 [percent setMaxValue:100];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3866 [percent setMinValue:0];
714
cf6246f86c04 Fixed the percent/progress indicators from always being indeterminate.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 713
diff changeset
3867 [percent incrementBy:1];
cf6246f86c04 Fixed the percent/progress indicators from always being indeterminate.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 713
diff changeset
3868 [percent setIndeterminate:NO];
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3869 /*[percent setTag:cid]; Why doesn't this work? */
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3870 return percent;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3871 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3872
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3873 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3874 * Sets the percent bar position.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3875 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3876 * 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
3877 * 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
3878 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3879 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
3880 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3881 DWPercent *percent = handle;
1190
76262040ed5f Added DW_PERCENT_INDETERMINATE which can be passed to dw_percent_set_pos() to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1176
diff changeset
3882
76262040ed5f Added DW_PERCENT_INDETERMINATE which can be passed to dw_percent_set_pos() to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1176
diff changeset
3883 /* Handle indeterminate */
76262040ed5f Added DW_PERCENT_INDETERMINATE which can be passed to dw_percent_set_pos() to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1176
diff changeset
3884 if(position == DW_PERCENT_INDETERMINATE)
1193
698875cfe8e5 Fixed the indeterminate percent bar should be animated on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1190
diff changeset
3885 {
1190
76262040ed5f Added DW_PERCENT_INDETERMINATE which can be passed to dw_percent_set_pos() to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1176
diff changeset
3886 [percent setIndeterminate:YES];
1193
698875cfe8e5 Fixed the indeterminate percent bar should be animated on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1190
diff changeset
3887 [percent startAnimation:percent];
698875cfe8e5 Fixed the indeterminate percent bar should be animated on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1190
diff changeset
3888 }
1190
76262040ed5f Added DW_PERCENT_INDETERMINATE which can be passed to dw_percent_set_pos() to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1176
diff changeset
3889 else
76262040ed5f Added DW_PERCENT_INDETERMINATE which can be passed to dw_percent_set_pos() to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1176
diff changeset
3890 {
76262040ed5f Added DW_PERCENT_INDETERMINATE which can be passed to dw_percent_set_pos() to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1176
diff changeset
3891 /* Handle normal */
76262040ed5f Added DW_PERCENT_INDETERMINATE which can be passed to dw_percent_set_pos() to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1176
diff changeset
3892 if([percent isIndeterminate])
1193
698875cfe8e5 Fixed the indeterminate percent bar should be animated on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1190
diff changeset
3893 {
698875cfe8e5 Fixed the indeterminate percent bar should be animated on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1190
diff changeset
3894 [percent stopAnimation:percent];
1190
76262040ed5f Added DW_PERCENT_INDETERMINATE which can be passed to dw_percent_set_pos() to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1176
diff changeset
3895 [percent setIndeterminate:NO];
1193
698875cfe8e5 Fixed the indeterminate percent bar should be animated on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1190
diff changeset
3896 }
1190
76262040ed5f Added DW_PERCENT_INDETERMINATE which can be passed to dw_percent_set_pos() to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1176
diff changeset
3897 [percent setDoubleValue:(double)position];
76262040ed5f Added DW_PERCENT_INDETERMINATE which can be passed to dw_percent_set_pos() to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1176
diff changeset
3898 }
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3899 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3900
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3901 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3902 * 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
3903 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3904 * 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
3905 * 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
3906 */
685
314a12dccd20 Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 684
diff changeset
3907 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
3908 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3909 DWButton *button = _button_new(text, cid);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3910 [button setButtonType:NSSwitchButton];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3911 [button setBezelStyle:NSRegularSquareBezelStyle];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3912 return button;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3913 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3914
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3915 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3916 * Returns the state of the checkbox.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3917 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3918 * 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
3919 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3920 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
3921 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3922 DWButton *button = handle;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3923 if([button state])
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3924 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3925 return TRUE;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3926 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3927 return FALSE;
650
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
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3930 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3931 * Sets the state of the checkbox.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3932 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3933 * 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
3934 * 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
3935 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3936 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
3937 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3938 DWButton *button = handle;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3939 if(value)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3940 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3941 [button setState:NSOnState];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3942 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3943 else
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3944 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3945 [button setState:NSOffState];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3946 }
656
6c8b95ca877b Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 655
diff changeset
3947
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
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
3950 /* 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
3951 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
3952 {
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
3953 NSScrollView *scrollview = [[NSScrollView alloc] init];
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3954 DWContainer *cont = [[DWContainer alloc] init];
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
3955
668
7b99731c6484 Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 667
diff changeset
3956 [cont setScrollview:scrollview];
7b99731c6484 Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 667
diff changeset
3957 [scrollview setBorderType:NSBezelBorder];
7b99731c6484 Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 667
diff changeset
3958 [scrollview setHasVerticalScroller:YES];
7b99731c6484 Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 667
diff changeset
3959 [scrollview setAutohidesScrollers:YES];
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
3960
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3961 if(multi)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3962 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3963 [cont setAllowsMultipleSelection:YES];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3964 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3965 else
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3966 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3967 [cont setAllowsMultipleSelection:NO];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3968 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3969 [cont setDataSource:cont];
813
7fa26d8cc8d0 Fix for column click handler not working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 812
diff changeset
3970 [cont setDelegate:cont];
668
7b99731c6484 Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 667
diff changeset
3971 [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
3972 [cont setTag:cid];
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3973 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
3974 }
0502e5b6743b Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 657
diff changeset
3975
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 * 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
3978 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3979 * 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
3980 * multi: Multiple select TRUE or FALSE.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3981 */
685
314a12dccd20 Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 684
diff changeset
3982 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
3983 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
3984 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
3985 DW_MUTEX_LOCK;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3986 DWContainer *cont = _cont_new(cid, multi);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3987 [cont setHeaderView:nil];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3988 int type = DW_CFA_STRING;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3989 [cont setup];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3990 NSTableColumn *column = [[NSTableColumn alloc] init];
795
f23cad02cfb3 Make listbox, container and tree cells uneditable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 794
diff changeset
3991 [column setEditable:NO];
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3992 [cont addTableColumn:column];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3993 [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
3994 DW_MUTEX_UNLOCK;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3995 return cont;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3996 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3997
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3998 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3999 * 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
4000 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4001 * 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
4002 * text: Text to append into listbox.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4003 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4004 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
4005 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
4006 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
4007 DW_MUTEX_LOCK;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4008 id object = handle;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
4009
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4010 if([object isMemberOfClass:[DWComboBox class]])
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4011 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4012 DWComboBox *combo = handle;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
4013
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4014 [combo addItemWithObjectValue:[ NSString stringWithUTF8String:text ]];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4015 }
669
62aae18e7b7d Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 668
diff changeset
4016 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
4017 {
62aae18e7b7d Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 668
diff changeset
4018 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
4019 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
4020 NSArray *newrow = [NSArray arrayWithObject:nstr];
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
4021
669
62aae18e7b7d Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 668
diff changeset
4022 [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
4023 /*[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
4024 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
4025 waitUntilDone:YES];*/
670
0b920d0dc13e Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 669
diff changeset
4026 [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
4027 [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
4028 }
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
4029 DW_MUTEX_UNLOCK;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4030 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4031
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4032 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4033 * 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
4034 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4035 * 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
4036 * text: Text to insert into listbox.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4037 * 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
4038 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4039 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
4040 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
4041 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
4042 DW_MUTEX_LOCK;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4043 id object = handle;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
4044
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4045 if([object isMemberOfClass:[DWComboBox class]])
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4046 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4047 DWComboBox *combo = handle;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
4048
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4049 [combo insertItemWithObjectValue:[ NSString stringWithUTF8String:text ] atIndex:pos];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4050 }
669
62aae18e7b7d Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 668
diff changeset
4051 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
4052 {
687
5dde8d34bc69 Implemented dw_listbox_insert for containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 686
diff changeset
4053 DWContainer *cont = handle;
5dde8d34bc69 Implemented dw_listbox_insert for containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 686
diff changeset
4054 NSString *nstr = [ NSString stringWithUTF8String:text ];
5dde8d34bc69 Implemented dw_listbox_insert for containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 686
diff changeset
4055 NSArray *newrow = [NSArray arrayWithObject:nstr];
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
4056
687
5dde8d34bc69 Implemented dw_listbox_insert for containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 686
diff changeset
4057 [cont insertRow:newrow at:pos];
5dde8d34bc69 Implemented dw_listbox_insert for containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 686
diff changeset
4058 [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
4059 [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
4060 }
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
4061 DW_MUTEX_UNLOCK;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4062 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4063
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4064 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4065 * 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
4066 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4067 * 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
4068 * 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
4069 * 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
4070 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4071 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
4072 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
4073 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
4074 DW_MUTEX_LOCK;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4075 id object = handle;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
4076
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4077 if([object isMemberOfClass:[DWComboBox class]])
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4078 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4079 DWComboBox *combo = handle;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4080 int z;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
4081
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4082 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
4083 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4084 [combo addItemWithObjectValue:[ NSString stringWithUTF8String:text[z] ]];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4085 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4086 }
669
62aae18e7b7d Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 668
diff changeset
4087 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
4088 {
62aae18e7b7d Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 668
diff changeset
4089 DWContainer *cont = handle;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4090 int z;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
4091
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4092 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
4093 {
669
62aae18e7b7d Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 668
diff changeset
4094 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
4095 NSArray *newrow = [[NSArray alloc] arrayWithObject:nstr];
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
4096
669
62aae18e7b7d Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 668
diff changeset
4097 [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
4098 }
670
0b920d0dc13e Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 669
diff changeset
4099 [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
4100 [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
4101 }
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
4102 DW_MUTEX_UNLOCK;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4103 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4104
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4105 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4106 * 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
4107 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4108 * 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
4109 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4110 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
4111 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
4112 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
4113 DW_MUTEX_LOCK;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4114 id object = handle;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
4115
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4116 if([object isMemberOfClass:[DWComboBox class]])
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4117 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4118 DWComboBox *combo = handle;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
4119
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4120 [combo removeAllItems];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4121 }
669
62aae18e7b7d Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 668
diff changeset
4122 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
4123 {
62aae18e7b7d Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 668
diff changeset
4124 DWContainer *cont = handle;
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
4125
669
62aae18e7b7d Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 668
diff changeset
4126 [cont clear];
670
0b920d0dc13e Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 669
diff changeset
4127 [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
4128 [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
4129 }
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
4130 DW_MUTEX_UNLOCK;
650
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 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4134 * Returns the listbox's item count.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4135 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4136 * 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
4137 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4138 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
4139 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4140 id object = handle;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
4141
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4142 if([object isMemberOfClass:[DWComboBox class]])
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4143 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4144 DWComboBox *combo = handle;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
4145
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4146 return (int)[combo numberOfItems];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4147 }
669
62aae18e7b7d Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 668
diff changeset
4148 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
4149 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
4150 int _locked_by_me = FALSE;
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
4151 DW_MUTEX_LOCK;
669
62aae18e7b7d Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 668
diff changeset
4152 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
4153 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
4154 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
4155 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
4156 }
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4157 return 0;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4158 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4159
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4160 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4161 * 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
4162 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4163 * 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
4164 * top: Index to the top item.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4165 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4166 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
4167 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
4168 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
4169 DW_MUTEX_LOCK;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4170 id object = handle;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
4171
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4172 if([object isMemberOfClass:[DWComboBox class]])
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4173 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4174 DWComboBox *combo = handle;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
4175
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4176 [combo scrollItemAtIndexToTop:top];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4177 }
669
62aae18e7b7d Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 668
diff changeset
4178 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
4179 {
62aae18e7b7d Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 668
diff changeset
4180 DWContainer *cont = handle;
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
4181
669
62aae18e7b7d Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 668
diff changeset
4182 [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
4183 }
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
4184 DW_MUTEX_UNLOCK;
650
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 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4188 * 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
4189 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4190 * 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
4191 * 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
4192 * 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
4193 * 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
4194 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4195 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
4196 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
4197 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
4198 DW_MUTEX_LOCK;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4199 id object = handle;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
4200
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4201 if([object isMemberOfClass:[DWComboBox class]])
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4202 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4203 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
4204 int count = (int)[combo numberOfItems];
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
4205
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
4206 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
4207 {
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
4208 *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
4209 }
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
4210 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
4211 {
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
4212 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
4213 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
4214 }
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4215 }
669
62aae18e7b7d Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 668
diff changeset
4216 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
4217 {
62aae18e7b7d Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 668
diff changeset
4218 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
4219 int count = (int)[cont numberOfRowsInTableView:cont];
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
4220
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
4221 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
4222 {
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
4223 *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
4224 }
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
4225 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
4226 {
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
4227 NSString *nstr = [cont getRow:index and:0];
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
4228
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
4229 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
4230 }
669
62aae18e7b7d Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 668
diff changeset
4231 }
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
4232 DW_MUTEX_UNLOCK;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4233 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4234
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4235 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4236 * 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
4237 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4238 * 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
4239 * 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
4240 * 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
4241 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4242 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
4243 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
4244 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
4245 DW_MUTEX_LOCK;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4246 id object = handle;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
4247
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4248 if([object isMemberOfClass:[DWComboBox class]])
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4249 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4250 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
4251 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
4252
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
4253 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
4254 {
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
4255 [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
4256 [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
4257 }
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4258 }
669
62aae18e7b7d Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 668
diff changeset
4259 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
4260 {
62aae18e7b7d Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 668
diff changeset
4261 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
4262 int count = (int)[cont numberOfRowsInTableView:cont];
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
4263
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
4264 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
4265 {
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
4266 NSString *nstr = [ NSString stringWithUTF8String:buffer ];
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
4267
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
4268 [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
4269 [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
4270 [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
4271 }
669
62aae18e7b7d Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 668
diff changeset
4272 }
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
4273 DW_MUTEX_UNLOCK;
650
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
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4276 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4277 * 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
4278 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4279 * 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
4280 */
986
87dc0f5f96d0 Fix return type of dw_listbox_selected() to be "int" instead of "unsigned int" to allow -1 return.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 983
diff changeset
4281 int API dw_listbox_selected(HWND handle)
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4282 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4283 id object = handle;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
4284
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4285 if([object isMemberOfClass:[DWComboBox class]])
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4286 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4287 DWComboBox *combo = handle;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4288 return (int)[combo indexOfSelectedItem];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4289 }
669
62aae18e7b7d Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 668
diff changeset
4290 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
4291 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
4292 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
4293 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
4294 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
4295 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
4296 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
4297 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
4298 }
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4299 return -1;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4300 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4301
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4302 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4303 * 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
4304 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4305 * 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
4306 * 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
4307 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4308 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
4309 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
4310 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
4311 DW_MUTEX_LOCK;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4312 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
4313 int retval = -1;
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
4314
669
62aae18e7b7d Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 668
diff changeset
4315 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
4316 {
981
536ec60ee433 Don't destroy a pixmap if the handle is null
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 980
diff changeset
4317 NSUInteger result;
669
62aae18e7b7d Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 668
diff changeset
4318 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
4319 NSIndexSet *selected = [cont selectedRowIndexes];
981
536ec60ee433 Don't destroy a pixmap if the handle is null
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 980
diff changeset
4320 if( where == -1 )
536ec60ee433 Don't destroy a pixmap if the handle is null
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 980
diff changeset
4321 result = [selected indexGreaterThanOrEqualToIndex:0];
536ec60ee433 Don't destroy a pixmap if the handle is null
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 980
diff changeset
4322 else
536ec60ee433 Don't destroy a pixmap if the handle is null
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 980
diff changeset
4323 result = [selected indexGreaterThanIndex:where];
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
4324
669
62aae18e7b7d Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 668
diff changeset
4325 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
4326 {
62aae18e7b7d Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 668
diff changeset
4327 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
4328 }
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
4329 }
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
4330 DW_MUTEX_UNLOCK;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4331 return retval;
650
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
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4334 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4335 * 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
4336 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4337 * 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
4338 * index: Item index.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4339 * 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
4340 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4341 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
4342 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
4343 int _locked_by_me = FALSE;
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
4344 DW_MUTEX_LOCK;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4345 id object = handle;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
4346
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4347 if([object isMemberOfClass:[DWComboBox class]])
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4348 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4349 DWComboBox *combo = handle;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4350 if(state)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4351 [combo selectItemAtIndex:index];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4352 else
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4353 [combo deselectItemAtIndex:index];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4354 }
669
62aae18e7b7d Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 668
diff changeset
4355 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
4356 {
62aae18e7b7d Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 668
diff changeset
4357 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
4358 NSIndexSet *selected = [[NSIndexSet alloc] initWithIndex:(NSUInteger)index];
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
4359
669
62aae18e7b7d Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 668
diff changeset
4360 [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
4361 [selected release];
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
4362 }
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
4363 DW_MUTEX_UNLOCK;
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 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4367 * 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
4368 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4369 * 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
4370 * index: Item index.
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_listbox_delete(HWND handle, int index)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4373 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
4374 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
4375 DW_MUTEX_LOCK;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4376 id object = handle;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
4377
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4378 if([object isMemberOfClass:[DWComboBox class]])
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4379 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4380 DWComboBox *combo = handle;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
4381
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4382 [combo removeItemAtIndex:index];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4383 }
669
62aae18e7b7d Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 668
diff changeset
4384 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
4385 {
62aae18e7b7d Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 668
diff changeset
4386 DWContainer *cont = handle;
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
4387
669
62aae18e7b7d Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 668
diff changeset
4388 [cont removeRow:index];
670
0b920d0dc13e Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 669
diff changeset
4389 [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
4390 [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
4391 }
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
4392 DW_MUTEX_UNLOCK;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4393 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4394
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4395 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4396 * 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
4397 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4398 * 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
4399 * 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
4400 */
685
314a12dccd20 Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 684
diff changeset
4401 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
4402 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4403 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
4404 [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
4405 [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
4406 [combo setTag:cid];
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4407 return combo;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4408 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4409
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4410 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4411 * 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
4412 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4413 * 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
4414 */
685
314a12dccd20 Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 684
diff changeset
4415 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
4416 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4417 DWMLE *mle = [[DWMLE alloc] init];
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
4418 NSScrollView *scrollview = [[NSScrollView alloc] init];
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
4419
676
9861d264925d MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 675
diff changeset
4420 [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
4421 [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
4422 [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
4423 [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
4424 [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
4425 [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
4426 /* [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
4427 [mle release];
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4428 return scrollview;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
4429 }
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4430
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4431 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4432 * 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
4433 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4434 * 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
4435 * buffer: Text buffer to be imported.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4436 * startpoint: Point to start entering text.
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 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
4439 {
676
9861d264925d MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 675
diff changeset
4440 NSScrollView *sv = handle;
1204
5cb7e52f76c7 Put Mac MLE under mutex protection because of crashes when accessing the MLE from threads.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1202
diff changeset
4441 int _locked_by_me = FALSE;
5cb7e52f76c7 Put Mac MLE under mutex protection because of crashes when accessing the MLE from threads.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1202
diff changeset
4442 DW_MUTEX_LOCK;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4443 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
4444 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
4445 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
4446 NSMutableString *ms = [ts mutableString];
992
2d80b4dcff9a A few MLE fixes on the Mac... and a slightly updated dwtest for MLE testing.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 989
diff changeset
4447 NSUInteger length = [ms length];
2d80b4dcff9a A few MLE fixes on the Mac... and a slightly updated dwtest for MLE testing.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 989
diff changeset
4448 if(startpoint < 0)
2d80b4dcff9a A few MLE fixes on the Mac... and a slightly updated dwtest for MLE testing.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 989
diff changeset
4449 startpoint = 0;
2d80b4dcff9a A few MLE fixes on the Mac... and a slightly updated dwtest for MLE testing.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 989
diff changeset
4450 if(startpoint > length)
2d80b4dcff9a A few MLE fixes on the Mac... and a slightly updated dwtest for MLE testing.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 989
diff changeset
4451 startpoint = (int)length;
2d80b4dcff9a A few MLE fixes on the Mac... and a slightly updated dwtest for MLE testing.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 989
diff changeset
4452 [ms insertString:nstr atIndex:startpoint];
1204
5cb7e52f76c7 Put Mac MLE under mutex protection because of crashes when accessing the MLE from threads.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1202
diff changeset
4453 DW_MUTEX_UNLOCK;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4454 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
4455 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4456
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4457 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4458 * Grabs text from an MLE box.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4459 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4460 * 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
4461 * buffer: Text buffer to be exported.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4462 * startpoint: Point to start grabbing text.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4463 * 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
4464 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4465 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
4466 {
676
9861d264925d MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 675
diff changeset
4467 NSScrollView *sv = handle;
1204
5cb7e52f76c7 Put Mac MLE under mutex protection because of crashes when accessing the MLE from threads.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1202
diff changeset
4468 int _locked_by_me = FALSE;
5cb7e52f76c7 Put Mac MLE under mutex protection because of crashes when accessing the MLE from threads.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1202
diff changeset
4469 DW_MUTEX_LOCK;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4470 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
4471 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
4472 NSMutableString *ms = [ts mutableString];
1128
7d7535f6bc4e Added ability to set background color of MLE; setting foreground still outstanding.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1120
diff changeset
4473 const char *tmp = [ms UTF8String];
7d7535f6bc4e Added ability to set background color of MLE; setting foreground still outstanding.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1120
diff changeset
4474 strncpy(buffer, tmp+startpoint, length);
1129
ab73d0269a5b Ensure default keypress event is not processed if handler returns 1
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1128
diff changeset
4475 buffer[length] = '\0';
1204
5cb7e52f76c7 Put Mac MLE under mutex protection because of crashes when accessing the MLE from threads.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1202
diff changeset
4476 DW_MUTEX_UNLOCK;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4477 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4478
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4479 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4480 * Obtains information about an MLE box.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4481 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4482 * 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
4483 * 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
4484 * 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
4485 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4486 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
4487 {
676
9861d264925d MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 675
diff changeset
4488 NSScrollView *sv = handle;
1204
5cb7e52f76c7 Put Mac MLE under mutex protection because of crashes when accessing the MLE from threads.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1202
diff changeset
4489 int _locked_by_me = FALSE;
5cb7e52f76c7 Put Mac MLE under mutex protection because of crashes when accessing the MLE from threads.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1202
diff changeset
4490 DW_MUTEX_LOCK;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4491 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
4492 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
4493 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
4494 NSUInteger numberOfLines, index, stringLength = [ms length];
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
4495
992
2d80b4dcff9a A few MLE fixes on the Mac... and a slightly updated dwtest for MLE testing.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 989
diff changeset
4496 if(bytes)
2d80b4dcff9a A few MLE fixes on the Mac... and a slightly updated dwtest for MLE testing.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 989
diff changeset
4497 *bytes = stringLength;
2d80b4dcff9a A few MLE fixes on the Mac... and a slightly updated dwtest for MLE testing.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 989
diff changeset
4498 if(lines)
2d80b4dcff9a A few MLE fixes on the Mac... and a slightly updated dwtest for MLE testing.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 989
diff changeset
4499 {
2d80b4dcff9a A few MLE fixes on the Mac... and a slightly updated dwtest for MLE testing.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 989
diff changeset
4500 for(index=0, numberOfLines=0; index < stringLength; numberOfLines++)
2d80b4dcff9a A few MLE fixes on the Mac... and a slightly updated dwtest for MLE testing.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 989
diff changeset
4501 index = NSMaxRange([ms lineRangeForRange:NSMakeRange(index, 0)]);
1041
6a57bf20d8f9 Return displayName property instead of fontName property in dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1040
diff changeset
4502
992
2d80b4dcff9a A few MLE fixes on the Mac... and a slightly updated dwtest for MLE testing.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 989
diff changeset
4503 *lines = numberOfLines;
2d80b4dcff9a A few MLE fixes on the Mac... and a slightly updated dwtest for MLE testing.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 989
diff changeset
4504 }
1204
5cb7e52f76c7 Put Mac MLE under mutex protection because of crashes when accessing the MLE from threads.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1202
diff changeset
4505 DW_MUTEX_LOCK;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4506 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4507
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4508 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4509 * Deletes text from an MLE box.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4510 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4511 * 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
4512 * startpoint: Point to start deleting text.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4513 * 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
4514 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4515 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
4516 {
676
9861d264925d MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 675
diff changeset
4517 NSScrollView *sv = handle;
1204
5cb7e52f76c7 Put Mac MLE under mutex protection because of crashes when accessing the MLE from threads.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1202
diff changeset
4518 int _locked_by_me = FALSE;
5cb7e52f76c7 Put Mac MLE under mutex protection because of crashes when accessing the MLE from threads.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1202
diff changeset
4519 DW_MUTEX_LOCK;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4520 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
4521 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
4522 NSMutableString *ms = [ts mutableString];
992
2d80b4dcff9a A few MLE fixes on the Mac... and a slightly updated dwtest for MLE testing.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 989
diff changeset
4523 NSUInteger mslength = [ms length];
2d80b4dcff9a A few MLE fixes on the Mac... and a slightly updated dwtest for MLE testing.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 989
diff changeset
4524 if(startpoint < 0)
2d80b4dcff9a A few MLE fixes on the Mac... and a slightly updated dwtest for MLE testing.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 989
diff changeset
4525 startpoint = 0;
2d80b4dcff9a A few MLE fixes on the Mac... and a slightly updated dwtest for MLE testing.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 989
diff changeset
4526 if(startpoint > mslength)
2d80b4dcff9a A few MLE fixes on the Mac... and a slightly updated dwtest for MLE testing.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 989
diff changeset
4527 startpoint = (int)mslength;
2d80b4dcff9a A few MLE fixes on the Mac... and a slightly updated dwtest for MLE testing.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 989
diff changeset
4528 if(startpoint + length > mslength)
2d80b4dcff9a A few MLE fixes on the Mac... and a slightly updated dwtest for MLE testing.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 989
diff changeset
4529 length = (int)mslength - startpoint;
2d80b4dcff9a A few MLE fixes on the Mac... and a slightly updated dwtest for MLE testing.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 989
diff changeset
4530 [ms deleteCharactersInRange:NSMakeRange(startpoint, length)];
1204
5cb7e52f76c7 Put Mac MLE under mutex protection because of crashes when accessing the MLE from threads.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1202
diff changeset
4531 DW_MUTEX_UNLOCK;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4532 }
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 * 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
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 MLE to be cleared.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4538 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4539 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
4540 {
676
9861d264925d MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 675
diff changeset
4541 NSScrollView *sv = handle;
1204
5cb7e52f76c7 Put Mac MLE under mutex protection because of crashes when accessing the MLE from threads.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1202
diff changeset
4542 int _locked_by_me = FALSE;
5cb7e52f76c7 Put Mac MLE under mutex protection because of crashes when accessing the MLE from threads.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1202
diff changeset
4543 DW_MUTEX_LOCK;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4544 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
4545 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
4546 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
4547 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
4548 [ms deleteCharactersInRange:NSMakeRange(0, length)];
1204
5cb7e52f76c7 Put Mac MLE under mutex protection because of crashes when accessing the MLE from threads.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1202
diff changeset
4549 DW_MUTEX_UNLOCK;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4550 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4551
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4552 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4553 * 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
4554 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4555 * 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
4556 * line: Line to be visible.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4557 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4558 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
4559 {
802
676d46b31a11 Initial implementation of dw_mle_set_visible().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 801
diff changeset
4560 NSScrollView *sv = handle;
1204
5cb7e52f76c7 Put Mac MLE under mutex protection because of crashes when accessing the MLE from threads.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1202
diff changeset
4561 int _locked_by_me = FALSE;
5cb7e52f76c7 Put Mac MLE under mutex protection because of crashes when accessing the MLE from threads.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1202
diff changeset
4562 DW_MUTEX_LOCK;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4563 DWMLE *mle = [sv documentView];
802
676d46b31a11 Initial implementation of dw_mle_set_visible().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 801
diff changeset
4564 NSTextStorage *ts = [mle textStorage];
676d46b31a11 Initial implementation of dw_mle_set_visible().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 801
diff changeset
4565 NSMutableString *ms = [ts mutableString];
676d46b31a11 Initial implementation of dw_mle_set_visible().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 801
diff changeset
4566 NSUInteger numberOfLines, index, stringLength = [ms length];
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
4567
802
676d46b31a11 Initial implementation of dw_mle_set_visible().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 801
diff changeset
4568 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
4569 index = NSMaxRange([ms lineRangeForRange:NSMakeRange(index, 0)]);
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
4570
802
676d46b31a11 Initial implementation of dw_mle_set_visible().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 801
diff changeset
4571 if(line == numberOfLines)
676d46b31a11 Initial implementation of dw_mle_set_visible().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 801
diff changeset
4572 {
676d46b31a11 Initial implementation of dw_mle_set_visible().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 801
diff changeset
4573 [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
4574 }
1204
5cb7e52f76c7 Put Mac MLE under mutex protection because of crashes when accessing the MLE from threads.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1202
diff changeset
4575 DW_MUTEX_UNLOCK;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4576 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4577
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4578 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4579 * 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
4580 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4581 * handle: Handle to the MLE.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4582 * 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
4583 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4584 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
4585 {
676
9861d264925d MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 675
diff changeset
4586 NSScrollView *sv = handle;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4587 DWMLE *mle = [sv documentView];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4588 if(state)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4589 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4590 [mle setEditable:YES];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4591 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4592 else
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4593 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4594 [mle setEditable:NO];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4595 }
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4596 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4597
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4598 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4599 * 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
4600 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4601 * handle: Handle to the MLE.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4602 * 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
4603 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4604 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
4605 {
676
9861d264925d MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 675
diff changeset
4606 NSScrollView *sv = handle;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4607 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
4608 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
4609 {
48f8efba898f Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 674
diff changeset
4610 [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
4611 }
48f8efba898f Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 674
diff changeset
4612 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
4613 {
48f8efba898f Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 674
diff changeset
4614 [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
4615 }
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4616 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4617
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4618 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4619 * 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
4620 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4621 * 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
4622 * point: Point to position cursor.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4623 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4624 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
4625 {
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
4626 NSScrollView *sv = handle;
1204
5cb7e52f76c7 Put Mac MLE under mutex protection because of crashes when accessing the MLE from threads.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1202
diff changeset
4627 int _locked_by_me = FALSE;
5cb7e52f76c7 Put Mac MLE under mutex protection because of crashes when accessing the MLE from threads.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1202
diff changeset
4628 DW_MUTEX_LOCK;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4629 DWMLE *mle = [sv documentView];
989
6de00477d627 Clamp the point specified in dw_mle_set_cursor() to the range of text to avoid an exception on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 986
diff changeset
4630 NSTextStorage *ts = [mle textStorage];
6de00477d627 Clamp the point specified in dw_mle_set_cursor() to the range of text to avoid an exception on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 986
diff changeset
4631 NSMutableString *ms = [ts mutableString];
6de00477d627 Clamp the point specified in dw_mle_set_cursor() to the range of text to avoid an exception on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 986
diff changeset
4632 NSUInteger length = [ms length];
6de00477d627 Clamp the point specified in dw_mle_set_cursor() to the range of text to avoid an exception on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 986
diff changeset
4633 if(point < 0)
6de00477d627 Clamp the point specified in dw_mle_set_cursor() to the range of text to avoid an exception on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 986
diff changeset
4634 point = 0;
6de00477d627 Clamp the point specified in dw_mle_set_cursor() to the range of text to avoid an exception on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 986
diff changeset
4635 if(point > length)
6de00477d627 Clamp the point specified in dw_mle_set_cursor() to the range of text to avoid an exception on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 986
diff changeset
4636 point = (int)length;
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
4637 [mle setSelectedRange: NSMakeRange(point,point)];
1201
196cd8a8e6a8 Fixed dw_mle_set_cursor() should scroll to the point on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1193
diff changeset
4638 [mle scrollRangeToVisible:NSMakeRange(point,point)];
1204
5cb7e52f76c7 Put Mac MLE under mutex protection because of crashes when accessing the MLE from threads.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1202
diff changeset
4639 DW_MUTEX_UNLOCK;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4640 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4641
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4642 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4643 * Finds text in an MLE box.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4644 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4645 * 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
4646 * text: Text to search for.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4647 * point: Start point of search.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4648 * flags: Search specific flags.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4649 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4650 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
4651 {
888
cd6ff038e38b Implemented dw_mle_search on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 887
diff changeset
4652 NSScrollView *sv = handle;
1204
5cb7e52f76c7 Put Mac MLE under mutex protection because of crashes when accessing the MLE from threads.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1202
diff changeset
4653 int _locked_by_me = FALSE;
5cb7e52f76c7 Put Mac MLE under mutex protection because of crashes when accessing the MLE from threads.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1202
diff changeset
4654 DW_MUTEX_LOCK;
888
cd6ff038e38b Implemented dw_mle_search on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 887
diff changeset
4655 DWMLE *mle = [sv documentView];
cd6ff038e38b Implemented dw_mle_search on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 887
diff changeset
4656 NSTextStorage *ts = [mle textStorage];
cd6ff038e38b Implemented dw_mle_search on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 887
diff changeset
4657 NSMutableString *ms = [ts mutableString];
cd6ff038e38b Implemented dw_mle_search on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 887
diff changeset
4658 NSString *searchForMe = [NSString stringWithUTF8String:text];
cd6ff038e38b Implemented dw_mle_search on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 887
diff changeset
4659 NSRange searchRange = NSMakeRange(point, [ms length] - point);
cd6ff038e38b Implemented dw_mle_search on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 887
diff changeset
4660 NSRange range = NSMakeRange(NSNotFound, 0);
cd6ff038e38b Implemented dw_mle_search on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 887
diff changeset
4661 NSUInteger options = flags ? flags : NSCaseInsensitiveSearch;
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
4662
888
cd6ff038e38b Implemented dw_mle_search on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 887
diff changeset
4663 if(ms)
cd6ff038e38b Implemented dw_mle_search on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 887
diff changeset
4664 {
cd6ff038e38b Implemented dw_mle_search on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 887
diff changeset
4665 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
4666 }
1204
5cb7e52f76c7 Put Mac MLE under mutex protection because of crashes when accessing the MLE from threads.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1202
diff changeset
4667 DW_MUTEX_UNLOCK;
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
4668 if(range.location != NSNotFound)
888
cd6ff038e38b Implemented dw_mle_search on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 887
diff changeset
4669 {
cd6ff038e38b Implemented dw_mle_search on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 887
diff changeset
4670 return -1;
cd6ff038e38b Implemented dw_mle_search on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 887
diff changeset
4671 }
cd6ff038e38b Implemented dw_mle_search on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 887
diff changeset
4672 return (int)range.location;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4673 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4674
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4675 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4676 * Stops redrawing of an MLE box.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4677 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4678 * handle: Handle to the MLE to freeze.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4679 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4680 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
4681 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4682 /* 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
4683 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4684
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4685 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4686 * Resumes redrawing of an MLE box.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4687 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4688 * 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
4689 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4690 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
4691 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4692 /* 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
4693 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4694
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4695 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4696 * 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
4697 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4698 * 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
4699 * 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
4700 */
685
314a12dccd20 Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 684
diff changeset
4701 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
4702 {
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
4703 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
4704 [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
4705 if(DWOSMinor > 5)
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4706 {
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
4707 [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
4708 [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
4709 }
eba6ab48c952 Runtime Snow Leopard checks where possible and visual fix for Leopard status text.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 749
diff changeset
4710 [textfield setBackgroundColor:[NSColor clearColor]];
673
6d0f0dc7ff7c Some minor font fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 672
diff changeset
4711 [textfield setDrawsBackground:NO];
931
dfd84cefd80b Minor changes to vertical centering on (status) text fields on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 930
diff changeset
4712 [[textfield cell] setVCenter:YES];
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
4713 return textfield;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4714 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4715
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4716 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4717 * 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
4718 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4719 * 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
4720 * 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
4721 */
685
314a12dccd20 Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 684
diff changeset
4722 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
4723 {
744
9882b0dfa304 Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 743
diff changeset
4724 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
4725 [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
4726 [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
4727 [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
4728 [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
4729 [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
4730 [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
4731 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
4732 {
9882b0dfa304 Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 743
diff changeset
4733 [[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
4734 }
9882b0dfa304 Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 743
diff changeset
4735 return textfield;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4736 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4737
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4738 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4739 * 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
4740 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4741 * 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
4742 * Returns:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4743 * 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
4744 */
685
314a12dccd20 Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 684
diff changeset
4745 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
4746 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4747 DWRender *render = [[DWRender alloc] init];
922
07f9a73c6847 Fix for button press/release events coordinates being relative to the window instead of the screen on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 921
diff changeset
4748 [render setTag:cid];
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4749 return render;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4750 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4751
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4752 /* Sets the current foreground drawing color.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4753 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4754 * red: red value.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4755 * green: green value.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4756 * blue: blue value.
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 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
4759 {
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
4760 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
4761 NSColor *newcolor;
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
4762
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4763 _foreground = _get_color(value);
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
4764
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
4765 newcolor = [[NSColor colorWithDeviceRed: DW_RED_VALUE(_foreground)/255.0 green:
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
4766 DW_GREEN_VALUE(_foreground)/255.0 blue:
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
4767 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
4768 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
4769 [oldcolor release];
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4770 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4771
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4772 /* Sets the current background drawing color.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4773 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4774 * red: red value.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4775 * green: green value.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4776 * blue: blue value.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4777 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4778 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
4779 {
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
4780 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
4781 NSColor *newcolor;
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
4782
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
4783 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
4784 {
3774af45eb0c Fix for dw_draw_text() not using the background color on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 890
diff changeset
4785 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
4786 }
3774af45eb0c Fix for dw_draw_text() not using the background color on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 890
diff changeset
4787 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
4788 {
3774af45eb0c Fix for dw_draw_text() not using the background color on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 890
diff changeset
4789 _background = _get_color(value);
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
4790
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
4791 newcolor = [[NSColor colorWithDeviceRed: DW_RED_VALUE(_background)/255.0 green:
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
4792 DW_GREEN_VALUE(_background)/255.0 blue:
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
4793 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
4794 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
4795 }
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
4796 [oldcolor release];
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4797 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4798
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4799 /* 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
4800 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4801 * value: current color
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4802 * Returns:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4803 * 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
4804 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4805 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
4806 {
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
4807 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
4808 /* 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
4809 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
4810 DWDialog *dialog;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
4811
733
8d5e5b89725f Fixed the crashing issue with dw_color_choose() it now functions properly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 732
diff changeset
4812 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
4813 {
db3a173e487e Fixes for the color chooser... it now works a single time. However...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 731
diff changeset
4814 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
4815 /* 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
4816 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
4817 {
8d5e5b89725f Fixed the crashing issue with dw_color_choose() it now functions properly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 732
diff changeset
4818 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
4819 }
732
db3a173e487e Fixes for the color chooser... it now works a single time. However...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 731
diff changeset
4820 }
db3a173e487e Fixes for the color chooser... it now works a single time. However...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 731
diff changeset
4821 else
db3a173e487e Fixes for the color chooser... it now works a single time. However...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 731
diff changeset
4822 {
733
8d5e5b89725f Fixed the crashing issue with dw_color_choose() it now functions properly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 732
diff changeset
4823 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
4824 /* 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
4825 [colorDlg setContinuous:NO];
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
4826 [colorDlg setTarget:colorDlg];
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
4827 [colorDlg setAction:@selector(changeColor:)];
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
4828 }
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
4829
733
8d5e5b89725f Fixed the crashing issue with dw_color_choose() it now functions properly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 732
diff changeset
4830 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
4831 [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
4832 [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
4833 [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
4834
732
db3a173e487e Fixes for the color chooser... it now works a single time. However...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 731
diff changeset
4835 /* 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
4836 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
4837
732
db3a173e487e Fixes for the color chooser... it now works a single time. However...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 731
diff changeset
4838 /* 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
4839 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
4840 [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
4841 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
4842 return value;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4843 }
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 /* 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
4846 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4847 * handle: Handle to the window.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4848 * 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
4849 * x: X coordinate.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4850 * y: Y coordinate.
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 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
4853 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
4854 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
4855 DW_MUTEX_LOCK;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4856 id image = handle;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4857 if(pixmap)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4858 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4859 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
4860 [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
4861 [NSGraphicsContext setCurrentContext:[NSGraphicsContext
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
4862 graphicsContextWithGraphicsPort:[[NSGraphicsContext graphicsContextWithBitmapImageRep:image] graphicsPort] flipped:YES]];
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4863 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4864 else
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4865 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4866 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
4867 {
a4f99795ff26 Abort drawing functions if we fail to lock focus on a render control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 745
diff changeset
4868 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
4869 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
4870 }
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4871 _DWLastDrawable = handle;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4872 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4873 NSBezierPath* aPath = [NSBezierPath bezierPath];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4874 [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
4875 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
4876 [color set];
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
4877
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
4878 [aPath moveToPoint:NSMakePoint(x, y)];
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4879 [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
4880 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
4881 {
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
4882 [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
4883 }
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
4884 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
4885 {
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
4886 [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
4887 }
691
578bbfd8c904 Added 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 /* 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
4892 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4893 * handle: Handle to the window.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4894 * 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
4895 * x1: First X coordinate.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4896 * y1: First Y coordinate.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4897 * x2: Second X coordinate.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4898 * y2: Second Y coordinate.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4899 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4900 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
4901 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
4902 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
4903 DW_MUTEX_LOCK;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4904 id image = handle;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4905 if(pixmap)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4906 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4907 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
4908 [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
4909 [NSGraphicsContext setCurrentContext:[NSGraphicsContext
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
4910 graphicsContextWithGraphicsPort:[[NSGraphicsContext graphicsContextWithBitmapImageRep:image] graphicsPort] flipped:YES]];
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4911 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4912 else
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4913 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4914 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
4915 {
a4f99795ff26 Abort drawing functions if we fail to lock focus on a render control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 745
diff changeset
4916 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
4917 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
4918 }
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4919 _DWLastDrawable = handle;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4920 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4921 NSBezierPath* aPath = [NSBezierPath bezierPath];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4922 [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
4923 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
4924 [color set];
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
4925
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
4926 [aPath moveToPoint:NSMakePoint(x1, y1)];
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4927 [aPath lineToPoint:NSMakePoint(x2, y2)];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4928 [aPath stroke];
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
4929
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
4930 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
4931 {
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
4932 [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
4933 }
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
4934 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
4935 {
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
4936 [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
4937 }
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
4938 DW_MUTEX_UNLOCK;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4939 }
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 /* 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
4942 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4943 * handle: Handle to the window.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4944 * 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
4945 * x: X coordinate.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4946 * y: Y coordinate.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4947 * text: Text to be displayed.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4948 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4949 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
4950 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
4951 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
4952 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
4953 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
4954 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
4955 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
4956 {
d29fb0d5b291 Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 744
diff changeset
4957 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
4958 {
d29fb0d5b291 Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 744
diff changeset
4959 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
4960 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
4961 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
4962 {
a4f99795ff26 Abort drawing functions if we fail to lock focus on a render control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 745
diff changeset
4963 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
4964 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
4965 }
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
4966 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
4967 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
4968 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
4969 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
4970 {
3774af45eb0c Fix for dw_draw_text() not using the background color on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 890
diff changeset
4971 [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
4972 }
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
4973 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
4974 {
d29fb0d5b291 Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 744
diff changeset
4975 [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
4976 }
d29fb0d5b291 Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 744
diff changeset
4977 [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
4978 [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
4979 [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
4980 }
d29fb0d5b291 Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 744
diff changeset
4981 _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
4982 }
d29fb0d5b291 Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 744
diff changeset
4983 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
4984 {
1146
9d97610b2140 Adding dw_pixmap_set_font() which is equivalent to dw_window_set_font() except for pixmaps.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1144
diff changeset
4985 NSFont *font = pixmap->font;
745
d29fb0d5b291 Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 744
diff changeset
4986 DWRender *render = pixmap->handle;
1146
9d97610b2140 Adding dw_pixmap_set_font() which is equivalent to dw_window_set_font() except for pixmaps.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1144
diff changeset
4987 if(!font && [render isMemberOfClass:[DWRender 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
4988 {
d29fb0d5b291 Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 744
diff changeset
4989 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
4990 }
d29fb0d5b291 Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 744
diff changeset
4991 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
4992 [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
4993 [NSGraphicsContext setCurrentContext:[NSGraphicsContext
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
4994 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
4995 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
4996 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
4997 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
4998 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
4999 {
3774af45eb0c Fix for dw_draw_text() not using the background color on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 890
diff changeset
5000 [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
5001 }
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
5002 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
5003 {
d29fb0d5b291 Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 744
diff changeset
5004 [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
5005 }
d29fb0d5b291 Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 744
diff changeset
5006 [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
5007 [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
5008 [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
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 DW_MUTEX_UNLOCK;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5011 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5012
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5013 /* 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
5014 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5015 * handle: Handle to the window.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5016 * 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
5017 * text: Text to be queried.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5018 * 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
5019 * 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
5020 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5021 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
5022 {
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
5023 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
5024 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
5025 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
5026 {
d29fb0d5b291 Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 744
diff changeset
5027 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
5028 }
d29fb0d5b291 Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 744
diff changeset
5029 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
5030 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
5031 {
d29fb0d5b291 Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 744
diff changeset
5032 NSFont *font = [object font];
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
5033
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
5034 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
5035 {
d29fb0d5b291 Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 744
diff changeset
5036 [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
5037 }
d29fb0d5b291 Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 744
diff changeset
5038 }
d29fb0d5b291 Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 744
diff changeset
5039 NSSize size = [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
5040 [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
5041 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
5042 {
d29fb0d5b291 Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 744
diff changeset
5043 *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
5044 }
d29fb0d5b291 Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 744
diff changeset
5045 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
5046 {
d29fb0d5b291 Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 744
diff changeset
5047 *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
5048 }
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5049 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5050
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5051 /* 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
5052 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5053 * handle: Handle to the window.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5054 * 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
5055 * fill: Fill box TRUE or FALSE.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5056 * x: X coordinate.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5057 * y: Y coordinate.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5058 * width: Width of rectangle.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5059 * height: Height of rectangle.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5060 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5061 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
5062 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
5063 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
5064 DW_MUTEX_LOCK;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5065 id image = handle;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5066 int z;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5067 if(pixmap)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5068 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5069 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
5070 [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
5071 [NSGraphicsContext setCurrentContext:[NSGraphicsContext
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
5072 graphicsContextWithGraphicsPort:[[NSGraphicsContext graphicsContextWithBitmapImageRep:image] graphicsPort] flipped:YES]];
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5073 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5074 else
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5075 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5076 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
5077 {
a4f99795ff26 Abort drawing functions if we fail to lock focus on a render control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 745
diff changeset
5078 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
5079 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
5080 }
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5081 _DWLastDrawable = handle;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5082 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5083 NSBezierPath* aPath = [NSBezierPath bezierPath];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5084 [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
5085 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
5086 [color set];
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
5087
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5088 [aPath moveToPoint:NSMakePoint(*x, *y)];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5089 for(z=1;z<npoints;z++)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5090 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5091 [aPath lineToPoint:NSMakePoint(x[z], y[z])];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5092 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5093 [aPath closePath];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5094 if(fill)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5095 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5096 [aPath fill];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5097 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5098 [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
5099 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
5100 {
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
5101 [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
5102 }
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
5103 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
5104 {
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
5105 [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
5106 }
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
5107 DW_MUTEX_UNLOCK;
650
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 /* 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
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 window.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5113 * 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
5114 * fill: Fill box TRUE or FALSE.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5115 * x: X coordinate.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5116 * y: Y coordinate.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5117 * width: Width of rectangle.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5118 * height: Height of rectangle.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5119 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5120 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
5121 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
5122 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
5123 DW_MUTEX_LOCK;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5124 id image = handle;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5125 if(pixmap)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5126 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5127 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
5128 [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
5129 [NSGraphicsContext setCurrentContext:[NSGraphicsContext
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
5130 graphicsContextWithGraphicsPort:[[NSGraphicsContext graphicsContextWithBitmapImageRep:image] graphicsPort] flipped:YES]];
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5131 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5132 else
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5133 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5134 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
5135 {
a4f99795ff26 Abort drawing functions if we fail to lock focus on a render control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 745
diff changeset
5136 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
5137 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
5138 }
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5139 _DWLastDrawable = handle;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5140 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5141 NSBezierPath* aPath = [NSBezierPath bezierPath];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5142 [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
5143 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
5144 [color set];
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
5145
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
5146 [aPath moveToPoint:NSMakePoint(x, y)];
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5147 [aPath lineToPoint:NSMakePoint(x, y + height)];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5148 [aPath lineToPoint:NSMakePoint(x + width, y + height)];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5149 [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
5150 [aPath closePath];
767
9b0c22b58447 Don't fill a rectangle unless requested to
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 766
diff changeset
5151 if(fill)
9b0c22b58447 Don't fill a rectangle unless requested to
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 766
diff changeset
5152 [aPath fill];
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5153 [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
5154 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
5155 {
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
5156 [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
5157 }
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
5158 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
5159 {
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
5160 [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
5161 }
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
5162 DW_MUTEX_UNLOCK;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5163 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5164
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5165 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5166 * 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
5167 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5168 * 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
5169 * resource file.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5170 */
685
314a12dccd20 Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 684
diff changeset
5171 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
5172 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
5173 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
5174 DW_MUTEX_LOCK;
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
5175 NSScrollView *scrollview = [[NSScrollView alloc] init];
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5176 DWTree *tree = [[DWTree alloc] init];
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
5177
680
db315779a283 Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 679
diff changeset
5178 [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
5179 [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
5180 [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
5181 [scrollview setAutohidesScrollers:YES];
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
5182
680
db315779a283 Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 679
diff changeset
5183 [tree setAllowsMultipleSelection:NO];
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5184 [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
5185 [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
5186 [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
5187 [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
5188 [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
5189 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
5190 return tree;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5191 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5192
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5193 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5194 * 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
5195 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5196 * 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
5197 * 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
5198 * 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
5199 * icon: Handle to coresponding icon.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5200 * 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
5201 * itemdata: Item specific data.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5202 */
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
5203 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
5204 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
5205 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
5206 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
5207 DWTree *tree = handle;
935
114729f5aedc Needed to retain NSStrings in the tree view on Mac to prevent crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 934
diff changeset
5208 NSString *nstr = [[NSString stringWithUTF8String:title] retain];
1065
25e0317335fc Switched from using NSPointerArray to NSMutableArray on Mac to avoid the duplicate string crashes
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1064
diff changeset
5209 NSMutableArray *treenode = [[[NSMutableArray alloc] init] retain];
1067
6ca1132a240e Allow tree nodes without icons using the new NSMutableArray tree code on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1065
diff changeset
5210 if(icon)
6ca1132a240e Allow tree nodes without icons using the new NSMutableArray tree code on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1065
diff changeset
5211 [treenode addObject:icon];
6ca1132a240e Allow tree nodes without icons using the new NSMutableArray tree code on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1065
diff changeset
5212 else
6ca1132a240e Allow tree nodes without icons using the new NSMutableArray tree code on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1065
diff changeset
5213 [treenode addObject:[NSNull null]];
1065
25e0317335fc Switched from using NSPointerArray to NSMutableArray on Mac to avoid the duplicate string crashes
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1064
diff changeset
5214 [treenode addObject:nstr];
25e0317335fc Switched from using NSPointerArray to NSMutableArray on Mac to avoid the duplicate string crashes
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1064
diff changeset
5215 [treenode addObject:[NSValue valueWithPointer:itemdata]];
25e0317335fc Switched from using NSPointerArray to NSMutableArray on Mac to avoid the duplicate string crashes
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1064
diff changeset
5216 [treenode addObject:[NSNull null]];
1064
b673b25bbd77 Fixed dw_tree_insert_after() so it works on Mac it previously functioned identical to dw_tree_insert().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1063
diff changeset
5217 [tree addTree:treenode and:parent after:item];
1063
2ebaea72ac95 Fix for some release calls causing issues on MacOS 10.7 Lion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1061
diff changeset
5218 if(parent)
2ebaea72ac95 Fix for some release calls causing issues on MacOS 10.7 Lion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1061
diff changeset
5219 [tree reloadItem:parent reloadChildren:YES];
2ebaea72ac95 Fix for some release calls causing issues on MacOS 10.7 Lion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1061
diff changeset
5220 else
2ebaea72ac95 Fix for some release calls causing issues on MacOS 10.7 Lion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1061
diff changeset
5221 [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
5222 DW_MUTEX_UNLOCK;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5223 return treenode;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5224 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5225
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5226 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5227 * 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
5228 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5229 * 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
5230 * 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
5231 * icon: Handle to coresponding icon.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5232 * 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
5233 * itemdata: Item specific data.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5234 */
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
5235 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
5236 {
680
db315779a283 Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 679
diff changeset
5237 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
5238 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5239
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5240 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5241 * 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
5242 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5243 * 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
5244 * 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
5245 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5246 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
5247 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
5248 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
5249 DW_MUTEX_LOCK;
1065
25e0317335fc Switched from using NSPointerArray to NSMutableArray on Mac to avoid the duplicate string crashes
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1064
diff changeset
5250 NSMutableArray *array = (NSMutableArray *)item;
25e0317335fc Switched from using NSPointerArray to NSMutableArray on Mac to avoid the duplicate string crashes
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1064
diff changeset
5251 NSString *nstr = (NSString *)[array objectAtIndex: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
5252 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
5253 return strdup([nstr UTF8String]);
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5254 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5255
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5256 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5257 * 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
5258 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5259 * 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
5260 * 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
5261 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5262 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
5263 {
881
7b2750744552 Implemented dw_tree_get_parent() for the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 873
diff changeset
5264 int _locked_by_me = FALSE;
7b2750744552 Implemented dw_tree_get_parent() for the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 873
diff changeset
5265 HTREEITEM parent;
1064
b673b25bbd77 Fixed dw_tree_insert_after() so it works on Mac it previously functioned identical to dw_tree_insert().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1063
diff changeset
5266 DWTree *tree = handle;
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
5267
881
7b2750744552 Implemented dw_tree_get_parent() for the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 873
diff changeset
5268 DW_MUTEX_LOCK;
1064
b673b25bbd77 Fixed dw_tree_insert_after() so it works on Mac it previously functioned identical to dw_tree_insert().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1063
diff changeset
5269 parent = [tree parentForItem:item];
881
7b2750744552 Implemented dw_tree_get_parent() for the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 873
diff changeset
5270 DW_MUTEX_UNLOCK;
7b2750744552 Implemented dw_tree_get_parent() for the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 873
diff changeset
5271 return parent;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5272 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5273
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5274 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5275 * 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
5276 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5277 * 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
5278 * 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
5279 * 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
5280 * icon: Handle to coresponding icon.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5281 */
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
5282 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
5283 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
5284 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
5285 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
5286 DWTree *tree = handle;
1065
25e0317335fc Switched from using NSPointerArray to NSMutableArray on Mac to avoid the duplicate string crashes
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1064
diff changeset
5287 NSMutableArray *array = (NSMutableArray *)item;
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
5288 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
5289 {
1065
25e0317335fc Switched from using NSPointerArray to NSMutableArray on Mac to avoid the duplicate string crashes
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1064
diff changeset
5290 NSString *oldstr = [array objectAtIndex:1];
935
114729f5aedc Needed to retain NSStrings in the tree view on Mac to prevent crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 934
diff changeset
5291 NSString *nstr = [[NSString stringWithUTF8String:title] retain];
1065
25e0317335fc Switched from using NSPointerArray to NSMutableArray on Mac to avoid the duplicate string crashes
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1064
diff changeset
5292 [array replaceObjectAtIndex:1 withObject:nstr];
935
114729f5aedc Needed to retain NSStrings in the tree view on Mac to prevent crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 934
diff changeset
5293 [oldstr release];
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
5294 }
de4aa126fb2f Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 681
diff changeset
5295 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
5296 {
1065
25e0317335fc Switched from using NSPointerArray to NSMutableArray on Mac to avoid the duplicate string crashes
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1064
diff changeset
5297 [array replaceObjectAtIndex:0 withObject:icon];
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
5298 }
de4aa126fb2f Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 681
diff changeset
5299 [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
5300 DW_MUTEX_UNLOCK;
650
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
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5303 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5304 * 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
5305 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5306 * 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
5307 * 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
5308 * 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
5309 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5310 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
5311 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
5312 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
5313 DW_MUTEX_LOCK;
1065
25e0317335fc Switched from using NSPointerArray to NSMutableArray on Mac to avoid the duplicate string crashes
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1064
diff changeset
5314 NSMutableArray *array = (NSMutableArray *)item;
25e0317335fc Switched from using NSPointerArray to NSMutableArray on Mac to avoid the duplicate string crashes
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1064
diff changeset
5315 [array replaceObjectAtIndex:2 withObject:[NSValue valueWithPointer: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
5316 DW_MUTEX_UNLOCK;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5317 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5318
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5319 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5320 * 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
5321 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5322 * 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
5323 * 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
5324 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5325 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
5326 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
5327 int _locked_by_me = FALSE;
1065
25e0317335fc Switched from using NSPointerArray to NSMutableArray on Mac to avoid the duplicate string crashes
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1064
diff changeset
5328 void *result = NULL;
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
5329 DW_MUTEX_LOCK;
1065
25e0317335fc Switched from using NSPointerArray to NSMutableArray on Mac to avoid the duplicate string crashes
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1064
diff changeset
5330 NSMutableArray *array = (NSMutableArray *)item;
25e0317335fc Switched from using NSPointerArray to NSMutableArray on Mac to avoid the duplicate string crashes
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1064
diff changeset
5331 NSValue *value = [array objectAtIndex:2];
1068
efaa9ceeb253 Removed test for class member for itemdata in dw_tree_item_get_data()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1067
diff changeset
5332 if(value)
1065
25e0317335fc Switched from using NSPointerArray to NSMutableArray on Mac to avoid the duplicate string crashes
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1064
diff changeset
5333 {
25e0317335fc Switched from using NSPointerArray to NSMutableArray on Mac to avoid the duplicate string crashes
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1064
diff changeset
5334 result = [value pointerValue];
25e0317335fc Switched from using NSPointerArray to NSMutableArray on Mac to avoid the duplicate string crashes
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1064
diff changeset
5335 }
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
5336 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
5337 return result;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5338 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5339
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5340 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5341 * 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
5342 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5343 * 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
5344 * 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
5345 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5346 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
5347 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
5348 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
5349 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
5350 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
5351 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
5352 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
5353 {
de4aa126fb2f Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 681
diff changeset
5354 [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
5355 }
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
5356 DW_MUTEX_UNLOCK;
650
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 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5360 * Removes all nodes from a tree.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5361 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5362 * 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
5363 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5364 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
5365 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
5366 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
5367 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
5368 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
5369 [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
5370 DW_MUTEX_UNLOCK;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5371 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5372
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5373 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5374 * Expands a node on a tree.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5375 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5376 * 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
5377 * 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
5378 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5379 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
5380 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
5381 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
5382 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
5383 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
5384 [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
5385 DW_MUTEX_UNLOCK;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5386 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5387
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5388 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5389 * Collapses a node on a tree.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5390 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5391 * 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
5392 * 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
5393 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5394 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
5395 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
5396 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
5397 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
5398 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
5399 [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
5400 DW_MUTEX_UNLOCK;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5401 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5402
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5403 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5404 * Removes a node from a tree.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5405 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5406 * 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
5407 * 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
5408 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5409 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
5410 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
5411 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
5412 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
5413 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
5414 [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
5415 [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
5416 DW_MUTEX_UNLOCK;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5417 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5418
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5419 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5420 * 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
5421 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5422 * 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
5423 * resource file.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5424 */
685
314a12dccd20 Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 684
diff changeset
5425 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
5426 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
5427 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
5428 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
5429 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
5430 NSScrollView *scrollview = [cont scrollview];
7b99731c6484 Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 667
diff changeset
5431 [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
5432 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
5433 [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
5434 [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
5435 [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
5436 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
5437 return cont;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5438 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5439
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5440 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5441 * Sets up the container columns.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5442 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5443 * 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
5444 * 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
5445 * 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
5446 * 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
5447 * 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
5448 * (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
5449 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5450 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
5451 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
5452 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
5453 DW_MUTEX_LOCK;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5454 int z;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5455 DWContainer *cont = handle;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
5456
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5457 [cont setup];
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
5458
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5459 for(z=0;z<count;z++)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5460 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5461 NSTableColumn *column = [[NSTableColumn alloc] init];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5462 [[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
5463 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
5464 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
5465 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
5466 [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
5467 [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
5468 }
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
5469 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
5470 {
1206
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
5471 DWImageAndTextCell *browsercell = [[DWImageAndTextCell alloc] init];
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
5472 [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
5473 [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
5474 }
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
5475 /* 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
5476 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
5477 {
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
5478 [(NSCell *)[column dataCell] setAlignment:NSRightTextAlignment];
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
5479 [(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
5480 }
0103a8751ab4 Removed an unnecessary method in the container (rowCount) and implemented container column alignment.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 854
diff changeset
5481 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
5482 {
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
5483 [(NSCell *)[column dataCell] setAlignment:NSCenterTextAlignment];
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
5484 [(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
5485 }
795
f23cad02cfb3 Make listbox, container and tree cells uneditable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 794
diff changeset
5486 [column setEditable:NO];
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5487 [cont addTableColumn:column];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5488 [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
5489 [column release];
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
5490 }
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
5491 DW_MUTEX_UNLOCK;
986
87dc0f5f96d0 Fix return type of dw_listbox_selected() to be "int" instead of "unsigned int" to allow -1 return.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 983
diff changeset
5492 return DW_ERROR_NONE;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5493 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5494
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5495 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5496 * 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
5497 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5498 * 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
5499 * 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
5500 * 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
5501 * 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
5502 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5503 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
5504 {
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
5505 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
5506 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
5507 DWContainer *cont = handle;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
5508
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
5509 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
5510
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
5511 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
5512
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
5513 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
5514 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
5515
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
5516 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
5517 [cont setFilesystem:YES];
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
5518
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5519 free(newtitles);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5520 free(newflags);
986
87dc0f5f96d0 Fix return type of dw_listbox_selected() to be "int" instead of "unsigned int" to allow -1 return.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 983
diff changeset
5521 return DW_ERROR_NONE;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5522 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5523
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5524 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5525 * 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
5526 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5527 * 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
5528 * 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
5529 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5530 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
5531 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
5532 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
5533 DW_MUTEX_LOCK;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5534 DWContainer *cont = handle;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5535 [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
5536 DW_MUTEX_UNLOCK;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5537 return cont;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5538 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5539
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5540 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5541 * 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
5542 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5543 * 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
5544 * 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
5545 * 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
5546 * 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
5547 * 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
5548 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5549 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
5550 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
5551 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
5552 DW_MUTEX_LOCK;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5553 DWContainer *cont = handle;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5554 id object = nil;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5555 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
5556 int lastadd = 0;
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
5557
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
5558 /* 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
5559 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
5560 {
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
5561 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
5562 }
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
5563
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
5564 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
5565 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
5566 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
5567 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
5568 }
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5569 if(type & DW_CFA_BITMAPORICON)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5570 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5571 object = *((NSImage **)data);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5572 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5573 else if(type & DW_CFA_STRING)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5574 {
726
ecf47778caff Possible fix for container string columns not showing correctly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 725
diff changeset
5575 char *str = *((char **)data);
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5576 object = [ NSString stringWithUTF8String:str ];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5577 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5578 else
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5579 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5580 char textbuffer[100];
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
5581
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5582 if(type & DW_CFA_ULONG)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5583 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5584 ULONG tmp = *((ULONG *)data);
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
5585
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5586 sprintf(textbuffer, "%lu", tmp);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5587 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5588 else if(type & DW_CFA_DATE)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5589 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5590 struct tm curtm;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5591 CDATE cdate = *((CDATE *)data);
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
5592
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5593 memset( &curtm, 0, sizeof(curtm) );
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5594 curtm.tm_mday = cdate.day;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5595 curtm.tm_mon = cdate.month - 1;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5596 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
5597
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5598 strftime(textbuffer, 100, "%x", &curtm);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5599 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5600 else if(type & DW_CFA_TIME)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5601 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5602 struct tm curtm;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5603 CTIME ctime = *((CTIME *)data);
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
5604
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5605 memset( &curtm, 0, sizeof(curtm) );
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5606 curtm.tm_hour = ctime.hours;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5607 curtm.tm_min = ctime.minutes;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5608 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
5609
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5610 strftime(textbuffer, 100, "%X", &curtm);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5611 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5612 else
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5613 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
5614 DW_MUTEX_UNLOCK;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5615 return;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5616 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5617 object = [ NSString stringWithUTF8String:textbuffer ];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5618 }
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
5619
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5620 [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
5621 [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
5622 DW_MUTEX_UNLOCK;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5623 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5624
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5625 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5626 * 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
5627 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5628 * 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
5629 * 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
5630 * 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
5631 * 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
5632 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5633 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
5634 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5635 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
5636 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5637
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5638 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5639 * 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
5640 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5641 * 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
5642 * 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
5643 * 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
5644 * 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
5645 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5646 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
5647 {
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
5648 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
5649 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5651 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5652 * 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
5653 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5654 * 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
5655 * 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
5656 * 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
5657 * 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
5658 * 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
5659 */
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
5660 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
5661 {
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
5662 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
5663 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5664
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5665 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5666 * 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
5667 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5668 * 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
5669 * 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
5670 * 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
5671 * 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
5672 * 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
5673 */
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
5674 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
5675 {
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
5676 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
5677 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
5678 DWContainer *cont = handle;
1206
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
5679 DWImageAndTextCell *browsercell;
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
5680 int lastadd = 0;
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
5681
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
5682 /* 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
5683 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
5684 {
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
5685 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
5686 }
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
5687
1206
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
5688 browsercell = [[DWImageAndTextCell alloc] init];
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
5689 [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
5690 [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
5691 [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
5692 [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
5693 DW_MUTEX_UNLOCK;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5694 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5695
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5696 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5697 * 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
5698 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5699 * 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
5700 * 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
5701 * 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
5702 * 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
5703 * 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
5704 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5705 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
5706 {
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
5707 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
5708 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5709
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5710 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5711 * 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
5712 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5713 * 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
5714 * column: Zero based column.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5715 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5716 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
5717 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
5718 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
5719 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
5720 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
5721 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
5722 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
5723 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
5724 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
5725 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
5726 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
5727 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
5728 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
5729 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
5730 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
5731 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
5732 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
5733 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
5734 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
5735 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
5736 return rc;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5737 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5738
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5739 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5740 * 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
5741 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5742 * 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
5743 * column: Zero based column.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5744 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5745 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
5746 {
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
5747 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
5748 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5749
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5750 /*
1206
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
5751 * Sets the alternating row colors for container window (widget) handle.
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
5752 * Parameters:
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
5753 * handle: The window (widget) handle.
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
5754 * oddcolor: Odd row background color in DW_RGB format or a default color index.
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
5755 * evencolor: Even row background color in DW_RGB format or a default color index.
1210
5a016a5a7412 Slight change in design behavior for dw_container_set_row_bg()...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1206
diff changeset
5756 * DW_RGB_TRANSPARENT will disable coloring rows.
5a016a5a7412 Slight change in design behavior for dw_container_set_row_bg()...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1206
diff changeset
5757 * DW_CLR_DEFAULT will use the system default alternating row colors.
1206
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
5758 */
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
5759 void API dw_container_set_row_bg(HWND handle, unsigned long oddcolor, unsigned long evencolor)
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
5760 {
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
5761 int _locked_by_me = FALSE;
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
5762 DW_MUTEX_LOCK;
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
5763 DWContainer *cont = handle;
1212
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1210
diff changeset
5764 [cont setRowBgOdd:(oddcolor == DW_CLR_DEFAULT ? DW_RGB(230,230,230) : oddcolor)
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1210
diff changeset
5765 andEven:(evencolor == DW_CLR_DEFAULT ? DW_RGB_TRANSPARENT : evencolor)];
1206
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
5766 DW_MUTEX_UNLOCK;
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
5767 }
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
5768
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
5769 /*
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5770 * 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
5771 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5772 * 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
5773 * 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
5774 * width: Width of column in pixels.
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_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
5777 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
5778 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
5779 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
5780 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
5781 if([cont filesystem])
168b9db65825 Minor fix for dw_container_column_set_width() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 829
diff changeset
5782 {
168b9db65825 Minor fix for dw_container_column_set_width() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 829
diff changeset
5783 column++;
168b9db65825 Minor fix for dw_container_column_set_width() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 829
diff changeset
5784 }
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
5785 NSTableColumn *col = [cont getColumn:column];
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
5786
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
5787 [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
5788 DW_MUTEX_UNLOCK;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5789 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5790
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5791 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5792 * 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
5793 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5794 * 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
5795 * 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
5796 * title: String title of the item.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5797 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5798 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
5799 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
5800 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
5801 DW_MUTEX_LOCK;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5802 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
5803 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
5804 [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
5805 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
5806 }
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
5807
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
5808
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
5809 /*
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
5810 * 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
5811 * 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
5812 * 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
5813 * 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
5814 * 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
5815 */
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
5816 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
5817 {
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
5818 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
5819 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
5820 DWContainer *cont = handle;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5821 [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
5822 DW_MUTEX_UNLOCK;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5823 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5824
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5825 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5826 * 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
5827 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5828 * 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
5829 * 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
5830 * 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
5831 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5832 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
5833 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
5834 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
5835 DW_MUTEX_LOCK;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5836 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
5837 [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
5838 DW_MUTEX_UNLOCK;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5839 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5840
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5841 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5842 * Removes all rows from a container.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5843 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5844 * handle: 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
5845 * 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
5846 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5847 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
5848 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
5849 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
5850 DW_MUTEX_LOCK;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5851 DWContainer *cont = handle;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5852 [cont clear];
670
0b920d0dc13e Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 669
diff changeset
5853 if(redraw)
0b920d0dc13e Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 669
diff changeset
5854 {
0b920d0dc13e Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 669
diff changeset
5855 [cont reloadData];
0b920d0dc13e Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 669
diff changeset
5856 }
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
5857 DW_MUTEX_UNLOCK;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5858 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5859
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5860 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5861 * 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
5862 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5863 * 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
5864 * 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
5865 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5866 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
5867 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
5868 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
5869 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
5870 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
5871 int x;
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
5872
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
5873 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
5874 {
48f8efba898f Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 674
diff changeset
5875 [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
5876 }
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
5877 DW_MUTEX_UNLOCK;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5878 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5879
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5880 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5881 * Scrolls container up or down.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5882 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5883 * 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
5884 * 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
5885 * 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
5886 * 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
5887 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5888 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
5889 {
837
89d4bad9c96e Initial attempt at implementing the scrollbox on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 831
diff changeset
5890 DWContainer *cont = handle;
89d4bad9c96e Initial attempt at implementing the scrollbox on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 831
diff changeset
5891 NSScrollView *sv = [cont scrollview];
852
bb582f89007a Implemented dw_container_scroll() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 851
diff changeset
5892 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
5893 int rowcount = (int)[cont numberOfRowsInTableView:cont];
852
bb582f89007a Implemented dw_container_scroll() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 851
diff changeset
5894 float currpos = [scrollbar floatValue];
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
5895 float change;
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
5896
853
c27ce204302b Add safety check to avoid potential divide by zero.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 852
diff changeset
5897 /* Safety check */
c27ce204302b Add safety check to avoid potential divide by zero.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 852
diff changeset
5898 if(rowcount < 1)
c27ce204302b Add safety check to avoid potential divide by zero.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 852
diff changeset
5899 {
c27ce204302b Add safety check to avoid potential divide by zero.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 852
diff changeset
5900 return;
c27ce204302b Add safety check to avoid potential divide by zero.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 852
diff changeset
5901 }
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
5902
853
c27ce204302b Add safety check to avoid potential divide by zero.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 852
diff changeset
5903 change = (float)rows/(float)rowcount;
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
5904
852
bb582f89007a Implemented dw_container_scroll() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 851
diff changeset
5905 switch(direction)
bb582f89007a Implemented dw_container_scroll() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 851
diff changeset
5906 {
bb582f89007a Implemented dw_container_scroll() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 851
diff changeset
5907 case DW_SCROLL_TOP:
bb582f89007a Implemented dw_container_scroll() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 851
diff changeset
5908 {
bb582f89007a Implemented dw_container_scroll() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 851
diff changeset
5909 [scrollbar setFloatValue:0];
bb582f89007a Implemented dw_container_scroll() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 851
diff changeset
5910 break;
bb582f89007a Implemented dw_container_scroll() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 851
diff changeset
5911 }
bb582f89007a Implemented dw_container_scroll() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 851
diff changeset
5912 case DW_SCROLL_BOTTOM:
bb582f89007a Implemented dw_container_scroll() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 851
diff changeset
5913 {
bb582f89007a Implemented dw_container_scroll() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 851
diff changeset
5914 [scrollbar setFloatValue:1];
bb582f89007a Implemented dw_container_scroll() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 851
diff changeset
5915 break;
bb582f89007a Implemented dw_container_scroll() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 851
diff changeset
5916 }
bb582f89007a Implemented dw_container_scroll() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 851
diff changeset
5917 case DW_SCROLL_UP:
bb582f89007a Implemented dw_container_scroll() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 851
diff changeset
5918 {
bb582f89007a Implemented dw_container_scroll() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 851
diff changeset
5919 float newpos = currpos - change;
bb582f89007a Implemented dw_container_scroll() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 851
diff changeset
5920 if(newpos < 0)
bb582f89007a Implemented dw_container_scroll() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 851
diff changeset
5921 {
bb582f89007a Implemented dw_container_scroll() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 851
diff changeset
5922 newpos = 0;
bb582f89007a Implemented dw_container_scroll() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 851
diff changeset
5923 }
bb582f89007a Implemented dw_container_scroll() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 851
diff changeset
5924 [scrollbar setFloatValue:newpos];
bb582f89007a Implemented dw_container_scroll() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 851
diff changeset
5925 break;
bb582f89007a Implemented dw_container_scroll() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 851
diff changeset
5926 }
bb582f89007a Implemented dw_container_scroll() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 851
diff changeset
5927 case DW_SCROLL_DOWN:
bb582f89007a Implemented dw_container_scroll() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 851
diff changeset
5928 {
bb582f89007a Implemented dw_container_scroll() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 851
diff changeset
5929 float newpos = currpos + change;
bb582f89007a Implemented dw_container_scroll() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 851
diff changeset
5930 if(newpos > 1)
bb582f89007a Implemented dw_container_scroll() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 851
diff changeset
5931 {
bb582f89007a Implemented dw_container_scroll() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 851
diff changeset
5932 newpos = 1;
bb582f89007a Implemented dw_container_scroll() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 851
diff changeset
5933 }
bb582f89007a Implemented dw_container_scroll() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 851
diff changeset
5934 [scrollbar setFloatValue:newpos];
bb582f89007a Implemented dw_container_scroll() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 851
diff changeset
5935 break;
bb582f89007a Implemented dw_container_scroll() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 851
diff changeset
5936 }
bb582f89007a Implemented dw_container_scroll() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 851
diff changeset
5937 }
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5938 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5939
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5940 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5941 * 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
5942 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5943 * 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
5944 * 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
5945 * 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
5946 * 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
5947 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5948 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
5949 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
5950 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
5951 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
5952 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
5953 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
5954 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
5955 char *retval = NULL;
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
5956
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
5957 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
5958 {
48f8efba898f Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 674
diff changeset
5959 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
5960 [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
5961 }
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
5962 DW_MUTEX_UNLOCK;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5963 return retval;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5964 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5965
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5966 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5967 * 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
5968 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5969 * 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
5970 * 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
5971 * 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
5972 * 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
5973 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5974 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
5975 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
5976 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
5977 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
5978 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
5979 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
5980 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
5981 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
5982 char *retval = NULL;
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
5983
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
5984 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
5985 {
48f8efba898f Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 674
diff changeset
5986 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
5987 [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
5988 }
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
5989 DW_MUTEX_UNLOCK;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5990 return retval;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5991 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5992
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5993 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5994 * 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
5995 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5996 * 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
5997 * 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
5998 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5999 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
6000 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
6001 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
6002 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
6003 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
6004 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
6005 int x, count = (int)[cont numberOfRowsInTableView:cont];
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
6006
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
6007 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
6008 {
48f8efba898f Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 674
diff changeset
6009 thistext = [cont getRowTitle:x];
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
6010
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
6011 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
6012 {
48f8efba898f Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 674
diff changeset
6013 NSIndexSet *selected = [[NSIndexSet alloc] initWithIndex:(NSUInteger)x];
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
6014
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
6015 [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
6016 [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
6017 }
48f8efba898f Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 674
diff changeset
6018 }
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
6019 DW_MUTEX_UNLOCK;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6020 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6021
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6022 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6023 * 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
6024 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6025 * handle: Handle to the window (widget).
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6026 * 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
6027 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6028 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
6029 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
6030 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
6031 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
6032 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
6033 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
6034 int x, count = (int)[cont numberOfRowsInTableView:cont];
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
6035
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
6036 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
6037 {
48f8efba898f Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 674
diff changeset
6038 thistext = [cont getRowTitle:x];
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
6039
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
6040 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
6041 {
48f8efba898f Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 674
diff changeset
6042 [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
6043 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
6044 }
48f8efba898f Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 674
diff changeset
6045 }
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
6046 DW_MUTEX_UNLOCK;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6047 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6048
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6049 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6050 * 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
6051 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6052 * 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
6053 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6054 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
6055 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
6056 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
6057 DW_MUTEX_LOCK;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6058 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
6059 [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
6060 #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
6061 /* All resizable columns should expand */
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6062 [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
6063 #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
6064 DW_MUTEX_UNLOCK;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6065 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6066
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6067 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6068 * Inserts an icon into the taskbar.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6069 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6070 * 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
6071 * 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
6072 * 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
6073 */
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
6074 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
6075 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6076 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
6077 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6078
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6079 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6080 * Deletes an icon from the taskbar.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6081 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6082 * 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
6083 * 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
6084 */
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
6085 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
6086 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6087 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
6088 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6089
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6090 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6091 * 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
6092 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6093 * 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
6094 * 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
6095 * 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
6096 * to an embedded XPM.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6097 */
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
6098 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
6099 {
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
6100 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
6101 NSString *respath = [bundle resourcePath];
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
6102 NSString *filepath = [respath stringByAppendingFormat:@"/%u.png", resid];
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6103 NSImage *image = [[NSImage alloc] initWithContentsOfFile:filepath];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6104 return image;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6105 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6106
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6107 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6108 * Obtains an icon from a file.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6109 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6110 * 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
6111 * DW pick the appropriate file extension.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6112 * (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
6113 */
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
6114 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
6115 {
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
6116 char *ext = _dw_get_image_extension( filename );
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
6117
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
6118 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
6119 NSImage *image = [[NSImage alloc] initWithContentsOfFile:nstr];
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
6120 if(!image && ext)
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
6121 {
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
6122 nstr = [nstr stringByAppendingString: [NSString stringWithUTF8String:ext]];
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
6123 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
6124 }
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6125 return image;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6126 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6127
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6128 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6129 * Obtains an icon from data
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6130 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6131 * 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
6132 * DW pick the appropriate file extension.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6133 * (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
6134 */
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
6135 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
6136 {
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
6137 NSData *thisdata = [NSData dataWithBytes:data length:len];
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6138 NSImage *image = [[NSImage alloc] initWithData:thisdata];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6139 return image;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6140 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6141
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6142 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6143 * 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
6144 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6145 * 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
6146 */
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
6147 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
6148 {
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
6149 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
6150 [image release];
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6151 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6152
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6153 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6154 * 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
6155 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6156 * 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
6157 */
685
314a12dccd20 Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 684
diff changeset
6158 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
6159 {
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
6160 /* 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
6161 * 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
6162 * when the application is deactivated to simulate
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
6163 * 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
6164 */
014b02436c1f Added MDI simulation code... the MDI "window" will just be a box for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 683
diff changeset
6165 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
6166 /* [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
6167 return mdi;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6168 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6169
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6170 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6171 * 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
6172 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6173 * 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
6174 * 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
6175 * 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
6176 * Returns:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6177 * 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
6178 */
685
314a12dccd20 Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 684
diff changeset
6179 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
6180 {
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
6181 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
6182 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
6183 DW_MUTEX_LOCK;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6184 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
6185 [split setDelegate:split];
7b99731c6484 Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 667
diff changeset
6186 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
6187 [split addSubview:tmpbox];
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
6188 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
6189 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
6190 [split addSubview:tmpbox];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6191 if(type == DW_VERT)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6192 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6193 [split setVertical:NO];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6194 }
668
7b99731c6484 Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 667
diff changeset
6195 else
7b99731c6484 Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 667
diff changeset
6196 {
7b99731c6484 Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 667
diff changeset
6197 [split setVertical:YES];
7b99731c6484 Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 667
diff changeset
6198 }
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
6199 /* 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
6200 [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
6201 /* [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
6202 DW_MUTEX_UNLOCK;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6203 return split;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6204 }
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 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6207 * 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
6208 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6209 * handle: The handle to the splitbar returned by dw_splitbar_new().
1117
9ca5de2e59f8 Fixed the dw_splitbar_set() comment documentation. The percent parameter was missing.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1115
diff changeset
6210 * percent: The position of the splitbar.
650
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 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
6213 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6214 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
6215 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
6216 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
6217 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
6218 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
6219 /* 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
6220 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
6221 {
677
99002595f549 Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 676
diff changeset
6222 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
6223 }
99002595f549 Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 676
diff changeset
6224 else
99002595f549 Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 676
diff changeset
6225 {
676
9861d264925d MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 675
diff changeset
6226 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
6227 }
677
99002595f549 Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 676
diff changeset
6228 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
6229 {
99002595f549 Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 676
diff changeset
6230 [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
6231 }
676
9861d264925d MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 675
diff changeset
6232 else
9861d264925d MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 675
diff changeset
6233 {
677
99002595f549 Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 676
diff changeset
6234 /* 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
6235 * 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
6236 * 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
6237 */
99002595f549 Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 676
diff changeset
6238 [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
6239 }
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
6240 DW_MUTEX_UNLOCK;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6241 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6242
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6243 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6244 * 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
6245 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6246 * 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
6247 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6248 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
6249 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6250 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
6251 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
6252 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
6253 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
6254 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
6255 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
6256 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
6257 {
677
99002595f549 Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 676
diff changeset
6258 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
6259 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
6260 }
9861d264925d MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 675
diff changeset
6261 else
9861d264925d MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 675
diff changeset
6262 {
677
99002595f549 Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 676
diff changeset
6263 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
6264 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
6265 }
9861d264925d MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 675
diff changeset
6266 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
6267 {
9861d264925d MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 675
diff changeset
6268 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
6269 }
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6270 return retval;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6271 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6272
1146
9d97610b2140 Adding dw_pixmap_set_font() which is equivalent to dw_window_set_font() except for pixmaps.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1144
diff changeset
6273 /* Internal function to convert fontname to NSFont */
9d97610b2140 Adding dw_pixmap_set_font() which is equivalent to dw_window_set_font() except for pixmaps.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1144
diff changeset
6274 NSFont *_dw_font_by_name(char *fontname)
9d97610b2140 Adding dw_pixmap_set_font() which is equivalent to dw_window_set_font() except for pixmaps.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1144
diff changeset
6275 {
9d97610b2140 Adding dw_pixmap_set_font() which is equivalent to dw_window_set_font() except for pixmaps.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1144
diff changeset
6276 char *fontcopy = strdup(fontname);
9d97610b2140 Adding dw_pixmap_set_font() which is equivalent to dw_window_set_font() except for pixmaps.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1144
diff changeset
6277 char *name = strchr(fontcopy, '.');
9d97610b2140 Adding dw_pixmap_set_font() which is equivalent to dw_window_set_font() except for pixmaps.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1144
diff changeset
6278 NSFont *font = nil;
9d97610b2140 Adding dw_pixmap_set_font() which is equivalent to dw_window_set_font() except for pixmaps.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1144
diff changeset
6279
9d97610b2140 Adding dw_pixmap_set_font() which is equivalent to dw_window_set_font() except for pixmaps.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1144
diff changeset
6280 if(name)
9d97610b2140 Adding dw_pixmap_set_font() which is equivalent to dw_window_set_font() except for pixmaps.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1144
diff changeset
6281 {
9d97610b2140 Adding dw_pixmap_set_font() which is equivalent to dw_window_set_font() except for pixmaps.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1144
diff changeset
6282 int size = atoi(fontcopy);
9d97610b2140 Adding dw_pixmap_set_font() which is equivalent to dw_window_set_font() except for pixmaps.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1144
diff changeset
6283 *name = 0;
9d97610b2140 Adding dw_pixmap_set_font() which is equivalent to dw_window_set_font() except for pixmaps.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1144
diff changeset
6284 name++;
9d97610b2140 Adding dw_pixmap_set_font() which is equivalent to dw_window_set_font() except for pixmaps.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1144
diff changeset
6285 font = [NSFont fontWithName:[ NSString stringWithUTF8String:name ] size:(float)size];
9d97610b2140 Adding dw_pixmap_set_font() which is equivalent to dw_window_set_font() except for pixmaps.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1144
diff changeset
6286 }
9d97610b2140 Adding dw_pixmap_set_font() which is equivalent to dw_window_set_font() except for pixmaps.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1144
diff changeset
6287 free(fontcopy);
9d97610b2140 Adding dw_pixmap_set_font() which is equivalent to dw_window_set_font() except for pixmaps.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1144
diff changeset
6288 return font;
9d97610b2140 Adding dw_pixmap_set_font() which is equivalent to dw_window_set_font() except for pixmaps.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1144
diff changeset
6289 }
9d97610b2140 Adding dw_pixmap_set_font() which is equivalent to dw_window_set_font() except for pixmaps.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1144
diff changeset
6290
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6291 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6292 * 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
6293 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6294 * 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
6295 */
685
314a12dccd20 Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 684
diff changeset
6296 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
6297 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
6298 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
6299 DW_MUTEX_LOCK;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6300 NSImageView *bitmap = [[NSImageView alloc] init];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6301 [bitmap setImageFrameStyle:NSImageFrameNone];
1074
53fc692279fc Bitmap widgets shouldn't scale down images when the widget is smaller than the image on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1071
diff changeset
6302 [bitmap setImageScaling:NSScaleNone];
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6303 [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
6304 [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
6305 DW_MUTEX_UNLOCK;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6306 return bitmap;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6307 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6308
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6309 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6310 * Creates a pixmap with given parameters.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6311 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6312 * 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
6313 * 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
6314 * 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
6315 * depth: Color depth of the pixmap.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6316 * Returns:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6317 * 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
6318 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6319 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
6320 {
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
6321 HPIXMAP pixmap;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
6322
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
6323 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
6324 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
6325 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
6326 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
6327 pixmap->handle = handle;
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
6328 pixmap->image = [[NSBitmapImageRep alloc]
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
6329 initWithBitmapDataPlanes:NULL
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
6330 pixelsWide:width
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
6331 pixelsHigh:height
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
6332 bitsPerSample:8
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
6333 samplesPerPixel:4
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
6334 hasAlpha:YES
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
6335 isPlanar:NO
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
6336 colorSpaceName:NSDeviceRGBColorSpace
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
6337 bytesPerRow:0
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
6338 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
6339 return pixmap;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6340 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6341
957
beed3e7f9d4b Fixes to flip pixmaps when loading from file or data on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 954
diff changeset
6342 /* Function takes an NSImage and copies it into a flipped NSBitmapImageRep */
beed3e7f9d4b Fixes to flip pixmaps when loading from file or data on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 954
diff changeset
6343 void _flip_image(NSImage *tmpimage, NSBitmapImageRep *image, NSSize size)
beed3e7f9d4b Fixes to flip pixmaps when loading from file or data on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 954
diff changeset
6344 {
beed3e7f9d4b Fixes to flip pixmaps when loading from file or data on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 954
diff changeset
6345 [NSGraphicsContext saveGraphicsState];
beed3e7f9d4b Fixes to flip pixmaps when loading from file or data on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 954
diff changeset
6346 [NSGraphicsContext setCurrentContext:[NSGraphicsContext
981
536ec60ee433 Don't destroy a pixmap if the handle is null
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 980
diff changeset
6347 graphicsContextWithGraphicsPort:[[NSGraphicsContext graphicsContextWithBitmapImageRep:image] graphicsPort]
957
beed3e7f9d4b Fixes to flip pixmaps when loading from file or data on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 954
diff changeset
6348 flipped:YES]];
beed3e7f9d4b Fixes to flip pixmaps when loading from file or data on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 954
diff changeset
6349 [[NSDictionary alloc] initWithObjectsAndKeys:image, NSGraphicsContextDestinationAttributeName, nil];
981
536ec60ee433 Don't destroy a pixmap if the handle is null
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 980
diff changeset
6350 // make a new transform:
536ec60ee433 Don't destroy a pixmap if the handle is null
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 980
diff changeset
6351 NSAffineTransform *t = [NSAffineTransform transform];
536ec60ee433 Don't destroy a pixmap if the handle is null
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 980
diff changeset
6352
536ec60ee433 Don't destroy a pixmap if the handle is null
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 980
diff changeset
6353 // by scaling Y negatively, we effectively flip the image:
536ec60ee433 Don't destroy a pixmap if the handle is null
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 980
diff changeset
6354 [t scaleXBy:1.0 yBy:-1.0];
536ec60ee433 Don't destroy a pixmap if the handle is null
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 980
diff changeset
6355
536ec60ee433 Don't destroy a pixmap if the handle is null
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 980
diff changeset
6356 // but we also have to translate it back by its height:
536ec60ee433 Don't destroy a pixmap if the handle is null
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 980
diff changeset
6357 [t translateXBy:0.0 yBy:-size.height];
536ec60ee433 Don't destroy a pixmap if the handle is null
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 980
diff changeset
6358
536ec60ee433 Don't destroy a pixmap if the handle is null
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 980
diff changeset
6359 // apply the transform:
536ec60ee433 Don't destroy a pixmap if the handle is null
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 980
diff changeset
6360 [t concat];
536ec60ee433 Don't destroy a pixmap if the handle is null
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 980
diff changeset
6361 [tmpimage drawAtPoint:NSMakePoint(0, 0) fromRect:NSMakeRect(0, 0, size.width, size.height)
536ec60ee433 Don't destroy a pixmap if the handle is null
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 980
diff changeset
6362 operation:NSCompositeSourceOver fraction:1.0];
957
beed3e7f9d4b Fixes to flip pixmaps when loading from file or data on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 954
diff changeset
6363 [NSGraphicsContext restoreGraphicsState];
beed3e7f9d4b Fixes to flip pixmaps when loading from file or data on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 954
diff changeset
6364 }
beed3e7f9d4b Fixes to flip pixmaps when loading from file or data on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 954
diff changeset
6365
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6366 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6367 * Creates a pixmap from a file.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6368 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6369 * 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
6370 * 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
6371 * DW pick the appropriate file extension.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6372 * (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
6373 * Returns:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6374 * 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
6375 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6376 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
6377 {
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
6378 HPIXMAP pixmap;
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
6379 char *ext = _dw_get_image_extension( filename );
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
6380
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
6381 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
6382 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
6383 NSString *nstr = [ NSString stringWithUTF8String:filename ];
957
beed3e7f9d4b Fixes to flip pixmaps when loading from file or data on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 954
diff changeset
6384 NSImage *tmpimage = [[NSImage alloc] initWithContentsOfFile:nstr];
beed3e7f9d4b Fixes to flip pixmaps when loading from file or data on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 954
diff changeset
6385 if(!tmpimage && ext)
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
6386 {
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
6387 nstr = [nstr stringByAppendingString: [NSString stringWithUTF8String:ext]];
957
beed3e7f9d4b Fixes to flip pixmaps when loading from file or data on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 954
diff changeset
6388 tmpimage = [[NSImage alloc] initWithContentsOfFile:nstr];
beed3e7f9d4b Fixes to flip pixmaps when loading from file or data on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 954
diff changeset
6389 }
beed3e7f9d4b Fixes to flip pixmaps when loading from file or data on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 954
diff changeset
6390 if(!tmpimage)
beed3e7f9d4b Fixes to flip pixmaps when loading from file or data on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 954
diff changeset
6391 return NULL;
beed3e7f9d4b Fixes to flip pixmaps when loading from file or data on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 954
diff changeset
6392 NSSize size = [tmpimage size];
beed3e7f9d4b Fixes to flip pixmaps when loading from file or data on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 954
diff changeset
6393 NSBitmapImageRep *image = [[NSBitmapImageRep alloc]
beed3e7f9d4b Fixes to flip pixmaps when loading from file or data on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 954
diff changeset
6394 initWithBitmapDataPlanes:NULL
beed3e7f9d4b Fixes to flip pixmaps when loading from file or data on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 954
diff changeset
6395 pixelsWide:size.width
beed3e7f9d4b Fixes to flip pixmaps when loading from file or data on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 954
diff changeset
6396 pixelsHigh:size.height
beed3e7f9d4b Fixes to flip pixmaps when loading from file or data on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 954
diff changeset
6397 bitsPerSample:8
beed3e7f9d4b Fixes to flip pixmaps when loading from file or data on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 954
diff changeset
6398 samplesPerPixel:4
beed3e7f9d4b Fixes to flip pixmaps when loading from file or data on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 954
diff changeset
6399 hasAlpha:YES
beed3e7f9d4b Fixes to flip pixmaps when loading from file or data on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 954
diff changeset
6400 isPlanar:NO
beed3e7f9d4b Fixes to flip pixmaps when loading from file or data on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 954
diff changeset
6401 colorSpaceName:NSDeviceRGBColorSpace
beed3e7f9d4b Fixes to flip pixmaps when loading from file or data on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 954
diff changeset
6402 bytesPerRow:0
beed3e7f9d4b Fixes to flip pixmaps when loading from file or data on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 954
diff changeset
6403 bitsPerPixel:0];
beed3e7f9d4b Fixes to flip pixmaps when loading from file or data on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 954
diff changeset
6404 _flip_image(tmpimage, image, size);
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
6405 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
6406 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
6407 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
6408 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
6409 return pixmap;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6410 }
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 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6413 * Creates a pixmap from memory.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6414 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6415 * 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
6416 * data: Source of the image data
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6417 * (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
6418 * le: length of data
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6419 * Returns:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6420 * 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
6421 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6422 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
6423 {
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
6424 HPIXMAP pixmap;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
6425
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
6426 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
6427 return NULL;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
6428 NSData *thisdata = [NSData dataWithBytes:data length:len];
957
beed3e7f9d4b Fixes to flip pixmaps when loading from file or data on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 954
diff changeset
6429 NSImage *tmpimage = [[NSImage alloc] initWithData:thisdata];
beed3e7f9d4b Fixes to flip pixmaps when loading from file or data on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 954
diff changeset
6430 if(!tmpimage)
beed3e7f9d4b Fixes to flip pixmaps when loading from file or data on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 954
diff changeset
6431 return NULL;
beed3e7f9d4b Fixes to flip pixmaps when loading from file or data on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 954
diff changeset
6432 NSSize size = [tmpimage size];
beed3e7f9d4b Fixes to flip pixmaps when loading from file or data on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 954
diff changeset
6433 NSBitmapImageRep *image = [[NSBitmapImageRep alloc]
beed3e7f9d4b Fixes to flip pixmaps when loading from file or data on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 954
diff changeset
6434 initWithBitmapDataPlanes:NULL
beed3e7f9d4b Fixes to flip pixmaps when loading from file or data on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 954
diff changeset
6435 pixelsWide:size.width
beed3e7f9d4b Fixes to flip pixmaps when loading from file or data on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 954
diff changeset
6436 pixelsHigh:size.height
beed3e7f9d4b Fixes to flip pixmaps when loading from file or data on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 954
diff changeset
6437 bitsPerSample:8
beed3e7f9d4b Fixes to flip pixmaps when loading from file or data on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 954
diff changeset
6438 samplesPerPixel:4
beed3e7f9d4b Fixes to flip pixmaps when loading from file or data on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 954
diff changeset
6439 hasAlpha:YES
beed3e7f9d4b Fixes to flip pixmaps when loading from file or data on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 954
diff changeset
6440 isPlanar:NO
beed3e7f9d4b Fixes to flip pixmaps when loading from file or data on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 954
diff changeset
6441 colorSpaceName:NSDeviceRGBColorSpace
beed3e7f9d4b Fixes to flip pixmaps when loading from file or data on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 954
diff changeset
6442 bytesPerRow:0
beed3e7f9d4b Fixes to flip pixmaps when loading from file or data on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 954
diff changeset
6443 bitsPerPixel:0];
beed3e7f9d4b Fixes to flip pixmaps when loading from file or data on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 954
diff changeset
6444 _flip_image(tmpimage, image, size);
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
6445 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
6446 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
6447 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
6448 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
6449 return pixmap;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6450 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6451
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6452 /*
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
6453 * 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
6454 * 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
6455 * 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
6456 * 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
6457 * 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
6458 * 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
6459 * is handled automatically
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6460 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6461 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
6462 {
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
6463 /* Don't do anything */
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6464 }
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 * 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
6468 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6469 * 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
6470 * 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
6471 * Returns:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6472 * 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
6473 */
670
0b920d0dc13e Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 669
diff changeset
6474 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
6475 {
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
6476 HPIXMAP pixmap;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
6477
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
6478 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
6479 return NULL;
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
6480
670
0b920d0dc13e Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 669
diff changeset
6481 NSBundle *bundle = [NSBundle mainBundle];
0b920d0dc13e Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 669
diff changeset
6482 NSString *respath = [bundle resourcePath];
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
6483 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
6484 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
6485 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
6486 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
6487 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
6488 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
6489 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
6490 return pixmap;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6491 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6492
1146
9d97610b2140 Adding dw_pixmap_set_font() which is equivalent to dw_window_set_font() except for pixmaps.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1144
diff changeset
6493 /*
9d97610b2140 Adding dw_pixmap_set_font() which is equivalent to dw_window_set_font() except for pixmaps.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1144
diff changeset
6494 * Sets the font used by a specified pixmap.
9d97610b2140 Adding dw_pixmap_set_font() which is equivalent to dw_window_set_font() except for pixmaps.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1144
diff changeset
6495 * Normally the pixmap font is obtained from the associated window handle.
9d97610b2140 Adding dw_pixmap_set_font() which is equivalent to dw_window_set_font() except for pixmaps.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1144
diff changeset
6496 * However this can be used to override that, or for pixmaps with no window.
9d97610b2140 Adding dw_pixmap_set_font() which is equivalent to dw_window_set_font() except for pixmaps.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1144
diff changeset
6497 * Parameters:
9d97610b2140 Adding dw_pixmap_set_font() which is equivalent to dw_window_set_font() except for pixmaps.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1144
diff changeset
6498 * pixmap: Handle to a pixmap returned by dw_pixmap_new() or
9d97610b2140 Adding dw_pixmap_set_font() which is equivalent to dw_window_set_font() except for pixmaps.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1144
diff changeset
6499 * passed to the application via a callback.
9d97610b2140 Adding dw_pixmap_set_font() which is equivalent to dw_window_set_font() except for pixmaps.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1144
diff changeset
6500 * fontname: Name and size of the font in the form "size.fontname"
1147
091ed7c20b3f Implemented dw_pixmap_set_font() on Windows. Added to export files on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1146
diff changeset
6501 * Returns:
091ed7c20b3f Implemented dw_pixmap_set_font() on Windows. Added to export files on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1146
diff changeset
6502 * DW_ERROR_NONE on success and DW_ERROR_GENERAL on failure.
1146
9d97610b2140 Adding dw_pixmap_set_font() which is equivalent to dw_window_set_font() except for pixmaps.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1144
diff changeset
6503 */
9d97610b2140 Adding dw_pixmap_set_font() which is equivalent to dw_window_set_font() except for pixmaps.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1144
diff changeset
6504 int API dw_pixmap_set_font(HPIXMAP pixmap, char *fontname)
9d97610b2140 Adding dw_pixmap_set_font() which is equivalent to dw_window_set_font() except for pixmaps.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1144
diff changeset
6505 {
9d97610b2140 Adding dw_pixmap_set_font() which is equivalent to dw_window_set_font() except for pixmaps.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1144
diff changeset
6506 if(pixmap)
9d97610b2140 Adding dw_pixmap_set_font() which is equivalent to dw_window_set_font() except for pixmaps.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1144
diff changeset
6507 {
9d97610b2140 Adding dw_pixmap_set_font() which is equivalent to dw_window_set_font() except for pixmaps.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1144
diff changeset
6508 NSFont *font = _dw_font_by_name(fontname);
9d97610b2140 Adding dw_pixmap_set_font() which is equivalent to dw_window_set_font() except for pixmaps.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1144
diff changeset
6509
9d97610b2140 Adding dw_pixmap_set_font() which is equivalent to dw_window_set_font() except for pixmaps.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1144
diff changeset
6510 if(font)
9d97610b2140 Adding dw_pixmap_set_font() which is equivalent to dw_window_set_font() except for pixmaps.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1144
diff changeset
6511 {
9d97610b2140 Adding dw_pixmap_set_font() which is equivalent to dw_window_set_font() except for pixmaps.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1144
diff changeset
6512 NSFont *oldfont = pixmap->font;
9d97610b2140 Adding dw_pixmap_set_font() which is equivalent to dw_window_set_font() except for pixmaps.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1144
diff changeset
6513 [font retain];
9d97610b2140 Adding dw_pixmap_set_font() which is equivalent to dw_window_set_font() except for pixmaps.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1144
diff changeset
6514 pixmap->font = font;
9d97610b2140 Adding dw_pixmap_set_font() which is equivalent to dw_window_set_font() except for pixmaps.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1144
diff changeset
6515 if(oldfont)
9d97610b2140 Adding dw_pixmap_set_font() which is equivalent to dw_window_set_font() except for pixmaps.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1144
diff changeset
6516 [oldfont release];
9d97610b2140 Adding dw_pixmap_set_font() which is equivalent to dw_window_set_font() except for pixmaps.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1144
diff changeset
6517 return DW_ERROR_NONE;
9d97610b2140 Adding dw_pixmap_set_font() which is equivalent to dw_window_set_font() except for pixmaps.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1144
diff changeset
6518 }
9d97610b2140 Adding dw_pixmap_set_font() which is equivalent to dw_window_set_font() except for pixmaps.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1144
diff changeset
6519 }
9d97610b2140 Adding dw_pixmap_set_font() which is equivalent to dw_window_set_font() except for pixmaps.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1144
diff changeset
6520 return DW_ERROR_GENERAL;
9d97610b2140 Adding dw_pixmap_set_font() which is equivalent to dw_window_set_font() except for pixmaps.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1144
diff changeset
6521 }
9d97610b2140 Adding dw_pixmap_set_font() which is equivalent to dw_window_set_font() except for pixmaps.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1144
diff changeset
6522
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6523 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6524 * Destroys an allocated pixmap.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6525 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6526 * 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
6527 * dw_pixmap_new..
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6528 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6529 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
6530 {
1146
9d97610b2140 Adding dw_pixmap_set_font() which is equivalent to dw_window_set_font() except for pixmaps.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1144
diff changeset
6531 if(pixmap)
9d97610b2140 Adding dw_pixmap_set_font() which is equivalent to dw_window_set_font() except for pixmaps.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1144
diff changeset
6532 {
9d97610b2140 Adding dw_pixmap_set_font() which is equivalent to dw_window_set_font() except for pixmaps.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1144
diff changeset
6533 NSBitmapImageRep *image = (NSBitmapImageRep *)pixmap->image;
9d97610b2140 Adding dw_pixmap_set_font() which is equivalent to dw_window_set_font() except for pixmaps.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1144
diff changeset
6534 NSFont *font = pixmap->font;
9d97610b2140 Adding dw_pixmap_set_font() which is equivalent to dw_window_set_font() except for pixmaps.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1144
diff changeset
6535 [image release];
9d97610b2140 Adding dw_pixmap_set_font() which is equivalent to dw_window_set_font() except for pixmaps.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1144
diff changeset
6536 [font release];
9d97610b2140 Adding dw_pixmap_set_font() which is equivalent to dw_window_set_font() except for pixmaps.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1144
diff changeset
6537 free(pixmap);
981
536ec60ee433 Don't destroy a pixmap if the handle is null
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 980
diff changeset
6538 }
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6539 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6540
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6541 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6542 * Copies from one item to another.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6543 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6544 * dest: Destination window handle.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6545 * destp: Destination pixmap. (choose only one).
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6546 * xdest: X coordinate of destination.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6547 * ydest: Y coordinate of destination.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6548 * width: Width of area to copy.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6549 * height: Height of area to copy.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6550 * src: Source window handle.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6551 * srcp: Source pixmap. (choose only one).
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6552 * xsrc: X coordinate of source.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6553 * ysrc: Y coordinate of source.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6554 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6555 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
6556 {
699
b79300831495 Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 698
diff changeset
6557 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
6558 NSValue* bi = [NSValue valueWithPointer:bltinfo];
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
6559
699
b79300831495 Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 698
diff changeset
6560 /* 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
6561 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
6562 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
6563 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
6564 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
6565 bltinfo->width = width;
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
6566 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
6567 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
6568 bltinfo->ysrc = ysrc;
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
6569
699
b79300831495 Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 698
diff changeset
6570 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
6571 {
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
6572 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
6573 }
b79300831495 Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 698
diff changeset
6574 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
6575 {
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
6576 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
6577 [object retain];
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
6578 }
699
b79300831495 Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 698
diff changeset
6579 [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
6580 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6581
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6582 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6583 * 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
6584 * Not available under OS/2, eCS
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6585 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6586 * 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
6587 * 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
6588 */
685
314a12dccd20 Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 684
diff changeset
6589 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
6590 {
729
6712e4211522 Switched to graphical calendar control style... and fixed date querying code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 728
diff changeset
6591 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
6592 [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
6593 [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
6594 [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
6595 [calendar setTag:cid];
1120
b2e060f43329 Initialize the calendar control to the current date during creation on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1117
diff changeset
6596 [calendar setDateValue:[NSDate date]];
729
6712e4211522 Switched to graphical calendar control style... and fixed date querying code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 728
diff changeset
6597 return calendar;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6598 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6599
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6600 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6601 * 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
6602 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6603 * 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
6604 * year...
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6605 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6606 void 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
6607 {
729
6712e4211522 Switched to graphical calendar control style... and fixed date querying code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 728
diff changeset
6608 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
6609 NSDate *date;
6712e4211522 Switched to graphical calendar control style... and fixed date querying code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 728
diff changeset
6610 char buffer[100];
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
6611
729
6712e4211522 Switched to graphical calendar control style... and fixed date querying code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 728
diff changeset
6612 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
6613
729
6712e4211522 Switched to graphical calendar control style... and fixed date querying code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 728
diff changeset
6614 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
6615 [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
6616 [date release];
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6617 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6618
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6619 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6620 * 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
6621 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6622 * 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
6623 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6624 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
6625 {
729
6712e4211522 Switched to graphical calendar control style... and fixed date querying code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 728
diff changeset
6626 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
6627 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
6628 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
6629 [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
6630 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
6631 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
6632 if(*year < 70)
d3fb3613726a Calendar control should return years with 4 digits not 2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 729
diff changeset
6633 {
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
6634 *year += 2000;
730
d3fb3613726a Calendar control should return years with 4 digits not 2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 729
diff changeset
6635 }
d3fb3613726a Calendar control should return years with 4 digits not 2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 729
diff changeset
6636 else if(*year < 100)
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
6637 {
730
d3fb3613726a Calendar control should return years with 4 digits not 2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 729
diff changeset
6638 *year += 1900;
d3fb3613726a Calendar control should return years with 4 digits not 2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 729
diff changeset
6639 }
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
6640 [df release];
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6641 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6642
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6643 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6644 * 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
6645 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6646 * handle: Handle to the window.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6647 * 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
6648 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6649 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
6650 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6651 WebView *html = handle;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6652 switch(action)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6653 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6654 case DW_HTML_GOBACK:
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6655 [html goBack];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6656 break;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6657 case DW_HTML_GOFORWARD:
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6658 [html goForward];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6659 break;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6660 case DW_HTML_GOHOME:
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6661 break;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6662 case DW_HTML_SEARCH:
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6663 break;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6664 case DW_HTML_RELOAD:
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6665 [html reload:html];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6666 break;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6667 case DW_HTML_STOP:
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6668 [html stopLoading:html];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6669 break;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6670 case DW_HTML_PRINT:
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6671 break;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6672 }
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6673 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6674
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6675 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6676 * 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
6677 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6678 * handle: Handle to the window.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6679 * 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
6680 * be rendered.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6681 * Returns:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6682 * 0 on success.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6683 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6684 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
6685 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6686 WebView *html = handle;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6687 [[html mainFrame] loadHTMLString:[ NSString stringWithUTF8String:string ] baseURL:nil];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6688 return 0;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6689 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6690
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6691 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6692 * 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
6693 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6694 * handle: Handle to the window.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6695 * 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
6696 * file object to be rendered.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6697 * Returns:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6698 * 0 on success.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6699 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6700 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
6701 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6702 WebView *html = handle;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6703 [[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
6704 return 0;
650
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
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6707 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6708 * 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
6709 * Not available under OS/2, eCS
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6710 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6711 * 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
6712 * 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
6713 */
685
314a12dccd20 Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 684
diff changeset
6714 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
6715 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
6716 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
6717 DW_MUTEX_LOCK;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6718 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
6719 /* [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
6720 DW_MUTEX_UNLOCK;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6721 return web;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6722 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6723
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6724 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6725 * 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
6726 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6727 * 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
6728 * 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
6729 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6730 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
6731 {
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
6732 NSPoint mouseLoc;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6733 mouseLoc = [NSEvent mouseLocation];
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6734 if(x)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6735 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6736 *x = mouseLoc.x;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6737 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6738 if(y)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6739 {
946
c64d3ca566f9 Attempt at inverting the window position and mouse pointer coordinates on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 945
diff changeset
6740 *y = [[NSScreen mainScreen] frame].size.height - mouseLoc.y;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6741 }
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6742 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6743
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6744 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6745 * 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
6746 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6747 * x: X coordinate.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6748 * y: Y coordinate.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6749 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6750 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
6751 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6752 /* 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
6753 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6754
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6755 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6756 * 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
6757 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6758 * 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
6759 * resource file.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6760 */
685
314a12dccd20 Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 684
diff changeset
6761 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
6762 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6763 NSMenu *menu = [[[NSMenu alloc] init] autorelease];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6764 [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
6765 /* [menu setTag:cid]; Why doesn't this work? */
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6766 return menu;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6767 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6768
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6769 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6770 * Create a menubar on a window.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6771 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6772 * 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
6773 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6774 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
6775 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6776 NSWindow *window = location;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6777 NSMenu *windowmenu = _generate_main_menu();
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6778 [[window contentView] setMenu:windowmenu];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6779 return (HMENUI)windowmenu;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6780 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6781
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6782 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6783 * 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
6784 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6785 * menu: Handle of a menu.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6786 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6787 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
6788 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6789 NSMenu *thismenu = *menu;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6790 [thismenu release];
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6791 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6792
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6793 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6794 * 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
6795 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6796 * 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
6797 * 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
6798 * x: X coordinate.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6799 * y: Y coordinate.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6800 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6801 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
6802 {
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
6803 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
6804 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
6805 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
6806 NSWindow *window = [view window];
701
c91a1b345f2e Fix for button press and context menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 700
diff changeset
6807 NSEvent *event = [DWApp currentEvent];
946
c64d3ca566f9 Attempt at inverting the window position and mouse pointer coordinates on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 945
diff changeset
6808 NSPoint p = NSMakePoint(x, [[NSScreen mainScreen] frame].size.height - y);
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
6809 NSEvent* fake = [NSEvent mouseEventWithType:NSRightMouseDown
946
c64d3ca566f9 Attempt at inverting the window position and mouse pointer coordinates on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 945
diff changeset
6810 location:[window convertScreenToBase:p]
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
6811 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
6812 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
6813 windowNumber:[window windowNumber]
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
6814 context:[NSGraphicsContext currentContext]
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
6815 eventNumber:1
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
6816 clickCount:1
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
6817 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
6818 [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
6819 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6820
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6821 char _removetilde(char *dest, char *src)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6822 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6823 int z, cur=0;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6824 char accel = '\0';
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
6825
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6826 for(z=0;z<strlen(src);z++)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6827 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6828 if(src[z] != '~')
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6829 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6830 dest[cur] = src[z];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6831 cur++;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6832 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6833 else
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6834 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6835 accel = src[z+1];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6836 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6837 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6838 dest[cur] = 0;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6839 return accel;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6840 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6841
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6842 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6843 * 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
6844 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6845 * 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
6846 * 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
6847 * 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
6848 * 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
6849 * 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
6850 * 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
6851 * 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
6852 * 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
6853 */
654
80e253df49fd Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 653
diff changeset
6854 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
6855 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6856 NSMenu *menu = menux;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6857 NSMenu *submenu = submenux;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6858 NSMenuItem *item = NULL;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6859 if(strlen(title) == 0)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6860 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6861 [menu addItem:[NSMenuItem separatorItem]];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6862 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6863 else
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6864 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6865 char accel[2];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6866 char *newtitle = malloc(strlen(title)+1);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6867 NSString *nstr;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
6868
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6869 accel[0] = _removetilde(newtitle, title);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6870 accel[1] = 0;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
6871
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6872 nstr = [ NSString stringWithUTF8String:newtitle ];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6873 free(newtitle);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6874
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6875 item = [menu addItemWithTitle: nstr
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6876 action:@selector(menuHandler:)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6877 keyEquivalent:[ NSString stringWithUTF8String:accel ]];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6878 [item setTag:itemid];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6879 if(flags & DW_MIS_CHECKED)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6880 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6881 [item setState:NSOnState];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6882 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6883 if(flags & DW_MIS_DISABLED)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6884 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6885 [item setEnabled:NO];
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
6886 }
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
6887
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6888 if(submenux)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6889 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6890 [submenu setTitle:nstr];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6891 [menu setSubmenu:submenu forItem:item];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6892 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6893 return item;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6894 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6895 return item;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6896 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6897
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6898 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6899 * 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
6900 * 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
6901 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6902 * 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
6903 * id: Menuitem id.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6904 * 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
6905 */
654
80e253df49fd Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 653
diff changeset
6906 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
6907 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6908 id menu = menux;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6909 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
6910
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6911 if(menuitem != nil)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6912 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6913 if(check)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6914 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6915 [menuitem setState:NSOnState];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6916 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6917 else
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
6918 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6919 [menuitem setState:NSOffState];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6920 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
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 * 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
6926 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6927 * 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
6928 * id: Menuitem id.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6929 * 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
6930 * DW_MIS_CHECKED/DW_MIS_UNCHECKED
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6931 */
654
80e253df49fd Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 653
diff changeset
6932 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
6933 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6934 id menu = menux;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6935 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
6936
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6937 if(menuitem != nil)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6938 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6939 if(state & DW_MIS_CHECKED)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6940 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6941 [menuitem setState:NSOnState];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6942 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6943 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
6944 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6945 [menuitem setState:NSOffState];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6946 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6947 if(state & DW_MIS_ENABLED)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6948 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6949 [menuitem setEnabled:YES];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6950 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6951 else if(state & DW_MIS_DISABLED)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6952 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6953 [menuitem setEnabled:NO];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6954 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6955 }
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6956 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6957
652
ef0f484c6c4b Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 651
diff changeset
6958 /* 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
6959 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
6960 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6961 NSArray *pages = [notebook tabViewItems];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6962 for(DWNotebookPage *notepage in pages)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6963 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6964 if([notepage pageid] == pageid)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6965 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6966 return notepage;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6967 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6968 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6969 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
6970 }
ef0f484c6c4b Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 651
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 * 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
6974 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6975 * 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
6976 * resource file.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6977 */
685
314a12dccd20 Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 684
diff changeset
6978 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
6979 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6980 DWNotebook *notebook = [[DWNotebook alloc] init];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6981 [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
6982 /* [notebook setTag:cid]; Why doesn't this work? */
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6983 return notebook;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6984 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6985
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6986 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6987 * 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
6988 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6989 * handle: Window (widget) handle.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6990 * flags: Any additional page creation flags.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6991 * 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
6992 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6993 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
6994 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6995 DWNotebook *notebook = handle;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6996 NSInteger page = [notebook pageid];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6997 DWNotebookPage *notepage = [[DWNotebookPage alloc] initWithIdentifier:nil];
937
83aceaaef6ed Added initial support for allowing dW_window_destroy() to remove an item from its containing box on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 936
diff changeset
6998 [notepage setPageid:(int)page];
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6999 if(front)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7000 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7001 [notebook insertTabViewItem:notepage atIndex:(NSInteger)0];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7002 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7003 else
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7004 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7005 [notebook addTabViewItem:notepage];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7006 }
937
83aceaaef6ed Added initial support for allowing dW_window_destroy() to remove an item from its containing box on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 936
diff changeset
7007 [notebook setPageid:(int)(page+1)];
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7008 return (unsigned long)page;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7009 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7010
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7011 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7012 * Remove a page from a notebook.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7013 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7014 * handle: Handle to the notebook widget.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7015 * 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
7016 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7017 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
7018 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7019 DWNotebook *notebook = handle;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7020 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
7021
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7022 if(notepage != nil)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7023 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7024 [notebook removeTabViewItem:notepage];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7025 }
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7026 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7027
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7028 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7029 * Queries the currently visible page ID.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7030 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7031 * handle: Handle to the notebook widget.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7032 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7033 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
7034 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7035 DWNotebook *notebook = handle;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7036 DWNotebookPage *notepage = (DWNotebookPage *)[notebook selectedTabViewItem];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7037 return [notepage pageid];
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7038 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7039
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7040 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7041 * Sets the currently visibale page ID.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7042 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7043 * handle: Handle to the notebook widget.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7044 * 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
7045 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7046 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
7047 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7048 DWNotebook *notebook = handle;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7049 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
7050
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7051 if(notepage != nil)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7052 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7053 [notebook selectTabViewItem:notepage];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7054 }
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7055 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7056
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7057 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7058 * 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
7059 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7060 * handle: Notebook handle.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7061 * 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
7062 * 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
7063 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7064 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
7065 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7066 DWNotebook *notebook = handle;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7067 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
7068
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7069 if(notepage != nil)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7070 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7071 [notepage setLabel:[ NSString stringWithUTF8String:text ]];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7072 }
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7073 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7074
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7075 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7076 * 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
7077 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7078 * handle: Notebook handle.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7079 * 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
7080 * 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
7081 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7082 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
7083 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7084 /* Note supported here... do nothing */
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7085 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7086
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7087 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7088 * 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
7089 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7090 * 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
7091 * 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
7092 * page: Box handle to be packed.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7093 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7094 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
7095 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7096 DWNotebook *notebook = handle;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7097 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
7098
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7099 if(notepage != nil)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7100 {
667
28727d9a835c Fix for a rather serious notebook layout bug.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 666
diff changeset
7101 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
7102 DWBox *box = tmpbox;
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
7103
667
28727d9a835c Fix for a rather serious notebook layout bug.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 666
diff changeset
7104 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
7105 [notepage setView:box];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7106 }
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7107 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7108
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7109 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7110 * Create a new Window Frame.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7111 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7112 * 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
7113 * title: The Window title.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7114 * 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
7115 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7116 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
7117 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
7118 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
7119 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
7120 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
7121 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
7122 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
7123 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
7124 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
7125 defer:false];
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7126
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7127 [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
7128
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7129 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
7130
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7131 [window setContentView:view];
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7132 [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
7133 [window setAutorecalculatesKeyViewLoop:YES];
944
cdb7a53e5515 Some motion notify changes... so it can handle events without the mouse button pressed on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 943
diff changeset
7134 [window setAcceptsMouseMovedEvents: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
7135 [view release];
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
7136
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
7137 /* 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
7138 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
7139 {
014b02436c1f Added MDI simulation code... the MDI "window" will just be a box for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 683
diff changeset
7140 id object = hwndOwner;
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
7141
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
7142 /* 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
7143 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
7144 {
014b02436c1f Added MDI simulation code... the MDI "window" will just be a box for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 683
diff changeset
7145 /* 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
7146 [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
7147 [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
7148 }
014b02436c1f Added MDI simulation code... the MDI "window" will just be a box for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 683
diff changeset
7149 }
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
7150 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
7151 return (HWND)window;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7152 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7153
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7154 /*
651
270580896dac Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 650
diff changeset
7155 * 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
7156 * Parameters:
270580896dac Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 650
diff changeset
7157 * handle: Window handle of the widget.
270580896dac Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 650
diff changeset
7158 * function: Function pointer to be called.
270580896dac Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 650
diff changeset
7159 * 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
7160 */
270580896dac Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 650
diff changeset
7161 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
7162 {
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
7163 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
7164 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
7165 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
7166 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
7167 [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
7168 free(params);
651
270580896dac Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 650
diff changeset
7169 }
270580896dac Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 650
diff changeset
7170
270580896dac Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 650
diff changeset
7171
270580896dac Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 650
diff changeset
7172 /*
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7173 * 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
7174 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7175 * 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
7176 * 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
7177 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7178 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
7179 {
669
62aae18e7b7d Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 668
diff changeset
7180 id object = handle;
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
7181
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7182 if([ object isKindOfClass:[ NSView class ] ])
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7183 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7184 NSView *view = handle;
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
7185
669
62aae18e7b7d Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 668
diff changeset
7186 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
7187 {
62aae18e7b7d Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 668
diff changeset
7188 [view discardCursorRects];
62aae18e7b7d Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 668
diff changeset
7189 }
62aae18e7b7d Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 668
diff changeset
7190 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
7191 {
62aae18e7b7d Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 668
diff changeset
7192 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
7193 NSCursor *cursor = [NSCursor arrowCursor];
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
7194
669
62aae18e7b7d Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 668
diff changeset
7195 [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
7196 }
62aae18e7b7d Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 668
diff changeset
7197 /* 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
7198 }
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7199 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7200
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7201 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7202 * Makes the window visible.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7203 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7204 * 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
7205 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7206 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
7207 {
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
7208 NSObject *object = handle;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
7209
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
7210 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
7211 {
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
7212 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
7213 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
7214 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
7215 {
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
7216 [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
7217 }
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
7218 /* 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
7219 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
7220 {
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
7221 /* 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
7222 [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
7223 }
930
b6ee515cad8a When getting dw_window_show() called on an unresized window... trigger a relayout on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 929
diff changeset
7224 [[window contentView] showWindow];
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
7225 [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
7226 }
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
7227 return 0;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7228 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7229
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 * Makes the window invisible.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7232 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7233 * 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
7234 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7235 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
7236 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7237 NSObject *object = handle;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
7238
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7239 if([ object isKindOfClass:[ NSWindow class ] ])
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7240 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7241 NSWindow *window = handle;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
7242
733
8d5e5b89725f Fixed the crashing issue with dw_color_choose() it now functions properly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 732
diff changeset
7243 [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
7244 }
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7245 return 0;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7246 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7247
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7248 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7249 * 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
7250 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7251 * handle: The window (widget) handle.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7252 * 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
7253 * 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
7254 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7255 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
7256 {
739
a0aec9a56914 Font and color improvements... including implementing dw_window_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 738
diff changeset
7257 id object = handle;
a0aec9a56914 Font and color improvements... including implementing dw_window_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 738
diff changeset
7258 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
7259 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
7260 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
7261 NSColor *bg = NULL;
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
7262
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
7263 /* 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
7264 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
7265 {
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
7266 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
7267 }
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
7268 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
7269 {
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
7270 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
7271 }
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
7272
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
7273 /* 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
7274 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
7275 {
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
7276 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
7277 }
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
7278 /* 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
7279 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
7280 {
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
7281 id cell = [object cell];
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
7282
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
7283 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
7284 {
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
7285 [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
7286 }
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
7287 }
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
7288 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
7289 {
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
7290 id cell = [object cell];
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
7291
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
7292 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
7293 {
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
7294 [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
7295 }
739
a0aec9a56914 Font and color improvements... including implementing dw_window_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 738
diff changeset
7296 }
a0aec9a56914 Font and color improvements... including implementing dw_window_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 738
diff changeset
7297 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
7298 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7299 DWBox *box = object;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
7300
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
7301 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
7302 {
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
7303 [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
7304 }
739
a0aec9a56914 Font and color improvements... including implementing dw_window_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 738
diff changeset
7305 }
810
746cdd753e7a Added coloring support for the Container/Tree/Listbox controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 809
diff changeset
7306 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
7307 {
746cdd753e7a Added coloring support for the Container/Tree/Listbox controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 809
diff changeset
7308 DWContainer *cont = handle;
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
7309
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
7310 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
7311 {
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
7312 [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
7313 }
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
7314 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
7315 {
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
7316 [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
7317 }
810
746cdd753e7a Added coloring support for the Container/Tree/Listbox controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 809
diff changeset
7318 }
1128
7d7535f6bc4e Added ability to set background color of MLE; setting foreground still outstanding.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1120
diff changeset
7319 else if([object isKindOfClass:[NSScrollView class]])
7d7535f6bc4e Added ability to set background color of MLE; setting foreground still outstanding.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1120
diff changeset
7320 {
7d7535f6bc4e Added ability to set background color of MLE; setting foreground still outstanding.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1120
diff changeset
7321 NSScrollView *sv = handle;
1130
c3138ffd0de0 Implemented foreground color changes for MLE on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1129
diff changeset
7322 DWMLE *mle = [sv documentView];
1128
7d7535f6bc4e Added ability to set background color of MLE; setting foreground still outstanding.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1120
diff changeset
7323 if(bg)
7d7535f6bc4e Added ability to set background color of MLE; setting foreground still outstanding.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1120
diff changeset
7324 {
1130
c3138ffd0de0 Implemented foreground color changes for MLE on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1129
diff changeset
7325 [mle setBackgroundColor:bg];
c3138ffd0de0 Implemented foreground color changes for MLE on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1129
diff changeset
7326 }
c3138ffd0de0 Implemented foreground color changes for MLE on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1129
diff changeset
7327 if(fg)
c3138ffd0de0 Implemented foreground color changes for MLE on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1129
diff changeset
7328 {
c3138ffd0de0 Implemented foreground color changes for MLE on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1129
diff changeset
7329 NSTextStorage *ts = [mle textStorage];
c3138ffd0de0 Implemented foreground color changes for MLE on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1129
diff changeset
7330 [ts setForegroundColor:fg];
c3138ffd0de0 Implemented foreground color changes for MLE on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1129
diff changeset
7331 }
1128
7d7535f6bc4e Added ability to set background color of MLE; setting foreground still outstanding.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1120
diff changeset
7332 }
739
a0aec9a56914 Font and color improvements... including implementing dw_window_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 738
diff changeset
7333 return 0;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7334 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7335
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7336 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7337 * 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
7338 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7339 * handle: The window (widget) handle.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7340 * 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
7341 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7342 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
7343 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7344 return 0;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7345 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7346
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7347 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7348 * 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
7349 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7350 * handle: Window (widget) handle.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7351 * width: New width in pixels.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7352 * height: New height in pixels.
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 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
7355 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7356 id object = handle;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
7357
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
7358 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
7359 {
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
7360 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
7361 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
7362 int tmp;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
7363
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
7364 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
7365 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
7366 tmp |= style;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
7367
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
7368 [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
7369 }
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
7370 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
7371 {
bb3b2d804f0e Working on fonts some more.... setting a default label font that is smaller.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 739
diff changeset
7372 NSTextField *tf = object;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
7373
859
80a88c91ccf6 Implemented vertical centering on text fields.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 858
diff changeset
7374 [[tf cell] setAlignment:(style & 0xF)];
931
dfd84cefd80b Minor changes to vertical centering on (status) text fields on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 930
diff changeset
7375 if(mask & DW_DT_VCENTER)
dfd84cefd80b Minor changes to vertical centering on (status) text fields on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 930
diff changeset
7376 {
dfd84cefd80b Minor changes to vertical centering on (status) text fields on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 930
diff changeset
7377 [[tf cell] setVCenter:(style & DW_DT_VCENTER ? YES : NO)];
859
80a88c91ccf6 Implemented vertical centering on text fields.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 858
diff changeset
7378 }
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
7379 }
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
7380 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
7381 {
48f8efba898f Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 674
diff changeset
7382 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
7383 [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
7384 }
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
7385 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
7386 {
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
7387 DWButton *button = handle;
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
7388
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
7389 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
7390 {
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
7391 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
7392 {
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
7393 [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
7394 [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
7395 }
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
7396 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
7397 {
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
7398 [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
7399 [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
7400 }
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
7401 }
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
7402 }
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7403 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7404
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7405 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7406 * 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
7407 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7408 * window: Toplevel window or dialog.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7409 * 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
7410 */
766
82cde14ec084 Enable recalculating the key view loop (keyboard focus list) automatically.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 763
diff changeset
7411 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
7412 {
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
7413 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
7414 id object = defaultitem;
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
7415
872
13debcad9757 Another test fix at reported crash in dw_window_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 867
diff changeset
7416 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
7417 {
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
7418 [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
7419 }
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7420 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7421
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7422 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7423 * 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
7424 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7425 * 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
7426 * 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
7427 */
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
7428 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
7429 {
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
7430 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
7431 id control = next;
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
7432
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
7433 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
7434 {
fc6a626a96cc Initial groupbox support. Sizing of the content frame is not quite right yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 768
diff changeset
7435 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
7436 {
fc6a626a96cc Initial groupbox support. Sizing of the content frame is not quite right yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 768
diff changeset
7437 NSWindow *window = object;
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
7438
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
7439 [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
7440 }
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
7441 }
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
7442 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
7443 {
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
7444 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
7445 {
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
7446 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
7447 }
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
7448 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
7449 {
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
7450 /* 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
7451 * 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
7452 */
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
7453 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
7454 }
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
7455 [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
7456 }
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 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7460 * 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
7461 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7462 * handle: Handle to receive mouse input.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7463 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7464 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
7465 {
949
451c71b7fdb1 Changed dw_window_capture() an dw_window_release() because the mouseDragged method does this already.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 948
diff changeset
7466 /* Don't do anything for now */
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7467 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7468
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7469 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7470 * Releases previous mouse capture.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7471 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7472 void API dw_window_release(void)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7473 {
949
451c71b7fdb1 Changed dw_window_capture() an dw_window_release() because the mouseDragged method does this already.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 948
diff changeset
7474 /* Don't do anything for now */
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7475 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7476
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7477 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7478 * 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
7479 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7480 * handle: The window handle to destroy.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7481 * 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
7482 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7483 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
7484 {
686
218d676baf7f Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 685
diff changeset
7485 id object = handle;
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
7486
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
7487 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
7488 {
218d676baf7f Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 685
diff changeset
7489 /* 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
7490 * 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
7491 * 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
7492 */
218d676baf7f Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 685
diff changeset
7493 NSWindow *window = handle;
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
7494
686
218d676baf7f Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 685
diff changeset
7495 /* 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
7496 if(newparent)
218d676baf7f Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 685
diff changeset
7497 {
218d676baf7f Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 685
diff changeset
7498 object = newparent;
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
7499
686
218d676baf7f Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 685
diff changeset
7500 /* 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
7501 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
7502 {
218d676baf7f Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 685
diff changeset
7503 /* 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
7504 [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
7505 [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
7506 return;
218d676baf7f Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 685
diff changeset
7507 }
218d676baf7f Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 685
diff changeset
7508 }
218d676baf7f Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 685
diff changeset
7509 /* 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
7510 [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
7511 [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
7512 }
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7513 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7514
1051
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1050
diff changeset
7515 /* Allows the user to choose a font using the system's font chooser dialog.
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1050
diff changeset
7516 * Parameters:
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1050
diff changeset
7517 * currfont: current font
1050
48f43c975533 Added dw_font_choose() on the Mac for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1048
diff changeset
7518 * Returns:
1051
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1050
diff changeset
7519 * A malloced buffer with the selected font or NULL on error.
1050
48f43c975533 Added dw_font_choose() on the Mac for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1048
diff changeset
7520 */
48f43c975533 Added dw_font_choose() on the Mac for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1048
diff changeset
7521 char * API dw_font_choose(char *currfont)
48f43c975533 Added dw_font_choose() on the Mac for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1048
diff changeset
7522 {
48f43c975533 Added dw_font_choose() on the Mac for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1048
diff changeset
7523 /* Create the Color Chooser Dialog class. */
48f43c975533 Added dw_font_choose() on the Mac for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1048
diff changeset
7524 static DWFontChoose *fontDlg = nil;
48f43c975533 Added dw_font_choose() on the Mac for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1048
diff changeset
7525 static NSFontManager *fontManager = nil;
48f43c975533 Added dw_font_choose() on the Mac for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1048
diff changeset
7526 DWDialog *dialog;
48f43c975533 Added dw_font_choose() on the Mac for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1048
diff changeset
7527 NSFont *font = nil;
1068
efaa9ceeb253 Removed test for class member for itemdata in dw_tree_item_get_data()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1067
diff changeset
7528
1050
48f43c975533 Added dw_font_choose() on the Mac for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1048
diff changeset
7529 if(currfont)
48f43c975533 Added dw_font_choose() on the Mac for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1048
diff changeset
7530 font = _dw_font_by_name(currfont);
1068
efaa9ceeb253 Removed test for class member for itemdata in dw_tree_item_get_data()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1067
diff changeset
7531
1050
48f43c975533 Added dw_font_choose() on the Mac for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1048
diff changeset
7532 if(fontDlg)
48f43c975533 Added dw_font_choose() on the Mac for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1048
diff changeset
7533 {
48f43c975533 Added dw_font_choose() on the Mac for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1048
diff changeset
7534 dialog = [fontDlg dialog];
48f43c975533 Added dw_font_choose() on the Mac for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1048
diff changeset
7535 /* If someone is already waiting just return */
48f43c975533 Added dw_font_choose() on the Mac for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1048
diff changeset
7536 if(dialog)
48f43c975533 Added dw_font_choose() on the Mac for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1048
diff changeset
7537 {
48f43c975533 Added dw_font_choose() on the Mac for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1048
diff changeset
7538 return NULL;
48f43c975533 Added dw_font_choose() on the Mac for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1048
diff changeset
7539 }
48f43c975533 Added dw_font_choose() on the Mac for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1048
diff changeset
7540 }
48f43c975533 Added dw_font_choose() on the Mac for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1048
diff changeset
7541 else
48f43c975533 Added dw_font_choose() on the Mac for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1048
diff changeset
7542 {
48f43c975533 Added dw_font_choose() on the Mac for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1048
diff changeset
7543 [NSFontManager setFontPanelFactory:[DWFontChoose class]];
48f43c975533 Added dw_font_choose() on the Mac for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1048
diff changeset
7544 fontManager = [NSFontManager sharedFontManager];
48f43c975533 Added dw_font_choose() on the Mac for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1048
diff changeset
7545 fontDlg = (DWFontChoose *)[fontManager fontPanel:YES];
48f43c975533 Added dw_font_choose() on the Mac for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1048
diff changeset
7546 }
1068
efaa9ceeb253 Removed test for class member for itemdata in dw_tree_item_get_data()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1067
diff changeset
7547
1050
48f43c975533 Added dw_font_choose() on the Mac for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1048
diff changeset
7548 dialog = dw_dialog_new(fontDlg);
48f43c975533 Added dw_font_choose() on the Mac for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1048
diff changeset
7549 if(font)
48f43c975533 Added dw_font_choose() on the Mac for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1048
diff changeset
7550 [fontManager setSelectedFont:font isMultiple:NO];
48f43c975533 Added dw_font_choose() on the Mac for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1048
diff changeset
7551 else
48f43c975533 Added dw_font_choose() on the Mac for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1048
diff changeset
7552 [fontManager setSelectedFont:[NSFont fontWithName:@"Helvetica" size:9.0] isMultiple:NO];
48f43c975533 Added dw_font_choose() on the Mac for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1048
diff changeset
7553 [fontDlg setDialog:dialog];
48f43c975533 Added dw_font_choose() on the Mac for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1048
diff changeset
7554 [fontDlg setFontManager:fontManager];
48f43c975533 Added dw_font_choose() on the Mac for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1048
diff changeset
7555 [fontManager orderFrontFontPanel:fontManager];
48f43c975533 Added dw_font_choose() on the Mac for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1048
diff changeset
7556
1068
efaa9ceeb253 Removed test for class member for itemdata in dw_tree_item_get_data()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1067
diff changeset
7557
1050
48f43c975533 Added dw_font_choose() on the Mac for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1048
diff changeset
7558 /* Wait for them to pick a color */
48f43c975533 Added dw_font_choose() on the Mac for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1048
diff changeset
7559 font = (NSFont *)dw_dialog_wait(dialog);
48f43c975533 Added dw_font_choose() on the Mac for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1048
diff changeset
7560 if(font)
48f43c975533 Added dw_font_choose() on the Mac for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1048
diff changeset
7561 {
48f43c975533 Added dw_font_choose() on the Mac for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1048
diff changeset
7562 NSString *fontname = [font displayName];
48f43c975533 Added dw_font_choose() on the Mac for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1048
diff changeset
7563 NSString *output = [NSString stringWithFormat:@"%d.%s", (int)[font pointSize], [fontname UTF8String]];
1068
efaa9ceeb253 Removed test for class member for itemdata in dw_tree_item_get_data()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1067
diff changeset
7564 return strdup([output UTF8String]);
1050
48f43c975533 Added dw_font_choose() on the Mac for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1048
diff changeset
7565 }
48f43c975533 Added dw_font_choose() on the Mac for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1048
diff changeset
7566 return NULL;
48f43c975533 Added dw_font_choose() on the Mac for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1048
diff changeset
7567 }
48f43c975533 Added dw_font_choose() on the Mac for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1048
diff changeset
7568
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7569 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7570 * 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
7571 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7572 * handle: The window (widget) handle.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7573 * 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
7574 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7575 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
7576 {
744
9882b0dfa304 Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 743
diff changeset
7577 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
7578
744
9882b0dfa304 Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 743
diff changeset
7579 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
7580 {
744
9882b0dfa304 Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 743
diff changeset
7581 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
7582 if([object window])
673
6d0f0dc7ff7c Some minor font fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 672
diff changeset
7583 {
744
9882b0dfa304 Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 743
diff changeset
7584 [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
7585 [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
7586 [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
7587 }
1040
7ea8a428e0cc Attempt at adding support for groupboxes to dw_window_set/get_font() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1027
diff changeset
7588 if([object isMemberOfClass:[DWGroupBox class]])
7ea8a428e0cc Attempt at adding support for groupboxes to dw_window_set/get_font() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1027
diff changeset
7589 {
7ea8a428e0cc Attempt at adding support for groupboxes to dw_window_set/get_font() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1027
diff changeset
7590 [object setTitleFont:font];
7ea8a428e0cc Attempt at adding support for groupboxes to dw_window_set/get_font() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1027
diff changeset
7591 }
7ea8a428e0cc Attempt at adding support for groupboxes to dw_window_set/get_font() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1027
diff changeset
7592 else if([object isKindOfClass:[NSControl class]])
744
9882b0dfa304 Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 743
diff changeset
7593 {
9882b0dfa304 Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 743
diff changeset
7594 [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
7595 [[object cell] setFont:font];
673
6d0f0dc7ff7c Some minor font fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 672
diff changeset
7596 }
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
7597 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
7598 {
d29fb0d5b291 Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 744
diff changeset
7599 DWRender *render = object;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
7600
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
7601 [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
7602 }
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
7603 }
bb3b2d804f0e Working on fonts some more.... setting a default label font that is smaller.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 739
diff changeset
7604 return 0;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7605 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7606
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7607 /*
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
7608 * Returns the current font for the specified window
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
7609 * Parameters:
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
7610 * 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
7611 */
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
7612 char * API dw_window_get_font(HWND handle)
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
7613 {
739
a0aec9a56914 Font and color improvements... including implementing dw_window_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 738
diff changeset
7614 id object = handle;
1040
7ea8a428e0cc Attempt at adding support for groupboxes to dw_window_set/get_font() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1027
diff changeset
7615 NSFont *font = nil;
7ea8a428e0cc Attempt at adding support for groupboxes to dw_window_set/get_font() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1027
diff changeset
7616
7ea8a428e0cc Attempt at adding support for groupboxes to dw_window_set/get_font() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1027
diff changeset
7617 if([object isMemberOfClass:[DWGroupBox class]])
7ea8a428e0cc Attempt at adding support for groupboxes to dw_window_set/get_font() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1027
diff changeset
7618 {
7ea8a428e0cc Attempt at adding support for groupboxes to dw_window_set/get_font() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1027
diff changeset
7619 font = [object titleFont];
7ea8a428e0cc Attempt at adding support for groupboxes to dw_window_set/get_font() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1027
diff changeset
7620 }
7ea8a428e0cc Attempt at adding support for groupboxes to dw_window_set/get_font() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1027
diff changeset
7621 else if([object isKindOfClass:[NSControl class]] || [object isMemberOfClass:[DWRender class]])
7ea8a428e0cc Attempt at adding support for groupboxes to dw_window_set/get_font() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1027
diff changeset
7622 {
7ea8a428e0cc Attempt at adding support for groupboxes to dw_window_set/get_font() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1027
diff changeset
7623 font = [object font];
7ea8a428e0cc Attempt at adding support for groupboxes to dw_window_set/get_font() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1027
diff changeset
7624 }
7ea8a428e0cc Attempt at adding support for groupboxes to dw_window_set/get_font() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1027
diff changeset
7625 if(font)
7ea8a428e0cc Attempt at adding support for groupboxes to dw_window_set/get_font() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1027
diff changeset
7626 {
1041
6a57bf20d8f9 Return displayName property instead of fontName property in dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1040
diff changeset
7627 NSString *fontname = [font displayName];
739
a0aec9a56914 Font and color improvements... including implementing dw_window_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 738
diff changeset
7628 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
7629 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
7630 }
a0aec9a56914 Font and color improvements... including implementing dw_window_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 738
diff changeset
7631 return NULL;
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
7632 }
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
7633
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
7634 /*
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7635 * 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
7636 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7637 * handle: The window handle to destroy.
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 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
7640 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
7641 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
7642 DW_MUTEX_LOCK;
937
83aceaaef6ed Added initial support for allowing dW_window_destroy() to remove an item from its containing box on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 936
diff changeset
7643 id object = handle;
83aceaaef6ed Added initial support for allowing dW_window_destroy() to remove an item from its containing box on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 936
diff changeset
7644
83aceaaef6ed Added initial support for allowing dW_window_destroy() to remove an item from its containing box on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 936
diff changeset
7645 /* Handle destroying a top-levle window */
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7646 if([ object isKindOfClass:[ NSWindow class ] ])
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7647 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7648 NSWindow *window = handle;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7649 [window close];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7650 }
937
83aceaaef6ed Added initial support for allowing dW_window_destroy() to remove an item from its containing box on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 936
diff changeset
7651 /* Handle destroying a control or box */
1099
d1cea9be1436 Fixed dw_window_destroy() with groupboxes on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1098
diff changeset
7652 else if([object isKindOfClass:[DWBox class]] || [object isKindOfClass:[DWGroupBox class]] || [object isKindOfClass:[NSControl class]])
937
83aceaaef6ed Added initial support for allowing dW_window_destroy() to remove an item from its containing box on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 936
diff changeset
7653 {
83aceaaef6ed Added initial support for allowing dW_window_destroy() to remove an item from its containing box on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 936
diff changeset
7654 DWBox *parent = (DWBox *)[object superview];
983
6abf763838c6 Allow checboxes and other "buttons" to have a blank title instead of the default "Button"
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 982
diff changeset
7655
6abf763838c6 Allow checboxes and other "buttons" to have a blank title instead of the default "Button"
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 982
diff changeset
7656 /* Some controls are embedded in scrollviews...
979
f6234f870e81 Attempt at fixing dw_window_destroy() for controls that are embedded in scrollviews on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 957
diff changeset
7657 * so get the parent of the scrollview in that case.
f6234f870e81 Attempt at fixing dw_window_destroy() for controls that are embedded in scrollviews on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 957
diff changeset
7658 */
982
a4425bb24b77 Fixed dw_window_destroy() on container and trees... there are multiple parts to scrollviews aparently on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 981
diff changeset
7659 if([object isKindOfClass:[NSTableView class]] && [parent isMemberOfClass:[NSClipView class]])
a4425bb24b77 Fixed dw_window_destroy() on container and trees... there are multiple parts to scrollviews aparently on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 981
diff changeset
7660 {
a4425bb24b77 Fixed dw_window_destroy() on container and trees... there are multiple parts to scrollviews aparently on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 981
diff changeset
7661 object = [parent superview];
980
94dde9b3dfc0 Ok so we need to set the object to be the right value in this case so it gets removed from the proper view on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 979
diff changeset
7662 parent = (DWBox *)[object superview];
979
f6234f870e81 Attempt at fixing dw_window_destroy() for controls that are embedded in scrollviews on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 957
diff changeset
7663 }
940
b5ae9cf15f68 Fix for returning wrong extension in _dw_get_image_extension; only worked for .ico files
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 939
diff changeset
7664
1099
d1cea9be1436 Fixed dw_window_destroy() with groupboxes on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1098
diff changeset
7665 if([parent isKindOfClass:[DWBox class]] || [parent isKindOfClass:[DWGroupBox class]])
937
83aceaaef6ed Added initial support for allowing dW_window_destroy() to remove an item from its containing box on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 936
diff changeset
7666 {
83aceaaef6ed Added initial support for allowing dW_window_destroy() to remove an item from its containing box on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 936
diff changeset
7667 Box *thisbox = [parent box];
83aceaaef6ed Added initial support for allowing dW_window_destroy() to remove an item from its containing box on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 936
diff changeset
7668 int z, index = -1;
83aceaaef6ed Added initial support for allowing dW_window_destroy() to remove an item from its containing box on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 936
diff changeset
7669 Item *tmpitem, *thisitem = thisbox->items;
940
b5ae9cf15f68 Fix for returning wrong extension in _dw_get_image_extension; only worked for .ico files
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 939
diff changeset
7670
937
83aceaaef6ed Added initial support for allowing dW_window_destroy() to remove an item from its containing box on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 936
diff changeset
7671 for(z=0;z<thisbox->count;z++)
83aceaaef6ed Added initial support for allowing dW_window_destroy() to remove an item from its containing box on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 936
diff changeset
7672 {
982
a4425bb24b77 Fixed dw_window_destroy() on container and trees... there are multiple parts to scrollviews aparently on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 981
diff changeset
7673 if(thisitem[z].hwnd == object)
937
83aceaaef6ed Added initial support for allowing dW_window_destroy() to remove an item from its containing box on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 936
diff changeset
7674 index = z;
83aceaaef6ed Added initial support for allowing dW_window_destroy() to remove an item from its containing box on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 936
diff changeset
7675 }
940
b5ae9cf15f68 Fix for returning wrong extension in _dw_get_image_extension; only worked for .ico files
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 939
diff changeset
7676
937
83aceaaef6ed Added initial support for allowing dW_window_destroy() to remove an item from its containing box on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 936
diff changeset
7677 if(index == -1)
83aceaaef6ed Added initial support for allowing dW_window_destroy() to remove an item from its containing box on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 936
diff changeset
7678 {
83aceaaef6ed Added initial support for allowing dW_window_destroy() to remove an item from its containing box on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 936
diff changeset
7679 DW_MUTEX_UNLOCK;
83aceaaef6ed Added initial support for allowing dW_window_destroy() to remove an item from its containing box on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 936
diff changeset
7680 return 0;
83aceaaef6ed Added initial support for allowing dW_window_destroy() to remove an item from its containing box on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 936
diff changeset
7681 }
940
b5ae9cf15f68 Fix for returning wrong extension in _dw_get_image_extension; only worked for .ico files
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 939
diff changeset
7682
982
a4425bb24b77 Fixed dw_window_destroy() on container and trees... there are multiple parts to scrollviews aparently on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 981
diff changeset
7683 [object removeFromSuperview];
1041
6a57bf20d8f9 Return displayName property instead of fontName property in dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1040
diff changeset
7684
937
83aceaaef6ed Added initial support for allowing dW_window_destroy() to remove an item from its containing box on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 936
diff changeset
7685 tmpitem = malloc(sizeof(Item)*(thisbox->count-1));
940
b5ae9cf15f68 Fix for returning wrong extension in _dw_get_image_extension; only worked for .ico files
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 939
diff changeset
7686
937
83aceaaef6ed Added initial support for allowing dW_window_destroy() to remove an item from its containing box on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 936
diff changeset
7687 /* Copy all but the current entry to the new list */
83aceaaef6ed Added initial support for allowing dW_window_destroy() to remove an item from its containing box on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 936
diff changeset
7688 for(z=0;z<index;z++)
83aceaaef6ed Added initial support for allowing dW_window_destroy() to remove an item from its containing box on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 936
diff changeset
7689 {
83aceaaef6ed Added initial support for allowing dW_window_destroy() to remove an item from its containing box on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 936
diff changeset
7690 tmpitem[z] = thisitem[z];
83aceaaef6ed Added initial support for allowing dW_window_destroy() to remove an item from its containing box on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 936
diff changeset
7691 }
83aceaaef6ed Added initial support for allowing dW_window_destroy() to remove an item from its containing box on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 936
diff changeset
7692 for(z=index+1;z<thisbox->count;z++)
83aceaaef6ed Added initial support for allowing dW_window_destroy() to remove an item from its containing box on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 936
diff changeset
7693 {
83aceaaef6ed Added initial support for allowing dW_window_destroy() to remove an item from its containing box on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 936
diff changeset
7694 tmpitem[z-1] = thisitem[z];
83aceaaef6ed Added initial support for allowing dW_window_destroy() to remove an item from its containing box on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 936
diff changeset
7695 }
940
b5ae9cf15f68 Fix for returning wrong extension in _dw_get_image_extension; only worked for .ico files
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 939
diff changeset
7696
937
83aceaaef6ed Added initial support for allowing dW_window_destroy() to remove an item from its containing box on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 936
diff changeset
7697 thisbox->items = tmpitem;
83aceaaef6ed Added initial support for allowing dW_window_destroy() to remove an item from its containing box on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 936
diff changeset
7698 free(thisitem);
940
b5ae9cf15f68 Fix for returning wrong extension in _dw_get_image_extension; only worked for .ico files
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 939
diff changeset
7699 thisbox->count--;
937
83aceaaef6ed Added initial support for allowing dW_window_destroy() to remove an item from its containing box on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 936
diff changeset
7700 }
83aceaaef6ed Added initial support for allowing dW_window_destroy() to remove an item from its containing box on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 936
diff changeset
7701 }
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
7702 DW_MUTEX_UNLOCK;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7703 return 0;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7704 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7705
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7706 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7707 * 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
7708 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7709 * handle: Handle to the window.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7710 * Returns:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7711 * 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
7712 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7713 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
7714 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7715 NSObject *object = handle;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
7716
1027
cbac281970a9 Added support for dw_window_get_text() on spinbutton controls on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1026
diff changeset
7717 if([object isMemberOfClass:[ DWSpinButton class]])
cbac281970a9 Added support for dw_window_get_text() on spinbutton controls on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1026
diff changeset
7718 {
cbac281970a9 Added support for dw_window_get_text() on spinbutton controls on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1026
diff changeset
7719 DWSpinButton *spinbutton = handle;
cbac281970a9 Added support for dw_window_get_text() on spinbutton controls on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1026
diff changeset
7720 handle = object = [spinbutton textfield];
cbac281970a9 Added support for dw_window_get_text() on spinbutton controls on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1026
diff changeset
7721 }
808
c0641a6d4258 Similar fix for dw_window_get_text().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 807
diff changeset
7722 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
7723 {
c0641a6d4258 Similar fix for dw_window_get_text().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 807
diff changeset
7724 id window = handle;
c0641a6d4258 Similar fix for dw_window_get_text().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 807
diff changeset
7725 NSString *nsstr = [ window title];
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
7726
808
c0641a6d4258 Similar fix for dw_window_get_text().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 807
diff changeset
7727 return strdup([ nsstr UTF8String ]);
c0641a6d4258 Similar fix for dw_window_get_text().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 807
diff changeset
7728 }
c0641a6d4258 Similar fix for dw_window_get_text().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 807
diff changeset
7729 else if([ object isKindOfClass:[ NSControl class ] ])
752
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 NSControl *control = handle;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7732 NSString *nsstr = [ control stringValue];
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
7733
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7734 return strdup([ nsstr UTF8String ]);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7735 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7736 return NULL;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7737 }
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 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7740 * 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
7741 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7742 * handle: Handle to the window.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7743 * 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
7744 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7745 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
7746 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
7747 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
7748 DW_MUTEX_LOCK;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7749 NSObject *object = handle;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
7750
1027
cbac281970a9 Added support for dw_window_get_text() on spinbutton controls on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1026
diff changeset
7751 if([object isMemberOfClass:[ DWSpinButton class]])
cbac281970a9 Added support for dw_window_get_text() on spinbutton controls on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1026
diff changeset
7752 {
cbac281970a9 Added support for dw_window_get_text() on spinbutton controls on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1026
diff changeset
7753 DWSpinButton *spinbutton = handle;
cbac281970a9 Added support for dw_window_get_text() on spinbutton controls on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1026
diff changeset
7754 handle = object = [spinbutton textfield];
cbac281970a9 Added support for dw_window_get_text() on spinbutton controls on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1026
diff changeset
7755 }
807
f7016a38bedd Fix for dw_window_set_text() on buttons not working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 806
diff changeset
7756 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
7757 {
f7016a38bedd Fix for dw_window_set_text() on buttons not working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 806
diff changeset
7758 id window = handle;
f7016a38bedd Fix for dw_window_set_text() on buttons not working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 806
diff changeset
7759 [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
7760 }
f7016a38bedd Fix for dw_window_set_text() on buttons not working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 806
diff changeset
7761 else if([ object isKindOfClass:[ NSControl class ] ])
752
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 NSControl *control = handle;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7764 [control setStringValue:[ NSString stringWithUTF8String:text ]];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7765 }
953
2dfc06afc7d3 Support dw_window_set_text() for groupboxes
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 952
diff changeset
7766 else if([object isMemberOfClass:[DWGroupBox class]])
2dfc06afc7d3 Support dw_window_set_text() for groupboxes
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 952
diff changeset
7767 {
2dfc06afc7d3 Support dw_window_set_text() for groupboxes
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 952
diff changeset
7768 DWGroupBox *groupbox = handle;
2dfc06afc7d3 Support dw_window_set_text() for groupboxes
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 952
diff changeset
7769 [groupbox setTitle:[NSString stringWithUTF8String:text]];
2dfc06afc7d3 Support dw_window_set_text() for groupboxes
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 952
diff changeset
7770 }
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
7771 DW_MUTEX_UNLOCK;
650
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
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7774 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7775 * Disables given window (widget).
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7776 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7777 * handle: Handle to the window.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7778 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7779 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
7780 {
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
7781 id object = handle;
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
7782
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
7783 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
7784 {
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
7785 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
7786 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
7787 }
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
7788 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
7789 {
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
7790 NSControl *control = object;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7791 [control setEnabled:NO];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7792 }
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
7793 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
7794 {
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
7795 NSTextView *mle = object;
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
7796
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
7797 [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
7798 }
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7799 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7800
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7801 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7802 * Enables given window (widget).
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7803 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7804 * handle: Handle to the window.
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 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
7807 {
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
7808 id object = handle;
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
7809
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
7810 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
7811 {
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
7812 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
7813 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
7814 }
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
7815 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
7816 {
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
7817 NSControl *control = object;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7818 [control setEnabled:YES];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7819 }
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
7820 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
7821 {
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
7822 NSTextView *mle = object;
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
7823
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
7824 [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
7825 }
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7826 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7827
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7828 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7829 * 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
7830 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7831 * handle: Handle to the window.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7832 * 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
7833 * (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
7834 * 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
7835 * 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
7836 * 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
7837 */
685
314a12dccd20 Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 684
diff changeset
7838 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
7839 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7840 NSObject *object = handle;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7841 if([ object isKindOfClass:[ NSImageView class ] ])
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7842 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7843 NSImageView *iv = handle;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
7844 NSData *thisdata = [NSData dataWithBytes:data length:len];
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7845 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
7846
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
7847 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
7848 {
48f8efba898f Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 674
diff changeset
7849 [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
7850 }
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
7851 [pixmap release];
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7852 }
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7853 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7854
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7855 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7856 * 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
7857 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7858 * handle: Handle to the window.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7859 * 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
7860 * (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
7861 * 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
7862 * 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
7863 * 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
7864 */
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
7865 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
7866 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7867 NSObject *object = handle;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7868 if([ object isKindOfClass:[ NSImageView class ] ])
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7869 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7870 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
7871 NSImage *bitmap = nil;
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
7872
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
7873 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
7874 {
48f8efba898f Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 674
diff changeset
7875 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
7876 }
48f8efba898f Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 674
diff changeset
7877 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
7878 {
48f8efba898f Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 674
diff changeset
7879 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
7880 }
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
7881
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
7882 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
7883 {
48f8efba898f Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 674
diff changeset
7884 [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
7885 }
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7886 }
650
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 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7890 * 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
7891 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7892 * handle: Handle to the window.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7893 * 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
7894 */
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
7895 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
7896 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7897 /* 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
7898 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7899
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7900 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7901 * 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
7902 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7903 * handle: Handle to the parent window.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7904 * id: Integer ID of the child.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7905 */
685
314a12dccd20 Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 684
diff changeset
7906 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
7907 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7908 NSObject *object = handle;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7909 NSView *view = handle;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7910 if([ object isKindOfClass:[ NSWindow class ] ])
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7911 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7912 NSWindow *window = handle;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7913 view = [window contentView];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7914 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7915 return [view viewWithTag:cid];
650
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
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 * 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
7920 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7921 * handle: The window handle to minimize.
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 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
7924 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7925 NSWindow *window = handle;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7926 [window miniaturize:nil];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7927 return 0;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7928 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7929
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7930 /* 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
7931 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7932 * 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
7933 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7934 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
7935 {
1101
d7eafaa054ab Added support for dw_window_redraw() causing splitbar panes to redraw without
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1100
diff changeset
7936 DWWindow *window = handle;
d7eafaa054ab Added support for dw_window_redraw() causing splitbar panes to redraw without
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1100
diff changeset
7937 [window setRedraw:YES];
941
18f194e1d71d dw_window_redraw() should relayout the window in addition to flushing the buffer on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 940
diff changeset
7938 [[window contentView] showWindow];
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7939 [window flushWindow];
1101
d7eafaa054ab Added support for dw_window_redraw() causing splitbar panes to redraw without
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1100
diff changeset
7940 [window setRedraw:NO];
650
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
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 * Makes the window topmost.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7945 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7946 * 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
7947 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7948 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
7949 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7950 NSWindow *window = handle;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7951 [window orderFront:nil];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7952 return 0;
650
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
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7955 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7956 * Makes the window bottommost.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7957 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7958 * 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
7959 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7960 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
7961 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7962 NSWindow *window = handle;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7963 [window orderBack:nil];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7964 return 0;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7965 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7966
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7967 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7968 * 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
7969 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7970 * handle: Window (widget) handle.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7971 * width: New width in pixels.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7972 * height: New height in pixels.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7973 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7974 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
7975 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
7976 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
7977 DW_MUTEX_LOCK;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7978 NSObject *object = handle;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7979 NSSize size;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7980 size.width = width;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7981 size.height = height;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
7982
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7983 if([ object isKindOfClass:[ NSWindow class ] ])
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7984 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7985 NSWindow *window = handle;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7986 [window setContentSize:size];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7987 }
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
7988 DW_MUTEX_UNLOCK;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7989 }
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 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7992 * 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
7993 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7994 * handle: Window (widget) handle.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7995 * 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
7996 * 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
7997 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7998 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
7999 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
8000 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
8001 DW_MUTEX_LOCK;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8002 NSObject *object = handle;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8003 NSPoint point;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8004 point.x = x;
946
c64d3ca566f9 Attempt at inverting the window position and mouse pointer coordinates on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 945
diff changeset
8005 point.y = [[NSScreen mainScreen] frame].size.height - y;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
8006
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8007 if([ object isKindOfClass:[ NSWindow class ] ])
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8008 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8009 NSWindow *window = handle;
947
c9f6ba940453 On window sizes we need to flip the origin point on the frame too on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 946
diff changeset
8010 point.y -= [window frame].size.height;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8011 [window setFrameOrigin:point];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8012 }
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
8013 DW_MUTEX_UNLOCK;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8014 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8015
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8016 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8017 * 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
8018 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8019 * handle: Window (widget) handle.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8020 * 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
8021 * 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
8022 * width: Width of the widget.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8023 * height: Height of the widget.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8024 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8025 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
8026 {
947
c9f6ba940453 On window sizes we need to flip the origin point on the frame too on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 946
diff changeset
8027 dw_window_set_size(handle, width, height);
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8028 dw_window_set_pos(handle, x, y);
650
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 * 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
8033 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8034 * handle: Window (widget) handle.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8035 * 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
8036 * 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
8037 * width: Width of the widget.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8038 * height: Height of the widget.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8039 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8040 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
8041 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8042 NSObject *object = handle;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
8043
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8044 if([ object isKindOfClass:[ NSWindow class ] ])
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8045 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8046 NSWindow *window = handle;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8047 NSRect rect = [window frame];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8048 if(x)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8049 *x = rect.origin.x;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8050 if(y)
947
c9f6ba940453 On window sizes we need to flip the origin point on the frame too on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 946
diff changeset
8051 *y = [[NSScreen mainScreen] frame].size.height - rect.origin.y - rect.size.height;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8052 if(width)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8053 *width = rect.size.width;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8054 if(height)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8055 *height = rect.size.height;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8056 return;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8057 }
951
7193401d139a Added support for dw_window_get_pos_size() to work on individual controls on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 950
diff changeset
8058 else if([ object isKindOfClass:[ NSControl class ] ])
7193401d139a Added support for dw_window_get_pos_size() to work on individual controls on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 950
diff changeset
8059 {
7193401d139a Added support for dw_window_get_pos_size() to work on individual controls on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 950
diff changeset
8060 NSControl *control = handle;
7193401d139a Added support for dw_window_get_pos_size() to work on individual controls on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 950
diff changeset
8061 NSRect rect = [control frame];
7193401d139a Added support for dw_window_get_pos_size() to work on individual controls on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 950
diff changeset
8062 if(x)
7193401d139a Added support for dw_window_get_pos_size() to work on individual controls on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 950
diff changeset
8063 *x = rect.origin.x;
7193401d139a Added support for dw_window_get_pos_size() to work on individual controls on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 950
diff changeset
8064 if(y)
7193401d139a Added support for dw_window_get_pos_size() to work on individual controls on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 950
diff changeset
8065 *y = rect.origin.y;
7193401d139a Added support for dw_window_get_pos_size() to work on individual controls on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 950
diff changeset
8066 if(width)
7193401d139a Added support for dw_window_get_pos_size() to work on individual controls on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 950
diff changeset
8067 *width = rect.size.width;
7193401d139a Added support for dw_window_get_pos_size() to work on individual controls on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 950
diff changeset
8068 if(height)
7193401d139a Added support for dw_window_get_pos_size() to work on individual controls on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 950
diff changeset
8069 *height = rect.size.height;
7193401d139a Added support for dw_window_get_pos_size() to work on individual controls on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 950
diff changeset
8070 return;
7193401d139a Added support for dw_window_get_pos_size() to work on individual controls on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 950
diff changeset
8071 }
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8072 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8073
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8074 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8075 * Returns the width of the screen.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8076 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8077 int API dw_screen_width(void)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8078 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8079 NSRect screenRect = [[NSScreen mainScreen] frame];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8080 return screenRect.size.width;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8081 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8082
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8083 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8084 * Returns the height of the screen.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8085 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8086 int API dw_screen_height(void)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8087 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8088 NSRect screenRect = [[NSScreen mainScreen] frame];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8089 return screenRect.size.height;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8090 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8091
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8092 /* 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
8093 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
8094 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8095 NSWindowDepth screenDepth = [[NSScreen mainScreen] depth];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8096 return NSBitsPerPixelFromDepth(screenDepth);
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8097 }
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 * 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
8101 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8102 * env: Pointer to a DWEnv struct.
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 void dw_environment_query(DWEnv *env)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8105 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8106 struct utsname name;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
8107
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8108 uname(&name);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8109 strcpy(env->osName, "MacOS");
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
8110
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8111 strcpy(env->buildDate, __DATE__);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8112 strcpy(env->buildTime, __TIME__);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8113 env->DWMajorVersion = DW_MAJOR_VERSION;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8114 env->DWMinorVersion = DW_MINOR_VERSION;
1160
924c8087a755 Attempt to use the subversion revision number as the sub version number.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1158
diff changeset
8115 #ifdef VER_REV
924c8087a755 Attempt to use the subversion revision number as the sub version number.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1158
diff changeset
8116 env->DWSubVersion = VER_REV;
924c8087a755 Attempt to use the subversion revision number as the sub version number.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1158
diff changeset
8117 #else
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8118 env->DWSubVersion = DW_SUB_VERSION;
1160
924c8087a755 Attempt to use the subversion revision number as the sub version number.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1158
diff changeset
8119 #endif
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
8120
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
8121 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
8122 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
8123 env->MajorBuild = DWOSBuild;
809
1ef0f4c03c14 MinorBuild was being left uninitialized.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 808
diff changeset
8124 env->MinorBuild = 0;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8125 }
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 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8128 * Emits a beep.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8129 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8130 * freq: Frequency.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8131 * dur: Duration.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8132 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8133 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
8134 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8135 NSBeep();
650
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
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8138 /* 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
8139 * anything you have drawn is visible.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8140 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8141 void API dw_flush(void)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8142 {
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
8143 /* 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
8144 [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
8145 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8146
651
270580896dac Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 650
diff changeset
8147 /* 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
8148 * 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
8149 * dw_window_get_data().
270580896dac Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 650
diff changeset
8150 */
270580896dac Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 650
diff changeset
8151 UserData *_find_userdata(UserData **root, char *varname)
270580896dac Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 650
diff changeset
8152 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8153 UserData *tmp = *root;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
8154
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8155 while(tmp)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8156 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8157 if(strcasecmp(tmp->varname, varname) == 0)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8158 return tmp;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8159 tmp = tmp->next;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8160 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8161 return NULL;
651
270580896dac Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 650
diff changeset
8162 }
270580896dac Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 650
diff changeset
8163
270580896dac Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 650
diff changeset
8164 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
8165 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8166 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
8167
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8168 if(new)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8169 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8170 new->data = data;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8171 return TRUE;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8172 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8173 else
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8174 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8175 new = malloc(sizeof(UserData));
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8176 if(new)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8177 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8178 new->varname = strdup(varname);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8179 new->data = data;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
8180
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8181 new->next = NULL;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
8182
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8183 if (!*root)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8184 *root = new;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8185 else
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8186 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8187 UserData *prev = NULL, *tmp = *root;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8188 while(tmp)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8189 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8190 prev = tmp;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8191 tmp = tmp->next;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8192 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8193 if(prev)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8194 prev->next = new;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8195 else
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8196 *root = new;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8197 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8198 return TRUE;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8199 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8200 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8201 return FALSE;
651
270580896dac Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 650
diff changeset
8202 }
270580896dac Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 650
diff changeset
8203
270580896dac Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 650
diff changeset
8204 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
8205 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8206 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
8207
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8208 while(tmp)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8209 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8210 if(all || strcasecmp(tmp->varname, varname) == 0)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8211 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8212 if(!prev)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8213 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8214 *root = tmp->next;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8215 free(tmp->varname);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8216 free(tmp);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8217 if(!all)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8218 return 0;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8219 tmp = *root;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8220 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8221 else
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8222 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8223 /* If all is true we should
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8224 * never get here.
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8225 */
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8226 prev->next = tmp->next;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8227 free(tmp->varname);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8228 free(tmp);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8229 return 0;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8230 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8231 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8232 else
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8233 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8234 prev = tmp;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8235 tmp = tmp->next;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8236 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8237 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8238 return 0;
651
270580896dac Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 650
diff changeset
8239 }
270580896dac Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 650
diff changeset
8240
650
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 * 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
8243 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8244 * 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
8245 * 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
8246 * 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
8247 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8248 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
8249 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8250 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
8251 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
8252 {
5fe12469c1fb Fix for dw_window_set/get_data() on a top-level window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 680
diff changeset
8253 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
8254 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
8255 }
5fe12469c1fb Fix for dw_window_set/get_data() on a top-level window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 680
diff changeset
8256 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
8257 {
9861d264925d MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 675
diff changeset
8258 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
8259 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
8260 }
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8261 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
8262
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8263 if(!blah)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8264 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8265 if(!dataname)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8266 return;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
8267
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8268 blah = calloc(1, sizeof(WindowData));
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8269 [object setUserdata:blah];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8270 }
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
8271
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8272 if(data)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8273 _new_userdata(&(blah->root), dataname, data);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8274 else
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8275 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8276 if(dataname)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8277 _remove_userdata(&(blah->root), dataname, FALSE);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8278 else
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8279 _remove_userdata(&(blah->root), NULL, TRUE);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8280 }
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8281 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8282
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8283 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8284 * 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
8285 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8286 * 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
8287 * 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
8288 * 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
8289 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8290 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
8291 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8292 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
8293 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
8294 {
5fe12469c1fb Fix for dw_window_set/get_data() on a top-level window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 680
diff changeset
8295 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
8296 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
8297 }
5fe12469c1fb Fix for dw_window_set/get_data() on a top-level window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 680
diff changeset
8298 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
8299 {
9861d264925d MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 675
diff changeset
8300 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
8301 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
8302 }
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8303 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
8304
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8305 if(blah && blah->root && dataname)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8306 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8307 UserData *ud = _find_userdata(&(blah->root), dataname);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8308 if(ud)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8309 return ud->data;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8310 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8311 return NULL;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8312 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8313
657
f31a47b055f8 Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 656
diff changeset
8314 #define DW_TIMER_MAX 64
f31a47b055f8 Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 656
diff changeset
8315 NSTimer *DWTimers[DW_TIMER_MAX];
f31a47b055f8 Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 656
diff changeset
8316
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8317 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8318 * 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
8319 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8320 * interval: Milliseconds to delay between calls.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8321 * 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
8322 * 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
8323 * Returns:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8324 * 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
8325 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8326 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
8327 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8328 int z;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
8329
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8330 for(z=0;z<DW_TIMER_MAX;z++)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8331 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8332 if(!DWTimers[z])
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8333 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8334 break;
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 }
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
8337
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8338 if(sigfunc && !DWTimers[z])
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8339 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8340 NSTimeInterval seconds = (double)interval / 1000.0;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8341 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
8342 _new_signal(0, thistimer, z+1, sigfunc, data);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8343 return z+1;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8344 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8345 return 0;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8346 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8347
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8348 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8349 * Removes timer callback.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8350 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8351 * 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
8352 */
657
f31a47b055f8 Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 656
diff changeset
8353 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
8354 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8355 SignalHandler *prev = NULL, *tmp = Root;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8356 NSTimer *thistimer;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
8357
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8358 /* 0 is an invalid timer ID */
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8359 if(timerid < 1 || !DWTimers[timerid-1])
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8360 return;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
8361
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8362 thistimer = DWTimers[timerid-1];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8363 DWTimers[timerid-1] = nil;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
8364
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8365 [thistimer invalidate];
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
8366
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8367 while(tmp)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8368 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8369 if(tmp->id == timerid && tmp->window == thistimer)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8370 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8371 if(prev)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8372 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8373 prev->next = tmp->next;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8374 free(tmp);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8375 tmp = prev->next;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8376 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8377 else
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8378 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8379 Root = tmp->next;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8380 free(tmp);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8381 tmp = Root;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8382 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8383 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8384 else
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8385 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8386 prev = tmp;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8387 tmp = tmp->next;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8388 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8389 }
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8390 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8391
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 * 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
8394 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8395 * 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
8396 * 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
8397 * 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
8398 * 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
8399 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8400 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
8401 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8402 ULONG message = 0, msgid = 0;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8403
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8404 if(window && signame && sigfunc)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8405 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8406 if((message = _findsigmessage(signame)) != 0)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8407 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8408 _new_signal(message, window, (int)msgid, sigfunc, data);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8409 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8410 }
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8411 }
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 * 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
8415 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8416 * 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
8417 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8418 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
8419 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8420 SignalHandler *prev = NULL, *tmp = Root;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8421 ULONG message;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
8422
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8423 if(!window || !signame || (message = _findsigmessage(signame)) == 0)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8424 return;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
8425
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8426 while(tmp)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8427 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8428 if(tmp->window == window && tmp->message == message)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8429 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8430 if(prev)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8431 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8432 prev->next = tmp->next;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8433 free(tmp);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8434 tmp = prev->next;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8435 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8436 else
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8437 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8438 Root = tmp->next;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8439 free(tmp);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8440 tmp = Root;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8441 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8442 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8443 else
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8444 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8445 prev = tmp;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8446 tmp = tmp->next;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8447 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8448 }
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8449 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8450
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8451 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8452 * 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
8453 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8454 * 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
8455 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8456 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
8457 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8458 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
8459
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8460 while(tmp)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8461 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8462 if(tmp->window == window)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8463 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8464 if(prev)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8465 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8466 prev->next = tmp->next;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8467 free(tmp);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8468 tmp = prev->next;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8469 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8470 else
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8471 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8472 Root = tmp->next;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8473 free(tmp);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8474 tmp = Root;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8475 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8476 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8477 else
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8478 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8479 prev = tmp;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8480 tmp = tmp->next;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8481 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8482 }
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8483 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8484
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8485 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8486 * 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
8487 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8488 * 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
8489 * 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
8490 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8491 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
8492 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8493 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
8494
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8495 while(tmp)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8496 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8497 if(tmp->window == window && tmp->data == data)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8498 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8499 if(prev)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8500 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8501 prev->next = tmp->next;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8502 free(tmp);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8503 tmp = prev->next;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8504 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8505 else
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8506 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8507 Root = tmp->next;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8508 free(tmp);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8509 tmp = Root;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8510 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8511 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8512 else
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8513 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8514 prev = tmp;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8515 tmp = tmp->next;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8516 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8517 }
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8518 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8519
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8520 void _my_strlwr(char *buf)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8521 {
1110
404b639f096b Minor typecast fixes for warnings reported by clang on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1102
diff changeset
8522 int z, len = (int)strlen(buf);
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8523
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8524 for(z=0;z<len;z++)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8525 {
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8526 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
8527 buf[z] -= 'A' - 'a';
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8528 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8529 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8530
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8531 /* 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
8532 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8533 * 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
8534 * handle: Pointer to a module handle,
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8535 * 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
8536 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8537 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
8538 {
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8539 int len;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8540 char *newname;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8541 char errorbuf[1024];
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8542
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8543
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8544 if(!handle)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8545 return -1;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8546
1110
404b639f096b Minor typecast fixes for warnings reported by clang on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1102
diff changeset
8547 if((len = (int)strlen(name)) == 0)
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8548 return -1;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8549
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8550 /* Lenth + "lib" + ".dylib" + NULL */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8551 newname = malloc(len + 10);
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8552
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8553 if(!newname)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8554 return -1;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8555
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8556 sprintf(newname, "lib%s.dylib", name);
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8557 _my_strlwr(newname);
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8558
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8559 *handle = dlopen(newname, RTLD_NOW);
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8560 if(*handle == NULL)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8561 {
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8562 strncpy(errorbuf, dlerror(), 1024);
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8563 printf("%s\n", errorbuf);
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8564 sprintf(newname, "lib%s.dylib", name);
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8565 *handle = dlopen(newname, RTLD_NOW);
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8566 }
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 free(newname);
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8569
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8570 return (NULL == *handle) ? -1 : 0;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8571 }
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 /* 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
8574 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8575 * 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
8576 * 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
8577 * 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
8578 * the address.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8579 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8580 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
8581 {
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8582 if(!func || !name)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8583 return -1;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8584
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8585 if(strlen(name) == 0)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8586 return -1;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8587
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8588 *func = (void*)dlsym(handle, name);
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8589 return (NULL == *func);
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8590 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8591
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8592 /* Frees the shared library previously opened.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8593 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8594 * 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
8595 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8596 int dw_module_close(HMOD handle)
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 if(handle)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8599 return dlclose(handle);
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8600 return 0;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8601 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8602
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 * 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
8605 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8606 HMTX dw_mutex_new(void)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8607 {
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
8608 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
8609
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
8610 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
8611 return mutex;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8612 }
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 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8615 * 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
8616 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8617 * 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
8618 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8619 void dw_mutex_close(HMTX mutex)
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(mutex)
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 pthread_mutex_destroy(mutex);
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8624 free(mutex);
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8625 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8626 }
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 * 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
8630 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8631 * 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
8632 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8633 void dw_mutex_lock(HMTX mutex)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8634 {
693
2f21ee9d7c7b Experimental change for locking on the main thread... will be committing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 692
diff changeset
8635 /* 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
8636 * 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
8637 * 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
8638 * 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
8639 */
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
8640 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
8641 {
693
2f21ee9d7c7b Experimental change for locking on the main thread... will be committing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 692
diff changeset
8642 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
8643 {
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
8644 /* 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
8645 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
8646 {
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
8647 /* 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
8648 }
693
2f21ee9d7c7b Experimental change for locking on the main thread... will be committing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 692
diff changeset
8649 }
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
8650 }
693
2f21ee9d7c7b Experimental change for locking on the main thread... will be committing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 692
diff changeset
8651 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
8652 {
693
2f21ee9d7c7b Experimental change for locking on the main thread... will be committing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 692
diff changeset
8653 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
8654 }
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8655 }
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 /*
1158
f86f556ff29d Added dw_mutex_trylock() that functions like dw_mutex_lock() except
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1155
diff changeset
8658 * Tries to gain access to the semaphore.
f86f556ff29d Added dw_mutex_trylock() that functions like dw_mutex_lock() except
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1155
diff changeset
8659 * Parameters:
f86f556ff29d Added dw_mutex_trylock() that functions like dw_mutex_lock() except
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1155
diff changeset
8660 * mutex: The handle to the mutex returned by dw_mutex_new().
f86f556ff29d Added dw_mutex_trylock() that functions like dw_mutex_lock() except
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1155
diff changeset
8661 * Returns:
f86f556ff29d Added dw_mutex_trylock() that functions like dw_mutex_lock() except
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1155
diff changeset
8662 * DW_ERROR_NONE on success, DW_ERROR_TIMEOUT if it is already locked.
f86f556ff29d Added dw_mutex_trylock() that functions like dw_mutex_lock() except
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1155
diff changeset
8663 */
f86f556ff29d Added dw_mutex_trylock() that functions like dw_mutex_lock() except
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1155
diff changeset
8664 int API dw_mutex_trylock(HMTX mutex)
f86f556ff29d Added dw_mutex_trylock() that functions like dw_mutex_lock() except
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1155
diff changeset
8665 {
f86f556ff29d Added dw_mutex_trylock() that functions like dw_mutex_lock() except
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1155
diff changeset
8666 if(pthread_mutex_trylock(mutex) == 0)
f86f556ff29d Added dw_mutex_trylock() that functions like dw_mutex_lock() except
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1155
diff changeset
8667 return DW_ERROR_NONE;
f86f556ff29d Added dw_mutex_trylock() that functions like dw_mutex_lock() except
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1155
diff changeset
8668 return DW_ERROR_TIMEOUT;
f86f556ff29d Added dw_mutex_trylock() that functions like dw_mutex_lock() except
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1155
diff changeset
8669 }
f86f556ff29d Added dw_mutex_trylock() that functions like dw_mutex_lock() except
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1155
diff changeset
8670
f86f556ff29d Added dw_mutex_trylock() that functions like dw_mutex_lock() except
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1155
diff changeset
8671 /*
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8672 * Reliquishes the access to the semaphore.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8673 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8674 * 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
8675 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8676 void dw_mutex_unlock(HMTX mutex)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8677 {
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8678 pthread_mutex_unlock(mutex);
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8679 }
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 * 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
8683 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8684 HEV dw_event_new(void)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8685 {
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8686 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
8687
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8688 if(!eve)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8689 return NULL;
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 /* 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
8692 * 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
8693 * 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
8694 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8695 pthread_mutex_init (&(eve->mutex), NULL);
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8696 pthread_mutex_lock (&(eve->mutex));
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8697 pthread_cond_init (&(eve->event), NULL);
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8698
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8699 pthread_mutex_unlock (&(eve->mutex));
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8700 eve->alive = 1;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8701 eve->posted = 0;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8702
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8703 return eve;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8704 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8705
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8706 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8707 * 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
8708 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8709 * 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
8710 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8711 int dw_event_reset (HEV eve)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8712 {
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8713 if(!eve)
986
87dc0f5f96d0 Fix return type of dw_listbox_selected() to be "int" instead of "unsigned int" to allow -1 return.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 983
diff changeset
8714 return DW_ERROR_NON_INIT;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8715
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8716 pthread_mutex_lock (&(eve->mutex));
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8717 pthread_cond_broadcast (&(eve->event));
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8718 pthread_cond_init (&(eve->event), NULL);
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8719 eve->posted = 0;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8720 pthread_mutex_unlock (&(eve->mutex));
986
87dc0f5f96d0 Fix return type of dw_listbox_selected() to be "int" instead of "unsigned int" to allow -1 return.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 983
diff changeset
8721 return DW_ERROR_NONE;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8722 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8723
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8724 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8725 * 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
8726 * 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
8727 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8728 * 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
8729 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8730 int dw_event_post (HEV eve)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8731 {
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8732 if(!eve)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8733 return FALSE;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8734
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8735 pthread_mutex_lock (&(eve->mutex));
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8736 pthread_cond_broadcast (&(eve->event));
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8737 eve->posted = 1;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8738 pthread_mutex_unlock (&(eve->mutex));
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8739 return 0;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8740 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8741
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8742 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8743 * 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
8744 * 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
8745 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8746 * 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
8747 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8748 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
8749 {
1155
e6a2f57c0842 Added support for infinite wait for dw_event_wait() on Mac, Unix and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1152
diff changeset
8750 int rc;
e6a2f57c0842 Added support for infinite wait for dw_event_wait() on Mac, Unix and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1152
diff changeset
8751
e6a2f57c0842 Added support for infinite wait for dw_event_wait() on Mac, Unix and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1152
diff changeset
8752 if(!eve)
e6a2f57c0842 Added support for infinite wait for dw_event_wait() on Mac, Unix and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1152
diff changeset
8753 return DW_ERROR_NON_INIT;
e6a2f57c0842 Added support for infinite wait for dw_event_wait() on Mac, Unix and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1152
diff changeset
8754
1202
5c1a01c6384d Think we need to check the posted state inside the mutex...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1201
diff changeset
8755 pthread_mutex_lock (&(eve->mutex));
5c1a01c6384d Think we need to check the posted state inside the mutex...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1201
diff changeset
8756
1155
e6a2f57c0842 Added support for infinite wait for dw_event_wait() on Mac, Unix and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1152
diff changeset
8757 if(eve->posted)
1202
5c1a01c6384d Think we need to check the posted state inside the mutex...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1201
diff changeset
8758 {
5c1a01c6384d Think we need to check the posted state inside the mutex...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1201
diff changeset
8759 pthread_mutex_unlock (&(eve->mutex));
5c1a01c6384d Think we need to check the posted state inside the mutex...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1201
diff changeset
8760 return DW_ERROR_NONE;
5c1a01c6384d Think we need to check the posted state inside the mutex...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1201
diff changeset
8761 }
1155
e6a2f57c0842 Added support for infinite wait for dw_event_wait() on Mac, Unix and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1152
diff changeset
8762
e6a2f57c0842 Added support for infinite wait for dw_event_wait() on Mac, Unix and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1152
diff changeset
8763 if(timeout != -1)
e6a2f57c0842 Added support for infinite wait for dw_event_wait() on Mac, Unix and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1152
diff changeset
8764 {
e6a2f57c0842 Added support for infinite wait for dw_event_wait() on Mac, Unix and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1152
diff changeset
8765 struct timeval now;
e6a2f57c0842 Added support for infinite wait for dw_event_wait() on Mac, Unix and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1152
diff changeset
8766 struct timespec timeo;
e6a2f57c0842 Added support for infinite wait for dw_event_wait() on Mac, Unix and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1152
diff changeset
8767
e6a2f57c0842 Added support for infinite wait for dw_event_wait() on Mac, Unix and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1152
diff changeset
8768 gettimeofday(&now, 0);
e6a2f57c0842 Added support for infinite wait for dw_event_wait() on Mac, Unix and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1152
diff changeset
8769 timeo.tv_sec = now.tv_sec + (timeout / 1000);
e6a2f57c0842 Added support for infinite wait for dw_event_wait() on Mac, Unix and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1152
diff changeset
8770 timeo.tv_nsec = now.tv_usec * 1000;
e6a2f57c0842 Added support for infinite wait for dw_event_wait() on Mac, Unix and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1152
diff changeset
8771 rc = pthread_cond_timedwait(&(eve->event), &(eve->mutex), &timeo);
e6a2f57c0842 Added support for infinite wait for dw_event_wait() on Mac, Unix and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1152
diff changeset
8772 }
e6a2f57c0842 Added support for infinite wait for dw_event_wait() on Mac, Unix and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1152
diff changeset
8773 else
e6a2f57c0842 Added support for infinite wait for dw_event_wait() on Mac, Unix and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1152
diff changeset
8774 rc = pthread_cond_wait(&(eve->event), &(eve->mutex));
e6a2f57c0842 Added support for infinite wait for dw_event_wait() on Mac, Unix and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1152
diff changeset
8775 pthread_mutex_unlock (&(eve->mutex));
e6a2f57c0842 Added support for infinite wait for dw_event_wait() on Mac, Unix and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1152
diff changeset
8776 if(!rc)
e6a2f57c0842 Added support for infinite wait for dw_event_wait() on Mac, Unix and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1152
diff changeset
8777 return DW_ERROR_NONE;
e6a2f57c0842 Added support for infinite wait for dw_event_wait() on Mac, Unix and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1152
diff changeset
8778 if(rc == ETIMEDOUT)
e6a2f57c0842 Added support for infinite wait for dw_event_wait() on Mac, Unix and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1152
diff changeset
8779 return DW_ERROR_TIMEOUT;
e6a2f57c0842 Added support for infinite wait for dw_event_wait() on Mac, Unix and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1152
diff changeset
8780 return DW_ERROR_GENERAL;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8781 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8782
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8783 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8784 * 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
8785 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8786 * 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
8787 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8788 int dw_event_close(HEV *eve)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8789 {
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8790 if(!eve || !(*eve))
986
87dc0f5f96d0 Fix return type of dw_listbox_selected() to be "int" instead of "unsigned int" to allow -1 return.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 983
diff changeset
8791 return DW_ERROR_NON_INIT;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8792
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8793 pthread_mutex_lock (&((*eve)->mutex));
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8794 pthread_cond_destroy (&((*eve)->event));
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8795 pthread_mutex_unlock (&((*eve)->mutex));
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8796 pthread_mutex_destroy (&((*eve)->mutex));
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8797 free(*eve);
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8798 *eve = NULL;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8799
986
87dc0f5f96d0 Fix return type of dw_listbox_selected() to be "int" instead of "unsigned int" to allow -1 return.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 983
diff changeset
8800 return DW_ERROR_NONE;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8801 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8802
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8803 struct _seminfo {
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8804 int fd;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8805 int waiting;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8806 };
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8807
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8808 static void _handle_sem(int *tmpsock)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8809 {
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8810 fd_set rd;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8811 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
8812 int listenfd = tmpsock[0];
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8813 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
8814 char command;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8815 sigset_t mask;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8816
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8817 sigfillset(&mask); /* Mask all allowed signals */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8818 pthread_sigmask(SIG_BLOCK, &mask, NULL);
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8819
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8820 /* problems */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8821 if(tmpsock[1] == -1)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8822 {
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8823 free(array);
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8824 return;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8825 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8826
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8827 array[0].fd = tmpsock[1];
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8828 array[0].waiting = 0;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8829
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8830 /* 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
8831 free(tmpsock);
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8832
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8833 while(1)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8834 {
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8835 FD_ZERO(&rd);
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8836 FD_SET(listenfd, &rd);
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8837
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8838 maxfd = listenfd;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8839
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8840 /* 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
8841 for(z=0;z<connectcount;z++)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8842 {
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8843 if(array[z].fd > maxfd)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8844 maxfd = array[z].fd;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8845
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8846 FD_SET(array[z].fd, &rd);
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8847 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8848
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8849 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
8850 return;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8851
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8852 if(FD_ISSET(listenfd, &rd))
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8853 {
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8854 struct _seminfo *newarray;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8855 int newfd = accept(listenfd, 0, 0);
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8856
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8857 if(newfd > -1)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8858 {
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8859 /* Add new connections to the set */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8860 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
8861 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
8862
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8863 newarray[connectcount].fd = newfd;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8864 newarray[connectcount].waiting = 0;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8865
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8866 connectcount++;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8867
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8868 /* Replace old array with new one */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8869 free(array);
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8870 array = newarray;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8871 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8872 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8873
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8874 /* 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
8875 for(z=0;z<connectcount;z++)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8876 {
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8877 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
8878 {
1110
404b639f096b Minor typecast fixes for warnings reported by clang on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1102
diff changeset
8879 if((bytesread = (int)read(array[z].fd, &command, 1)) < 1)
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8880 {
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8881 struct _seminfo *newarray;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8882
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8883 /* Remove this connection from the set */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8884 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
8885 if(!z)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8886 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
8887 else
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8888 {
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8889 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
8890 if(z!=(connectcount-1))
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8891 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
8892 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8893 connectcount--;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8894
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8895 /* Replace old array with new one */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8896 free(array);
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8897 array = newarray;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8898 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8899 else if(bytesread == 1)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8900 {
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8901 switch(command)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8902 {
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8903 case 0:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8904 {
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8905 /* Reset */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8906 posted = 0;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8907 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8908 break;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8909 case 1:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8910 /* Post */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8911 {
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8912 int s;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8913 char tmp = (char)0;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8914
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8915 posted = 1;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8916
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8917 for(s=0;s<connectcount;s++)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8918 {
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8919 /* The semaphore has been posted so
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8920 * 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
8921 * continue.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8922 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8923 if(array[s].waiting)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8924 write(array[s].fd, &tmp, 1);
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8925 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8926 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8927 break;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8928 case 2:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8929 /* Wait */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8930 {
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8931 char tmp = (char)0;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8932
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8933 array[z].waiting = 1;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8934
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8935 /* If we are posted exit immeditately */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8936 if(posted)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8937 write(array[z].fd, &tmp, 1);
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8938 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8939 break;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8940 case 3:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8941 {
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8942 /* Done Waiting */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8943 array[z].waiting = 0;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8944 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8945 break;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8946 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8947 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8948 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8949 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8950
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8951 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8952
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8953 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8954
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8955 /* 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
8956 /* 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
8957 * opened from other processes.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8958 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8959 * 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
8960 * 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
8961 * by other processes.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8962 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8963 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
8964 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8965 struct sockaddr_un un;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8966 int ev, *tmpsock = (int *)malloc(sizeof(int)*2);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8967 HEV eve;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8968 DWTID dwthread;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8969
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8970 if(!tmpsock)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8971 return NULL;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8972
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8973 eve = (HEV)malloc(sizeof(struct _dw_unix_event));
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8974
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8975 if(!eve)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8976 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8977 free(tmpsock);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8978 return NULL;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8979 }
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
8980
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8981 tmpsock[0] = socket(AF_UNIX, SOCK_STREAM, 0);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8982 ev = socket(AF_UNIX, SOCK_STREAM, 0);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8983 memset(&un, 0, sizeof(un));
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8984 un.sun_family=AF_UNIX;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8985 mkdir("/tmp/.dw", S_IWGRP|S_IWOTH);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8986 strcpy(un.sun_path, "/tmp/.dw/");
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8987 strcat(un.sun_path, name);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8988
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8989 /* just to be safe, this should be changed
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8990 * to support multiple instances.
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8991 */
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8992 remove(un.sun_path);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8993
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8994 bind(tmpsock[0], (struct sockaddr *)&un, sizeof(un));
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8995 listen(tmpsock[0], 0);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8996 connect(ev, (struct sockaddr *)&un, sizeof(un));
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8997 tmpsock[1] = accept(tmpsock[0], 0, 0);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8998
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8999 if(tmpsock[0] < 0 || tmpsock[1] < 0 || ev < 0)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9000 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9001 if(tmpsock[0] > -1)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9002 close(tmpsock[0]);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9003 if(tmpsock[1] > -1)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9004 close(tmpsock[1]);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9005 if(ev > -1)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9006 close(ev);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9007 free(tmpsock);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9008 free(eve);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9009 return NULL;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9010 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9011
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9012 /* Create a thread to handle this event semaphore */
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9013 pthread_create(&dwthread, NULL, (void *)_handle_sem, (void *)tmpsock);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9014 eve->alive = ev;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9015 return eve;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9016 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9017
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9018 /* 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
9019 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9020 * 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
9021 * 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
9022 * by other processes.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9023 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9024 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
9025 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9026 struct sockaddr_un un;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9027 HEV eve;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9028 int ev = socket(AF_UNIX, SOCK_STREAM, 0);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9029 if(ev < 0)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9030 return NULL;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9031
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9032 eve = (HEV)malloc(sizeof(struct _dw_unix_event));
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9033
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9034 if(!eve)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9035 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9036 close(ev);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9037 return NULL;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9038 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9039
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9040 un.sun_family=AF_UNIX;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9041 mkdir("/tmp/.dw", S_IWGRP|S_IWOTH);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9042 strcpy(un.sun_path, "/tmp/.dw/");
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9043 strcat(un.sun_path, name);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9044 connect(ev, (struct sockaddr *)&un, sizeof(un));
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9045 eve->alive = ev;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9046 return eve;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9047 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9048
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9049 /* 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
9050 * on this semaphore will block.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9051 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9052 * 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
9053 * an open or create call.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9054 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9055 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
9056 {
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9057 /* signal reset */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9058 char tmp = (char)0;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9059
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9060 if(!eve || eve->alive < 0)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9061 return 0;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9062
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9063 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
9064 return 0;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9065 return 1;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9066 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9067
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9068 /* 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
9069 * 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
9070 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9071 * 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
9072 * an open or create call.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9073 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9074 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
9075 {
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9076
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9077 /* signal post */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9078 char tmp = (char)1;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9079
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9080 if(!eve || eve->alive < 0)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9081 return 0;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9082
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9083 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
9084 return 0;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9085 return 1;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9086 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9087
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9088 /* 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
9089 * 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
9090 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9091 * 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
9092 * an open or create call.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9093 * 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
9094 * or -1 if indefinite.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9095 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9096 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
9097 {
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9098 fd_set rd;
1155
e6a2f57c0842 Added support for infinite wait for dw_event_wait() on Mac, Unix and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1152
diff changeset
9099 struct timeval tv, *useme = NULL;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9100 int retval = 0;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9101 char tmp;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9102
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9103 if(!eve || eve->alive < 0)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9104 return DW_ERROR_NON_INIT;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9105
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9106 /* Set the timout or infinite */
1155
e6a2f57c0842 Added support for infinite wait for dw_event_wait() on Mac, Unix and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1152
diff changeset
9107 if(timeout != -1)
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9108 {
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9109 tv.tv_sec = timeout / 1000;
1110
404b639f096b Minor typecast fixes for warnings reported by clang on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1102
diff changeset
9110 tv.tv_usec = (int)timeout % 1000;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9111
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9112 useme = &tv;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9113 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9114
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9115 FD_ZERO(&rd);
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9116 FD_SET(eve->alive, &rd);
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9117
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9118 /* Signal wait */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9119 tmp = (char)2;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9120 write(eve->alive, &tmp, 1);
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9121
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9122 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
9123
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9124 /* Signal done waiting. */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9125 tmp = (char)3;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9126 write(eve->alive, &tmp, 1);
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9127
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9128 if(retval == 0)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9129 return DW_ERROR_TIMEOUT;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9130 else if(retval == -1)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9131 return DW_ERROR_INTERRUPT;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9132
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9133 /* 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
9134 * we don't loop endlessly. :)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9135 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9136 read(eve->alive, &tmp, 1);
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9137 return 0;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9138 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9139
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9140 /* 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
9141 * 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
9142 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9143 * 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
9144 * an open or create call.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9145 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9146 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
9147 {
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9148 /* Finally close the domain socket,
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9149 * cleanup will continue in _handle_sem.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9150 */
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9151 if(eve)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9152 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9153 close(eve->alive);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9154 free(eve);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9155 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9156 return 0;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9157 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9158
697
830e1f3672b9 Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 696
diff changeset
9159 /* 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
9160 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
9161 {
830e1f3672b9 Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 696
diff changeset
9162 #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
9163 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
9164 [pool drain];
698
e19f69a78f21 Fix for pool being removed and not just drained.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 697
diff changeset
9165 pool = [[NSAutoreleasePool alloc] init];
e19f69a78f21 Fix for pool being removed and not just drained.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 697
diff changeset
9166 pthread_setspecific(_dw_pool_key, pool);
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
9167 #endif
697
830e1f3672b9 Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 696
diff changeset
9168 }
830e1f3672b9 Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 696
diff changeset
9169
830e1f3672b9 Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 696
diff changeset
9170 /*
830e1f3672b9 Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 696
diff changeset
9171 * Setup thread independent pools.
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9172 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9173 void _dwthreadstart(void *data)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9174 {
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
9175 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
9176 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
9177 NSColor *color;
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
9178
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
9179 /* 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
9180 #if !defined(GARBAGE_COLLECT)
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9181 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
9182 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
9183 #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
9184 _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
9185
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
9186 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
9187
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
9188 /* 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
9189 threadfunc(tmp[1]);
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
9190
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
9191 /* 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
9192 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
9193 [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
9194 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
9195 [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
9196 #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
9197 pool = pthread_getspecific(_dw_pool_key);
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9198 [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
9199 #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
9200 free(tmp);
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9201 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9202
1075
3d117071a50b Renamed Mac _dw_default_font() to dw_font_set_default() and added it on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1074
diff changeset
9203 /*
3d117071a50b Renamed Mac _dw_default_font() to dw_font_set_default() and added it on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1074
diff changeset
9204 * Sets the default font used on text based widgets.
3d117071a50b Renamed Mac _dw_default_font() to dw_font_set_default() and added it on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1074
diff changeset
9205 * Parameters:
3d117071a50b Renamed Mac _dw_default_font() to dw_font_set_default() and added it on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1074
diff changeset
9206 * fontname: Font name in Dynamic Windows format.
3d117071a50b Renamed Mac _dw_default_font() to dw_font_set_default() and added it on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1074
diff changeset
9207 */
3d117071a50b Renamed Mac _dw_default_font() to dw_font_set_default() and added it on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1074
diff changeset
9208 void API dw_font_set_default(char *fontname)
744
9882b0dfa304 Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 743
diff changeset
9209 {
9882b0dfa304 Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 743
diff changeset
9210 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
9211 {
9882b0dfa304 Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 743
diff changeset
9212 [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
9213 }
9882b0dfa304 Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 743
diff changeset
9214 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
9215 [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
9216 }
9882b0dfa304 Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 743
diff changeset
9217
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9218 /*
697
830e1f3672b9 Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 696
diff changeset
9219 * 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
9220 * Parameters:
830e1f3672b9 Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 696
diff changeset
9221 * 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
9222 * 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
9223 */
830e1f3672b9 Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 696
diff changeset
9224 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
9225 {
1098
9e1d6fa397be Experimental change to set the current working directory to the bundle path on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1093
diff changeset
9226 /* Correct the startup path if run from a bundle */
9e1d6fa397be Experimental change to set the current working directory to the bundle path on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1093
diff changeset
9227 if(argc > 0 && argv[0])
9e1d6fa397be Experimental change to set the current working directory to the bundle path on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1093
diff changeset
9228 {
9e1d6fa397be Experimental change to set the current working directory to the bundle path on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1093
diff changeset
9229 char *pathcopy = strdup(argv[0]);
9e1d6fa397be Experimental change to set the current working directory to the bundle path on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1093
diff changeset
9230 char *app = strstr(pathcopy, ".app/");
1128
7d7535f6bc4e Added ability to set background color of MLE; setting foreground still outstanding.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1120
diff changeset
9231
1098
9e1d6fa397be Experimental change to set the current working directory to the bundle path on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1093
diff changeset
9232 if(app)
9e1d6fa397be Experimental change to set the current working directory to the bundle path on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1093
diff changeset
9233 {
9e1d6fa397be Experimental change to set the current working directory to the bundle path on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1093
diff changeset
9234 char pathbuf[PATH_MAX];
1128
7d7535f6bc4e Added ability to set background color of MLE; setting foreground still outstanding.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1120
diff changeset
9235
1098
9e1d6fa397be Experimental change to set the current working directory to the bundle path on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1093
diff changeset
9236 *app = 0;
1128
7d7535f6bc4e Added ability to set background color of MLE; setting foreground still outstanding.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1120
diff changeset
9237
1098
9e1d6fa397be Experimental change to set the current working directory to the bundle path on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1093
diff changeset
9238 getcwd(pathbuf, PATH_MAX);
1128
7d7535f6bc4e Added ability to set background color of MLE; setting foreground still outstanding.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1120
diff changeset
9239
1098
9e1d6fa397be Experimental change to set the current working directory to the bundle path on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1093
diff changeset
9240 /* If run from a bundle the path seems to be / */
9e1d6fa397be Experimental change to set the current working directory to the bundle path on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1093
diff changeset
9241 if(strcmp(pathbuf, "/") == 0)
9e1d6fa397be Experimental change to set the current working directory to the bundle path on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1093
diff changeset
9242 {
9e1d6fa397be Experimental change to set the current working directory to the bundle path on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1093
diff changeset
9243 size_t len;
1128
7d7535f6bc4e Added ability to set background color of MLE; setting foreground still outstanding.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1120
diff changeset
9244
1098
9e1d6fa397be Experimental change to set the current working directory to the bundle path on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1093
diff changeset
9245 strncpy(pathbuf, pathcopy, PATH_MAX);
1128
7d7535f6bc4e Added ability to set background color of MLE; setting foreground still outstanding.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1120
diff changeset
9246
1098
9e1d6fa397be Experimental change to set the current working directory to the bundle path on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1093
diff changeset
9247 len = strlen(pathbuf);
1128
7d7535f6bc4e Added ability to set background color of MLE; setting foreground still outstanding.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1120
diff changeset
9248
1098
9e1d6fa397be Experimental change to set the current working directory to the bundle path on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1093
diff changeset
9249 while(len > 0 && pathbuf[len] != '/')
9e1d6fa397be Experimental change to set the current working directory to the bundle path on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1093
diff changeset
9250 {
9e1d6fa397be Experimental change to set the current working directory to the bundle path on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1093
diff changeset
9251 len--;
9e1d6fa397be Experimental change to set the current working directory to the bundle path on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1093
diff changeset
9252 }
9e1d6fa397be Experimental change to set the current working directory to the bundle path on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1093
diff changeset
9253 pathbuf[len] = '\0';
9e1d6fa397be Experimental change to set the current working directory to the bundle path on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1093
diff changeset
9254 chdir(pathbuf);
9e1d6fa397be Experimental change to set the current working directory to the bundle path on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1093
diff changeset
9255 }
9e1d6fa397be Experimental change to set the current working directory to the bundle path on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1093
diff changeset
9256 }
9e1d6fa397be Experimental change to set the current working directory to the bundle path on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1093
diff changeset
9257 free(pathcopy);
9e1d6fa397be Experimental change to set the current working directory to the bundle path on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1093
diff changeset
9258 }
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
9259 /* 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
9260 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
9261 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
9262 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
9263 /* 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
9264 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
9265 /* 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
9266 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
9267 /* 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
9268 #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
9269 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
9270 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
9271 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
9272 #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
9273 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
9274 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
9275 _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
9276 /* 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
9277 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
9278 [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
9279 [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
9280 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
9281 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
9282 /* 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
9283 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
9284 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
9285 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
9286 /* 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
9287 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
9288 [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
9289 [thread release];
859
80a88c91ccf6 Implemented vertical centering on text fields.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 858
diff changeset
9290 [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
9291 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
9292 }
830e1f3672b9 Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 696
diff changeset
9293
830e1f3672b9 Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 696
diff changeset
9294 /*
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9295 * 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
9296 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9297 * 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
9298 * 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
9299 * 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
9300 * 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
9301 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9302 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
9303 {
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9304 char namebuf[1024];
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9305 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
9306
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9307 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
9308 sprintf(namebuf, "/tmp/.dw/%s", name);
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9309
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9310 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
9311 {
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9312 free(handle);
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9313 return NULL;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9314 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9315
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9316 ftruncate(handle->fd, size);
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9317
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9318 /* 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
9319 *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
9320
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9321 if(*dest == MAP_FAILED)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9322 {
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9323 close(handle->fd);
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9324 *dest = NULL;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9325 free(handle);
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9326 return NULL;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9327 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9328
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9329 handle->size = size;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9330 handle->sid = getsid(0);
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9331 handle->path = strdup(namebuf);
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9332
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9333 return handle;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9334 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9335
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9336 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9337 * 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
9338 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9339 * 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
9340 * 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
9341 * 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
9342 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9343 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
9344 {
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9345 char namebuf[1024];
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9346 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
9347
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9348 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
9349 sprintf(namebuf, "/tmp/.dw/%s", name);
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9350
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9351 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
9352 {
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9353 free(handle);
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9354 return NULL;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9355 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9356
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9357 /* 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
9358 *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
9359
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9360 if(*dest == MAP_FAILED)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9361 {
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9362 close(handle->fd);
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9363 *dest = NULL;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9364 free(handle);
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9365 return NULL;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9366 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9367
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9368 handle->size = size;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9369 handle->sid = -1;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9370 handle->path = NULL;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9371
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9372 return handle;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9373 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9374
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9375 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9376 * 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
9377 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9378 * 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
9379 * 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
9380 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9381 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
9382 {
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9383 struct _dw_unix_shm *h = handle;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9384 int rc = munmap(ptr, h->size);
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9385
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9386 close(h->fd);
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9387 if(h->path)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9388 {
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9389 /* 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
9390 * creator of the file.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9391 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9392 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
9393 remove(h->path);
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9394 free(h->path);
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9395 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9396 return rc;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9397 }
697
830e1f3672b9 Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 696
diff changeset
9398
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9399 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9400 * 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
9401 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9402 * 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
9403 * 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
9404 * 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
9405 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9406 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
9407 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9408 DWTID thread;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9409 void **tmp = malloc(sizeof(void *) * 2);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9410 int rc;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9411
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9412 tmp[0] = func;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9413 tmp[1] = data;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9414
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9415 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
9416 if(rc == 0)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9417 return thread;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9418 return (DWTID)-1;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9419 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9420
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9421 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9422 * Ends execution of current thread immediately.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9423 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9424 void dw_thread_end(void)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9425 {
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9426 pthread_exit(NULL);
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9427 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9428
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9429 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9430 * Returns the current thread's ID.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9431 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9432 DWTID dw_thread_id(void)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9433 {
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9434 return (DWTID)pthread_self();
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9435 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9436
661
eee90a788876 Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 660
diff changeset
9437 /*
eee90a788876 Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 660
diff changeset
9438 * 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
9439 * Parameters:
eee90a788876 Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 660
diff changeset
9440 * program: Program name with optional path.
eee90a788876 Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 660
diff changeset
9441 * 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
9442 * 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
9443 * Returns:
eee90a788876 Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 660
diff changeset
9444 * -1 on error.
eee90a788876 Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 660
diff changeset
9445 */
eee90a788876 Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 660
diff changeset
9446 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
9447 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9448 int ret = -1;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
9449
738
52d5ed00f892 Use NSWorkplace to launch GUI applications instead of fork() and exec().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 737
diff changeset
9450 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
9451 {
52d5ed00f892 Use NSWorkplace to launch GUI applications instead of fork() and exec().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 737
diff changeset
9452 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
9453 {
52d5ed00f892 Use NSWorkplace to launch GUI applications instead of fork() and exec().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 737
diff changeset
9454 [[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
9455 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
9456 }
52d5ed00f892 Use NSWorkplace to launch GUI applications instead of fork() and exec().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 737
diff changeset
9457 else
52d5ed00f892 Use NSWorkplace to launch GUI applications instead of fork() and exec().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 737
diff changeset
9458 {
52d5ed00f892 Use NSWorkplace to launch GUI applications instead of fork() and exec().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 737
diff changeset
9459 [[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
9460 }
52d5ed00f892 Use NSWorkplace to launch GUI applications instead of fork() and exec().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 737
diff changeset
9461 return 0;
52d5ed00f892 Use NSWorkplace to launch GUI applications instead of fork() and exec().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 737
diff changeset
9462 }
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
9463
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9464 if((ret = fork()) == 0)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9465 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9466 int i;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
9467
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9468 for (i = 3; i < 256; i++)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9469 close(i);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9470 setsid();
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
9471
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9472 if(type == DW_EXEC_CON)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9473 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9474 char **tmpargs;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
9475
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9476 if(!params)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9477 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9478 tmpargs = malloc(sizeof(char *));
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9479 tmpargs[0] = NULL;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9480 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9481 else
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9482 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9483 int z = 0;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
9484
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9485 while(params[z])
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9486 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9487 z++;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9488 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9489 tmpargs = malloc(sizeof(char *)*(z+3));
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9490 z=0;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9491 tmpargs[0] = "xterm";
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9492 tmpargs[1] = "-e";
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9493 while(params[z])
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9494 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9495 tmpargs[z+2] = params[z];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9496 z++;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9497 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9498 tmpargs[z+2] = NULL;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9499 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9500 execvp("xterm", tmpargs);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9501 free(tmpargs);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9502 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9503 /* If we got here exec failed */
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9504 _exit(-1);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9505 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9506 return ret;
661
eee90a788876 Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 660
diff changeset
9507 }
eee90a788876 Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 660
diff changeset
9508
eee90a788876 Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 660
diff changeset
9509 /*
eee90a788876 Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 660
diff changeset
9510 * 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
9511 * Parameters:
eee90a788876 Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 660
diff changeset
9512 * url: Uniform resource locator.
eee90a788876 Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 660
diff changeset
9513 */
eee90a788876 Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 660
diff changeset
9514 int dw_browse(char *url)
eee90a788876 Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 660
diff changeset
9515 {
715
5f8102bd7646 dw_browse() reimplmented so it actually works as expected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 714
diff changeset
9516 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
9517 [[NSWorkspace sharedWorkspace] openURL:myurl];
1115
03cd2f3e929d Fixed a documentation and template error regarding dw_browse() return code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1110
diff changeset
9518 return DW_ERROR_NONE;
03cd2f3e929d Fixed a documentation and template error regarding dw_browse() return code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1110
diff changeset
9519 }
1137
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1135
diff changeset
9520
1141
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
9521 typedef struct _dwprint
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
9522 {
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
9523 NSPrintInfo *pi;
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
9524 int (*drawfunc)(HPRINT, HPIXMAP, int, void *);
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
9525 void *drawdata;
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
9526 unsigned long flags;
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
9527 } DWPrint;
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
9528
1137
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1135
diff changeset
9529 /*
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1135
diff changeset
9530 * Creates a new print object.
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1135
diff changeset
9531 * Parameters:
1152
58b5374355ab Added print jobname parameter to dw_print_new().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1147
diff changeset
9532 * jobname: Name of the print job to show in the queue.
1137
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1135
diff changeset
9533 * flags: Flags to initially configure the print object.
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1135
diff changeset
9534 * pages: Number of pages to print.
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1135
diff changeset
9535 * drawfunc: The pointer to the function to be used as the callback.
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1135
diff changeset
9536 * drawdata: User data to be passed to the handler function.
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1135
diff changeset
9537 * Returns:
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1135
diff changeset
9538 * A handle to the print object or NULL on failure.
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1135
diff changeset
9539 */
1152
58b5374355ab Added print jobname parameter to dw_print_new().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1147
diff changeset
9540 HPRINT API dw_print_new(char *jobname, unsigned long flags, unsigned int pages, void *drawfunc, void *drawdata)
1137
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1135
diff changeset
9541 {
1141
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
9542 DWPrint *print;
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
9543 NSPrintPanel *panel;
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
9544 PMPrintSettings settings;
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
9545 NSPrintInfo *pi;
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
9546
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
9547 if(!drawfunc || !(print = calloc(1, sizeof(DWPrint))))
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
9548 {
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
9549 return NULL;
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
9550 }
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
9551
1152
58b5374355ab Added print jobname parameter to dw_print_new().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1147
diff changeset
9552 if(!jobname)
58b5374355ab Added print jobname parameter to dw_print_new().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1147
diff changeset
9553 jobname = "Dynamic Windows Print Job";
58b5374355ab Added print jobname parameter to dw_print_new().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1147
diff changeset
9554
1141
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
9555 print->drawfunc = drawfunc;
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
9556 print->drawdata = drawdata;
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
9557 print->flags = flags;
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
9558
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
9559 /* Get the page range */
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
9560 pi = [NSPrintInfo sharedPrintInfo];
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
9561 settings = [pi PMPrintSettings];
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
9562 PMSetPageRange(settings, 1, pages);
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
9563 PMSetFirstPage(settings, 1, true);
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
9564 PMSetLastPage(settings, pages, true);
1152
58b5374355ab Added print jobname parameter to dw_print_new().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1147
diff changeset
9565 PMPrintSettingsSetJobName(settings, (CFStringRef)[NSString stringWithUTF8String:jobname]);
1141
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
9566 [pi updateFromPMPrintSettings];
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
9567
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
9568 /* Create and show the print panel */
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
9569 panel = [NSPrintPanel printPanel];
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
9570 if(!panel || [panel runModalWithPrintInfo:pi] == NSCancelButton)
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
9571 {
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
9572 free(print);
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
9573 return NULL;
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
9574 }
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
9575 /* Put the print info from the panel into the operation */
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
9576 print->pi = pi;
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
9577
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
9578 return print;
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
9579 }
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
9580
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
9581 /*
1137
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1135
diff changeset
9582 * Runs the print job, causing the draw page callbacks to fire.
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1135
diff changeset
9583 * Parameters:
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1135
diff changeset
9584 * print: Handle to the print object returned by dw_print_new().
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1135
diff changeset
9585 * flags: Flags to run the print job.
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1135
diff changeset
9586 * Returns:
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1135
diff changeset
9587 * DW_ERROR_UNKNOWN on error or DW_ERROR_NONE on success.
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1135
diff changeset
9588 */
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1135
diff changeset
9589 int API dw_print_run(HPRINT print, unsigned long flags)
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1135
diff changeset
9590 {
1141
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
9591 DWPrint *p = print;
1175
eb4589ddff3e Added some test code to save what we are trying to print as a PNG on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1160
diff changeset
9592 NSBitmapImageRep *rep, *rep2;
1141
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
9593 NSPrintInfo *pi;
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
9594 NSPrintOperation *po;
1175
eb4589ddff3e Added some test code to save what we are trying to print as a PNG on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1160
diff changeset
9595 HPIXMAP pixmap, pixmap2;
eb4589ddff3e Added some test code to save what we are trying to print as a PNG on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1160
diff changeset
9596 NSImage *image, *flipped;
1141
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
9597 NSImageView *iv;
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
9598 NSSize size;
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
9599 PMPrintSettings settings;
1143
b1b23de965d7 Fixed using a pointer after being free()ed on Windows and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1141
diff changeset
9600 int x, result = DW_ERROR_UNKNOWN;
1141
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
9601 UInt32 start, end;
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
9602
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
9603 if(!p)
1143
b1b23de965d7 Fixed using a pointer after being free()ed on Windows and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1141
diff changeset
9604 return result;
1141
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
9605
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
9606 /* Figure out the printer/paper size */
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
9607 pi = p->pi;
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
9608 size = [pi paperSize];
1176
408ea33b19cf Ok fixed a problem with the last commit using the wrong representation on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1175
diff changeset
9609 /* Okay the size reported is really small... and everything
408ea33b19cf Ok fixed a problem with the last commit using the wrong representation on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1175
diff changeset
9610 * in Cocoa is scaled so ... multiply by 2 to get a better
408ea33b19cf Ok fixed a problem with the last commit using the wrong representation on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1175
diff changeset
9611 * resolution but maintain the right aspect ratio.
408ea33b19cf Ok fixed a problem with the last commit using the wrong representation on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1175
diff changeset
9612 */
408ea33b19cf Ok fixed a problem with the last commit using the wrong representation on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1175
diff changeset
9613 size.width *= 2;
408ea33b19cf Ok fixed a problem with the last commit using the wrong representation on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1175
diff changeset
9614 size.height *= 2;
1141
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
9615 /* Create an image view to print and a pixmap to draw into */
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
9616 iv = [[NSImageView alloc] init];
1143
b1b23de965d7 Fixed using a pointer after being free()ed on Windows and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1141
diff changeset
9617 pixmap = dw_pixmap_new(iv, (int)size.width, (int)size.height, 8);
1141
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
9618 rep = pixmap->image;
1175
eb4589ddff3e Added some test code to save what we are trying to print as a PNG on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1160
diff changeset
9619 pixmap2 = dw_pixmap_new(iv, (int)size.width, (int)size.height, 8);
eb4589ddff3e Added some test code to save what we are trying to print as a PNG on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1160
diff changeset
9620 rep2 = pixmap2->image;
1141
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
9621
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
9622 /* Create an image with the data from the pixmap
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
9623 * to go into the image view.
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
9624 */
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
9625 image = [[NSImage alloc] initWithSize:[rep size]];
1175
eb4589ddff3e Added some test code to save what we are trying to print as a PNG on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1160
diff changeset
9626 flipped = [[NSImage alloc] initWithSize:[rep size]];
1141
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
9627 [image addRepresentation:rep];
1176
408ea33b19cf Ok fixed a problem with the last commit using the wrong representation on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1175
diff changeset
9628 [flipped addRepresentation:rep2];
1175
eb4589ddff3e Added some test code to save what we are trying to print as a PNG on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1160
diff changeset
9629 [iv setImage:flipped];
1144
5878dbfafbe2 Need to size the NSImageView to print it apparently on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1143
diff changeset
9630 [iv setImageScaling:NSScaleProportionally];
5878dbfafbe2 Need to size the NSImageView to print it apparently on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1143
diff changeset
9631 [iv setFrameOrigin:NSMakePoint(0,0)];
5878dbfafbe2 Need to size the NSImageView to print it apparently on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1143
diff changeset
9632 [iv setFrameSize:size];
1141
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
9633
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
9634 /* Create the print operation using the image view and
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
9635 * print info obtained from the panel in the last call.
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
9636 */
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
9637 po = [NSPrintOperation printOperationWithView:iv printInfo:pi];
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
9638 [po setShowsPrintPanel:NO];
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
9639
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
9640 /* Get the page range */
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
9641 settings = [pi PMPrintSettings];
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
9642 PMGetFirstPage(settings, &start);
1143
b1b23de965d7 Fixed using a pointer after being free()ed on Windows and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1141
diff changeset
9643 if(start > 0)
1141
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
9644 start--;
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
9645 PMGetLastPage(settings, &end);
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
9646 PMSetPageRange(settings, 1, 1);
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
9647 PMSetFirstPage(settings, 1, true);
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
9648 PMSetLastPage(settings, 1, true);
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
9649 [pi updateFromPMPrintSettings];
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
9650
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
9651 /* Cycle through each page */
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
9652 for(x=start; x<end && p->drawfunc; x++)
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
9653 {
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
9654 /* Call the application's draw function */
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
9655 p->drawfunc(print, pixmap, x, p->drawdata);
1175
eb4589ddff3e Added some test code to save what we are trying to print as a PNG on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1160
diff changeset
9656 /* Internal representation is flipped... so flip again so we can print */
eb4589ddff3e Added some test code to save what we are trying to print as a PNG on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1160
diff changeset
9657 _flip_image(image, rep2, size);
1176
408ea33b19cf Ok fixed a problem with the last commit using the wrong representation on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1175
diff changeset
9658 #ifdef DEBUG_PRINT
1175
eb4589ddff3e Added some test code to save what we are trying to print as a PNG on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1160
diff changeset
9659 /* Save it to file to see what we have */
eb4589ddff3e Added some test code to save what we are trying to print as a PNG on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1160
diff changeset
9660 NSData *data = [rep2 representationUsingType: NSPNGFileType properties: nil];
eb4589ddff3e Added some test code to save what we are trying to print as a PNG on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1160
diff changeset
9661 [data writeToFile: @"print.png" atomically: NO];
1176
408ea33b19cf Ok fixed a problem with the last commit using the wrong representation on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1175
diff changeset
9662 #endif
1141
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
9663 /* Print the image view */
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
9664 [po runOperation];
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
9665 /* Fill the pixmap with white in case we are printing more pages */
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
9666 dw_color_foreground_set(DW_CLR_WHITE);
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
9667 dw_draw_rect(0, pixmap, TRUE, 0, 0, (int)size.width, (int)size.height);
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
9668 }
1143
b1b23de965d7 Fixed using a pointer after being free()ed on Windows and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1141
diff changeset
9669 if(p->drawfunc)
b1b23de965d7 Fixed using a pointer after being free()ed on Windows and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1141
diff changeset
9670 result = DW_ERROR_NONE;
1141
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
9671 /* Free memory */
1144
5878dbfafbe2 Need to size the NSImageView to print it apparently on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1143
diff changeset
9672 [image release];
1175
eb4589ddff3e Added some test code to save what we are trying to print as a PNG on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1160
diff changeset
9673 [flipped release];
1141
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
9674 dw_pixmap_destroy(pixmap);
1175
eb4589ddff3e Added some test code to save what we are trying to print as a PNG on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1160
diff changeset
9675 dw_pixmap_destroy(pixmap2);
1141
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
9676 free(p);
1144
5878dbfafbe2 Need to size the NSImageView to print it apparently on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1143
diff changeset
9677 [iv release];
1143
b1b23de965d7 Fixed using a pointer after being free()ed on Windows and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1141
diff changeset
9678 return result;
1137
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1135
diff changeset
9679 }
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1135
diff changeset
9680
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1135
diff changeset
9681 /*
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1135
diff changeset
9682 * Cancels the print job, typically called from a draw page callback.
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1135
diff changeset
9683 * Parameters:
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1135
diff changeset
9684 * print: Handle to the print object returned by dw_print_new().
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1135
diff changeset
9685 */
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1135
diff changeset
9686 void API dw_print_cancel(HPRINT print)
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1135
diff changeset
9687 {
1141
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
9688 DWPrint *p = print;
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
9689
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
9690 if(p)
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
9691 p->drawfunc = NULL;
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
9692 }
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
9693